|  | @@ -5,6 +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.HttpStatusEnum;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.mybatis.entity.*;
 | 
	
		
			
				|  |  | +import com.zanxiang.game.module.sdk.constant.RedisKeyConstant;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.enums.LoginTypeEnum;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.enums.SmsTypeEnum;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.pojo.dto.GameAppletDTO;
 | 
	
	
		
			
				|  | @@ -17,7 +18,9 @@ import com.zanxiang.game.module.sdk.service.*;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.service.api.WxApiService;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.util.RegexUtil;
 | 
	
		
			
				|  |  |  import com.zanxiang.game.module.sdk.util.RegisterUtil;
 | 
	
		
			
				|  |  | +import com.zanxiang.module.redis.service.IDistributedLockComponent;
 | 
	
		
			
				|  |  |  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.logging.log4j.util.Strings;
 | 
	
	
		
			
				|  | @@ -31,6 +34,7 @@ import reactor.util.function.Tuples;
 | 
	
		
			
				|  |  |  import java.time.LocalDateTime;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  |  import java.util.Objects;
 | 
	
		
			
				|  |  | +import java.util.concurrent.TimeUnit;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * @author : lingfeng
 | 
	
	
		
			
				|  | @@ -95,6 +99,9 @@ public class LoginServiceImpl implements IRegisterLoginService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private IGameUserRoleService gameUserRoleService;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private IDistributedLockComponent distributedLockComponent;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |      public ResultVO<UserLoginVO> loginWxCode(LoginVxCodeParam param, UserData userData) {
 | 
	
	
		
			
				|  | @@ -109,10 +116,6 @@ public class LoginServiceImpl implements IRegisterLoginService {
 | 
	
		
			
				|  |  |                  gameAppletDTO.getAppSecret(), gameAppletDTO.getType());
 | 
	
		
			
				|  |  |          String openId = resultMap.get("openid");
 | 
	
		
			
				|  |  |          String sessionKey = resultMap.get("session_key");
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -        log.error("登录用户, param : {}, userData : {}, resultMap : {}", JsonUtil.toString(param),
 | 
	
		
			
				|  |  | -                JsonUtil.toString(userData), JsonUtil.toString(resultMap));
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          //根据openId查询用户
 | 
	
		
			
				|  |  |          User user = userService.getOne(new LambdaQueryWrapper<User>()
 | 
	
		
			
				|  |  |                  .eq(User::getGameId, userData.getGameId()).eq(User::getOpenId, openId));
 | 
	
	
		
			
				|  | @@ -269,6 +272,12 @@ public class LoginServiceImpl implements IRegisterLoginService {
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      private User userCreateSave(UserData userData, String userName, String password, String mobile, String openId, String sessionKey) {
 | 
	
		
			
				|  |  | +        //锁Key
 | 
	
		
			
				|  |  | +        String lockKey = RedisKeyConstant.USER_CREATE + "_" + userData.getGameId() + "_" + userName;
 | 
	
		
			
				|  |  | +        //上锁
 | 
	
		
			
				|  |  | +        if (!distributedLockComponent.doLock(lockKey, 3L, 10L, TimeUnit.SECONDS)) {
 | 
	
		
			
				|  |  | +            throw new BaseException("用户信息正在注册中, 请稍后重试");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          //渠道id, 链接参数, 分享人id
 | 
	
		
			
				|  |  |          Tuple3<Long, Map<String, String>, String> tuple3 = agentService.getUserAgentId(userData);
 | 
	
		
			
				|  |  |          //分享人id
 | 
	
	
		
			
				|  | @@ -297,6 +306,8 @@ public class LoginServiceImpl implements IRegisterLoginService {
 | 
	
		
			
				|  |  |                  .createTime(LocalDateTime.now())
 | 
	
		
			
				|  |  |                  .updateTime(LocalDateTime.now())
 | 
	
		
			
				|  |  |                  .build());
 | 
	
		
			
				|  |  | +        //释放锁
 | 
	
		
			
				|  |  | +        distributedLockComponent.unlock(lockKey);
 | 
	
		
			
				|  |  |          return user;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 |