|
@@ -2,6 +2,7 @@ package com.zanxiang.game.module.sdk.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.game.module.base.pojo.enums.BanStatusEnum;
|
|
|
import com.zanxiang.game.module.base.util.DateUtils;
|
|
@@ -34,9 +35,12 @@ import reactor.util.function.Tuple2;
|
|
|
import reactor.util.function.Tuples;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
import java.util.Objects;
|
|
|
+import java.util.Set;
|
|
|
import java.util.UUID;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @author : lingfeng
|
|
@@ -76,7 +80,7 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
|
|
|
//用户信息
|
|
|
User user = userService.getById(userId);
|
|
|
//获取检测token
|
|
|
- UserToken userToken = this.getCheckUserToken(userId, token, user.getRelationUserId());
|
|
|
+ UserToken userToken = this.getCheckUserToken(userId, token);
|
|
|
//判断token是否存在, 并且没有过期
|
|
|
if (userToken == null || userToken.getExpireTime() < DateUtils.localDateTimeToSecond(LocalDateTime.now())) {
|
|
|
log.error("token验证失败 , token不存在或者已经失效, appId : {}, userId : {}, token : {}", appId, userId, token);
|
|
@@ -104,10 +108,8 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
|
|
|
log.error("token验证失败 , 游戏拓展信息不存在, appId : {}, userId : {}", appId, userId);
|
|
|
return ResultVO.fail(TokenCheckEnum.PARAM_LACK.getMsg());
|
|
|
}
|
|
|
- //用户信息
|
|
|
- User user = userService.getById(userId);
|
|
|
//获取检测token
|
|
|
- UserToken userToken = this.getCheckUserToken(userId, token, user.getRelationUserId());
|
|
|
+ UserToken userToken = this.getCheckUserToken(userId, token);
|
|
|
//判断token是否存在, 并且没有过期
|
|
|
if (userToken == null || userToken.getExpireTime() < DateUtils.localDateTimeToSecond(LocalDateTime.now())) {
|
|
|
log.error("token验证失败 , token不存在或者已经失效, appId : {}, userId : {}, token : {}", appId, userId, token);
|
|
@@ -140,21 +142,26 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
|
|
|
return Tuples.of(sb.toString(), mySign);
|
|
|
}
|
|
|
|
|
|
- private UserToken getCheckUserToken(Long userId, String token, Long relationUserId) {
|
|
|
- //查询token是否存在
|
|
|
+ private UserToken getCheckUserToken(Long userId, String token) {
|
|
|
+ //非导量用户
|
|
|
UserToken userToken = super.getOne(new LambdaQueryWrapper<UserToken>()
|
|
|
.eq(UserToken::getToken, token)
|
|
|
- .eq(relationUserId == null, UserToken::getUserId, userId));
|
|
|
- //非导量玩家
|
|
|
- if (Objects.equals(userToken.getUserId(), userId)) {
|
|
|
+ .eq(UserToken::getUserId, userId));
|
|
|
+ if (userToken != null) {
|
|
|
return userToken;
|
|
|
}
|
|
|
- //导量玩家
|
|
|
- User relationUser = userService.getById(userToken.getUserId());
|
|
|
- if (Objects.equals(relationUser.getRelationUserId(), userId)) {
|
|
|
- return userToken;
|
|
|
+ //导量处理
|
|
|
+ List<User> relationUserList = userService.list(new LambdaQueryWrapper<User>()
|
|
|
+ .eq(User::getRelationUserId, userId));
|
|
|
+ //不存在导量用户
|
|
|
+ if (CollectionUtils.isEmpty(relationUserList)) {
|
|
|
+ return null;
|
|
|
}
|
|
|
- return null;
|
|
|
+ Set<Long> relationUserIdSet = relationUserList.stream().map(User::getId)
|
|
|
+ .collect(Collectors.toSet());
|
|
|
+ return super.getOne(new LambdaQueryWrapper<UserToken>()
|
|
|
+ .eq(UserToken::getToken, token)
|
|
|
+ .in(UserToken::getUserId, relationUserIdSet));
|
|
|
}
|
|
|
|
|
|
@Override
|