|
@@ -5,10 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.BanStatusEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.HttpStatusEnum;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.Game;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.GameExt;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.User;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.UserCard;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.*;
|
|
|
import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
|
|
|
import com.zanxiang.game.module.sdk.enums.KafkaEventTrackEnum;
|
|
|
import com.zanxiang.game.module.sdk.enums.LoginTypeEnum;
|
|
@@ -29,6 +26,7 @@ import com.zanxiang.module.util.JsonUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
|
import com.zanxiang.module.util.pojo.ResultVO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.logging.log4j.util.Strings;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -115,6 +113,9 @@ public class LoginServiceImpl implements IRegisterLoginService {
|
|
|
@Autowired
|
|
|
private IDistributedLockComponent distributedLockComponent;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IUserEventService userEventService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public ResultVO<UserLoginVO> loginWxCode(LoginVxCodeParam param, UserData userData, HttpServletRequest request) {
|
|
@@ -212,6 +213,8 @@ public class LoginServiceImpl implements IRegisterLoginService {
|
|
|
//返回登录信息
|
|
|
return ResultVO.ok(userLoginVO);
|
|
|
}
|
|
|
+ //设备账号数量检测
|
|
|
+ this.accountCheck(username, userData);
|
|
|
//用户注册, 用户名密码校验
|
|
|
HttpStatusEnum checkRegisterEnum = this.checkRegister(userData.getGameId(), username, password);
|
|
|
if (!Objects.equals(checkRegisterEnum, HttpStatusEnum.SUCCESS)) {
|
|
@@ -260,6 +263,8 @@ public class LoginServiceImpl implements IRegisterLoginService {
|
|
|
//返回登录信息
|
|
|
return ResultVO.ok(userLoginVO);
|
|
|
}
|
|
|
+ //设备账号数量检测
|
|
|
+ this.accountCheck(mobile, userData);
|
|
|
//用户注册
|
|
|
user = userCreateSave(userData, mobile, null, mobile, null, null);
|
|
|
//返回登录信息
|
|
@@ -267,6 +272,56 @@ public class LoginServiceImpl implements IRegisterLoginService {
|
|
|
return ResultVO.ok(userLoginVO);
|
|
|
}
|
|
|
|
|
|
+ private void accountCheck(String userName, UserData userData) {
|
|
|
+ //非安卓设备, 无法限制
|
|
|
+ if (Strings.isBlank(userData.getAndroidId())) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Game game = gameService.getById(userData.getGameId());
|
|
|
+ //仙剑游戏限制注册账号数量, 其他游戏直接过
|
|
|
+ if (game == null || !Objects.equals(game.getSuperGameId(), 12L)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //内部账号, 不受监控
|
|
|
+ if (userEventService.count(new LambdaQueryWrapper<UserEvent>()
|
|
|
+ .eq(UserEvent::getGameId, userData.getGameId())
|
|
|
+ .and(qw -> qw.eq(UserEvent::getUsername, userName)
|
|
|
+ .or().eq(UserEvent::getMobile, userName)
|
|
|
+ .or().eq(UserEvent::getIp, userData.getIp()))
|
|
|
+ ) > 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //判断安卓设备已经注册过2个账号
|
|
|
+ LambdaQueryWrapper<User> queryWrapper = new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getGameId, userData.getGameId());
|
|
|
+ //条件匹配
|
|
|
+ queryWrapper.and(qw -> {
|
|
|
+ boolean hasCondition = false;
|
|
|
+ //安卓id匹配
|
|
|
+ if (StringUtils.isNoneBlank(userData.getAndroidId())) {
|
|
|
+ qw.or().eq(User::getAndroidId, userData.getAndroidId());
|
|
|
+ hasCondition = true;
|
|
|
+ }
|
|
|
+ //oaid匹配
|
|
|
+ if (StringUtils.isNoneBlank(userData.getOaid())) {
|
|
|
+ qw.or().eq(User::getOaid, userData.getOaid());
|
|
|
+ hasCondition = true;
|
|
|
+ }
|
|
|
+ //imei匹配
|
|
|
+ if (StringUtils.isNoneBlank(userData.getImei())) {
|
|
|
+ qw.or().eq(User::getImei, userData.getImei());
|
|
|
+ hasCondition = true;
|
|
|
+ }
|
|
|
+ // 避免无条件的OR查询
|
|
|
+ if (!hasCondition) {
|
|
|
+ qw.or().apply("1=0");
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (userService.count(queryWrapper) >= 2) {
|
|
|
+ throw new BaseException("注册异常,请勿重复申请注册账号!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private Tuple2<Boolean, Long> userGuideCheck(User user) {
|
|
|
//非导量用户
|
|
|
if (user.getRelationUserId() == null) {
|
|
@@ -297,7 +352,7 @@ public class LoginServiceImpl implements IRegisterLoginService {
|
|
|
//获取游戏信息
|
|
|
Game game = gameService.getById(userData.getGameId());
|
|
|
//渠道id, 链接参数, 分享人id
|
|
|
- Tuple3<Long, Map<String, String>, String> tuple3 = agentService.getUserAgentId(game, userData);
|
|
|
+ Tuple3<Long, Map<String, String>, String> tuple3 = agentService.getUserAgentId(game, userData, openId);
|
|
|
//分享人id
|
|
|
Long shareUserId = Strings.isBlank(tuple3.getT3()) ? null : Long.valueOf(tuple3.getT3());
|
|
|
//用户参数补充
|