|
@@ -10,16 +10,20 @@ import com.zanxiang.game.module.mybatis.entity.GameUserRole;
|
|
import com.zanxiang.game.module.mybatis.entity.User;
|
|
import com.zanxiang.game.module.mybatis.entity.User;
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAppletShellMapper;
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAppletShellMapper;
|
|
import com.zanxiang.game.module.sdk.enums.ShellSwitchEnum;
|
|
import com.zanxiang.game.module.sdk.enums.ShellSwitchEnum;
|
|
|
|
+import com.zanxiang.game.module.sdk.pojo.result.IpCheckResult;
|
|
import com.zanxiang.game.module.sdk.service.IGameAppletShellService;
|
|
import com.zanxiang.game.module.sdk.service.IGameAppletShellService;
|
|
import com.zanxiang.game.module.sdk.service.IGameExtService;
|
|
import com.zanxiang.game.module.sdk.service.IGameExtService;
|
|
import com.zanxiang.game.module.sdk.service.IGameUserRoleService;
|
|
import com.zanxiang.game.module.sdk.service.IGameUserRoleService;
|
|
|
|
+import com.zanxiang.game.module.sdk.service.IUserCardService;
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
import com.zanxiang.module.util.JsonUtil;
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
|
+import com.zanxiang.module.web.util.IpUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.apache.logging.log4j.util.Strings;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
@@ -39,6 +43,9 @@ public class GameAppletShellServiceImpl extends ServiceImpl<GameAppletShellMappe
|
|
@Autowired
|
|
@Autowired
|
|
private IGameUserRoleService gameUserRoleService;
|
|
private IGameUserRoleService gameUserRoleService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IUserCardService userCardService;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Integer getShellSwitch(String appId, String version) {
|
|
public Integer getShellSwitch(String appId, String version) {
|
|
log.error("壳包接口收到请求, appId : {}, version : {}", appId, version);
|
|
log.error("壳包接口收到请求, appId : {}, version : {}", appId, version);
|
|
@@ -82,7 +89,7 @@ public class GameAppletShellServiceImpl extends ServiceImpl<GameAppletShellMappe
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Integer getUserShellSwitch(User user, boolean register) {
|
|
|
|
|
|
+ public Integer getUserShellSwitch(User user, boolean register, HttpServletRequest request) {
|
|
GameAppletShell gameAppletShell = super.getOne(new LambdaQueryWrapper<GameAppletShell>()
|
|
GameAppletShell gameAppletShell = super.getOne(new LambdaQueryWrapper<GameAppletShell>()
|
|
.eq(GameAppletShell::getGameId, user.getGameId()));
|
|
.eq(GameAppletShell::getGameId, user.getGameId()));
|
|
//未设置, 统一返回关闭
|
|
//未设置, 统一返回关闭
|
|
@@ -103,12 +110,14 @@ public class GameAppletShellServiceImpl extends ServiceImpl<GameAppletShellMappe
|
|
if (Objects.equals(proControlType, ShellControlEnum.SHELL_CONTROL_NEW_USER_OPEN.getShellControl())) {
|
|
if (Objects.equals(proControlType, ShellControlEnum.SHELL_CONTROL_NEW_USER_OPEN.getShellControl())) {
|
|
return register ? ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch() : ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
return register ? ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch() : ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //查询用户角色列表
|
|
|
|
+ List<GameUserRole> gameUserRoleList = gameUserRoleService.list(new LambdaQueryWrapper<GameUserRole>()
|
|
|
|
+ .eq(GameUserRole::getUserId, user.getId())
|
|
|
|
+ .eq(GameUserRole::getGameId, user.getGameId()));
|
|
|
|
+
|
|
//等级控制开启
|
|
//等级控制开启
|
|
if (Objects.equals(proControlType, ShellControlEnum.SHELL_CONTROL_LOW_LEVEL_OPEN.getShellControl())) {
|
|
if (Objects.equals(proControlType, ShellControlEnum.SHELL_CONTROL_LOW_LEVEL_OPEN.getShellControl())) {
|
|
- //查询用户角色等级
|
|
|
|
- List<GameUserRole> gameUserRoleList = gameUserRoleService.list(new LambdaQueryWrapper<GameUserRole>()
|
|
|
|
- .eq(GameUserRole::getUserId, user.getId())
|
|
|
|
- .eq(GameUserRole::getGameId, user.getGameId()));
|
|
|
|
//不存在角色的新用户, 开启
|
|
//不存在角色的新用户, 开启
|
|
if (CollectionUtils.isEmpty(gameUserRoleList)) {
|
|
if (CollectionUtils.isEmpty(gameUserRoleList)) {
|
|
return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
@@ -121,6 +130,39 @@ public class GameAppletShellServiceImpl extends ServiceImpl<GameAppletShellMappe
|
|
}
|
|
}
|
|
return ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
return ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //省份屏蔽
|
|
|
|
+ if (Objects.equals(proControlType, ShellControlEnum.SHELL_CONTROL_PROV_OPEN.getShellControl())) {
|
|
|
|
+ if (Strings.isBlank(gameAppletShell.getProvShield())) {
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+ String prov = null;
|
|
|
|
+ try {
|
|
|
|
+ IpCheckResult result = userCardService.userIpCheck(IpUtil.getRealIp(request));
|
|
|
|
+ prov = result.getData().getResult().getProv();
|
|
|
|
+ } catch (Exception ignored) {
|
|
|
|
+ }
|
|
|
|
+ //未查询到归属地, 或者不包含屏蔽省份, 关闭壳包
|
|
|
|
+ if (prov == null || !prov.contains(gameAppletShell.getProvShield())) {
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+ //未设置更多的等级限制, 直接进壳
|
|
|
|
+ if (gameAppletShell.getProControlLevel() == null) {
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+ //不存在角色的新用户, 开启
|
|
|
|
+ if (CollectionUtils.isEmpty(gameUserRoleList)) {
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+ //获取用户等级最高的角色
|
|
|
|
+ GameUserRole gameUserRole = gameUserRoleList.stream().max(Comparator.comparing(GameUserRole::getRoleLevel)).orElse(null);
|
|
|
|
+ //角色不存在, 或者等级小于等于控制等级
|
|
|
|
+ if (gameUserRole == null || gameUserRole.getRoleLevel() <= gameAppletShell.getProControlLevel()) {
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+ return ShellSwitchEnum.SHELL_SWITCH_CLOSE.getShellSwitch();
|
|
|
|
+ }
|
|
|
|
+
|
|
log.error("壳包控制配置不存在, 默认进壳包, userId : {}, gameAppletShell : {}", user.getId(), JsonUtil.toString(gameAppletShell));
|
|
log.error("壳包控制配置不存在, 默认进壳包, userId : {}, gameAppletShell : {}", user.getId(), JsonUtil.toString(gameAppletShell));
|
|
return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
return ShellSwitchEnum.SHELL_SWITCH_OPEN.getShellSwitch();
|
|
}
|
|
}
|