| 
					
				 | 
			
			
				@@ -24,7 +24,9 @@ import org.apache.logging.log4j.util.Strings; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import reactor.util.function.Tuple2; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import reactor.util.function.Tuple3; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import reactor.util.function.Tuples; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.time.LocalDateTime; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.Map; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -90,6 +92,9 @@ public class LoginServiceImpl implements IRegisterLoginService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private IGameService gameService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private IGameUserRoleService gameUserRoleService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public ResultVO<UserLoginVO> loginWxCode(LoginVxCodeParam param, UserData userData) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -178,11 +183,18 @@ public class LoginServiceImpl implements IRegisterLoginService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //渠道更新和回传判断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             agentService.userAgentUpdate(user, userData.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //登录信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            UserLoginVO userLoginVO = this.createUserLoginVO(user, userData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Tuple2<Boolean, Long> tuple2 = this.userGuideCheck(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //导量用户返回原有的用户id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (tuple2.getT1()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                userLoginVO.setUserId(tuple2.getT2()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //返回登录信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return ResultVO.ok(this.createUserLoginVO(user, userData)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ResultVO.ok(userLoginVO); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //用户注册, 用户名密码校验 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        HttpStatusEnum checkRegisterEnum = this.checkRegister(username, password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        HttpStatusEnum checkRegisterEnum = this.checkRegister(userData.getGameId(), username, password); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (!Objects.equals(checkRegisterEnum, HttpStatusEnum.SUCCESS)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return ResultVO.fail(checkRegisterEnum.getMsg()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -218,14 +230,11 @@ public class LoginServiceImpl implements IRegisterLoginService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //渠道更新和回传判断 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             agentService.userAgentUpdate(user, userData.getChannel()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             UserLoginVO userLoginVO = this.createUserLoginVO(user, userData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Game game = gameService.getById(user.getGameId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //判断是否导量用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (user.getRelationUserId() != null && game.getGuideGameId() != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                User relationUser = userService.getById(user.getRelationUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (relationUser != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    //导量用户返回原有的用户id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    userLoginVO.setUserId(relationUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Tuple2<Boolean, Long> tuple2 = this.userGuideCheck(user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //导量用户返回原有的用户id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (tuple2.getT1()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                userLoginVO.setUserId(tuple2.getT2()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //返回登录信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return ResultVO.ok(userLoginVO); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -236,6 +245,28 @@ public class LoginServiceImpl implements IRegisterLoginService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return ResultVO.ok(this.createUserLoginVO(user, userData)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private Tuple2<Boolean, Long> userGuideCheck(User user) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //游戏信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Game game = gameService.getById(user.getGameId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //非导量用户 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (user.getRelationUserId() == null || game.getGuideGameId() == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return Tuples.of(Boolean.FALSE, 0L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //导量用户信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        User relationUser = userService.getById(user.getRelationUserId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //确定导量匹配 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (relationUser != null && Objects.equals(relationUser.getRelationUserId(), user.getId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            try { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                //监测角色是否导全, 或者导过之后又跑去小程序创建了其他角色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                gameUserRoleService.userGuideGameRoleCheck(user, relationUser); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } catch (Exception ignored) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return Tuples.of(Boolean.TRUE, relationUser.getId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //非导量兜底逻辑 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return Tuples.of(Boolean.FALSE, 0L); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private User userCreateSave(UserData userData, String userName, String password, String mobile, String openId, String sessionKey) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //渠道id, 链接参数, 分享人id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Tuple3<Long, Map<String, String>, String> tuple3 = agentService.getUserAgentId(userData); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -333,13 +364,16 @@ public class LoginServiceImpl implements IRegisterLoginService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return Boolean.TRUE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private HttpStatusEnum checkRegister(String username, String password) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private HttpStatusEnum checkRegister(Long gameId, String username, String password) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //判断用户名是否存在敏感词 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (wordCheckService.hasWord(username)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return HttpStatusEnum.USERNAME_SENSITIVE; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //判断用户名是否已存在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (userService.count(new LambdaQueryWrapper<User>().eq(User::getUsername, username)) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (userService.count(new LambdaQueryWrapper<User>() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(User::getGameId, gameId) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .eq(User::getUsername, username) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ) > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return HttpStatusEnum.USERNAME_EXISTS; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         //用户名合规检测 
			 |