Ver código fonte

fix : 多表增加字段, 解决线上bug问题

bilingfeng 1 ano atrás
pai
commit
3cf85d5294

+ 5 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/GameRemitLog.java

@@ -34,6 +34,11 @@ public class GameRemitLog implements Serializable {
      */
     private Long userId;
 
+    /**
+     * 渠道id
+     */
+    private Long agentId;
+
     /**
      * 游戏id
      */

+ 5 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/IpBan.java

@@ -32,6 +32,11 @@ public class IpBan implements Serializable {
      */
     private String ip;
 
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
     /**
      * 封禁时间
      */

+ 10 - 0
game-module/game-module-mybatis/src/main/java/com/zanxiang/game/module/mybatis/entity/UserCard.java

@@ -35,6 +35,11 @@ public class UserCard implements Serializable {
      */
     private Long userId;
 
+    /**
+     * 渠道id
+     */
+    private Long agentId;
+
     /**
      * 用户名
      */
@@ -45,6 +50,11 @@ public class UserCard implements Serializable {
      */
     private String nickname;
 
+    /**
+     * 游戏id
+     */
+    private Long gameId;
+
     /**
      * 注册时间
      */

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/SDKApplication.java

@@ -23,7 +23,7 @@ public class SDKApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(SDKApplication.class, args);
-        System.out.println("赞象SDK服务启动成功 <解决短信验证码问题> ( ´・・)ノ(._.`) \n" +
+        System.out.println("赞象SDK服务启动成功 <多表增加字段, 解决线上bug问题> ( ´・・)ノ(._.`) \n" +
                 " ___________ _   __\n" +
                 "/  ___|  _  \\ | / /\n" +
                 "\\ `--.| | | | |/ / \n" +

+ 3 - 2
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/IIpBanService.java

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.sdk.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zanxiang.game.module.mybatis.entity.IpBan;
+import com.zanxiang.game.module.sdk.pojo.param.UserData;
 
 /**
  * @author : lingfeng
@@ -13,8 +14,8 @@ public interface IIpBanService extends IService<IpBan> {
     /**
      * 检查ip禁令
      *
-     * @param ip 知识产权
+     * @param userData 用户数据
      * @return boolean
      */
-    boolean checkIpBan(String ip);
+    boolean checkIpBan(UserData userData);
 }

+ 10 - 5
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/GameRemitLogServiceImpl.java

@@ -5,10 +5,12 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.game.module.base.pojo.enums.PayWayEnum;
 import com.zanxiang.game.module.mybatis.entity.GameExt;
 import com.zanxiang.game.module.mybatis.entity.GameRemitLog;
+import com.zanxiang.game.module.mybatis.entity.User;
 import com.zanxiang.game.module.mybatis.mapper.GameRemitLogMapper;
 import com.zanxiang.game.module.sdk.pojo.param.GameRemitLogParam;
 import com.zanxiang.game.module.sdk.service.IGameExtService;
 import com.zanxiang.game.module.sdk.service.IGameRemitLogService;
+import com.zanxiang.game.module.sdk.service.IUserService;
 import com.zanxiang.game.module.sdk.util.SignUtil;
 import com.zanxiang.module.util.DateUtil;
 import com.zanxiang.module.util.exception.BaseException;
@@ -31,6 +33,9 @@ public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, Gam
     @Autowired
     private IGameExtService gameExtService;
 
+    @Autowired
+    private IUserService userService;
+
     @Override
     public boolean addOrUpdate(GameRemitLogParam param) {
         GameExt gameExt = gameExtService.getByGameAppId(param.getAppId());
@@ -40,9 +45,6 @@ public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, Gam
         sb.append("&userId=").append(param.getUserId());
         sb.append("&merchantOrderNo=").append(param.getMerchantOrderNo());
         sb.append("&createdTime=").append(param.getCreatedTime());
-
-        log.error("加密签名字符串, str : {}", sb.toString());
-
         String mySign;
         try {
             mySign = SignUtil.MD5(sb.toString());
@@ -55,12 +57,14 @@ public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, Gam
             log.error("游戏提现签名验证失败, mySign : {}, sign : {}", mySign, param.getSign());
             throw new BaseException("签名验证失败");
         }
+        User user = userService.getById(param.getUserId());
         GameRemitLog gameRemitLog = super.getOne(new LambdaQueryWrapper<GameRemitLog>()
                 .eq(GameRemitLog::getMerchantOrderNo, param.getMerchantOrderNo()));
         if (gameRemitLog == null) {
-            gameRemitLog = this.transform(param, gameExt.getGameId());
+            gameRemitLog = this.transform(param, user, gameExt.getGameId());
         } else {
             gameRemitLog.setUserId(param.getUserId());
+            gameRemitLog.setAgentId(user == null ? null : user.getAgentId());
             gameRemitLog.setGameId(gameExt.getGameId());
             gameRemitLog.setAmount(param.getAmount());
             gameRemitLog.setPayPlatform(PayWayEnum.getKeyByPayWayId(param.getPayPlatform()));
@@ -71,9 +75,10 @@ public class GameRemitLogServiceImpl extends ServiceImpl<GameRemitLogMapper, Gam
         return super.saveOrUpdate(gameRemitLog);
     }
 
-    private GameRemitLog transform(GameRemitLogParam param, Long gameId) {
+    private GameRemitLog transform(GameRemitLogParam param, User user, Long gameId) {
         return GameRemitLog.builder()
                 .userId(param.getUserId())
+                .agentId(user == null ? null : user.getAgentId())
                 .gameId(gameId)
                 .merchantOrderNo(param.getMerchantOrderNo())
                 .amount(param.getAmount())

+ 4 - 2
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/IpBanServiceImpl.java

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.game.module.base.pojo.enums.BanStatusEnum;
 import com.zanxiang.game.module.mybatis.entity.IpBan;
 import com.zanxiang.game.module.mybatis.mapper.IpBanMapper;
+import com.zanxiang.game.module.sdk.pojo.param.UserData;
 import com.zanxiang.game.module.sdk.service.IIpBanService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -21,9 +22,10 @@ import java.util.Objects;
 public class IpBanServiceImpl extends ServiceImpl<IpBanMapper, IpBan> implements IIpBanService {
 
     @Override
-    public boolean checkIpBan(String ip) {
+    public boolean checkIpBan(UserData userData) {
         IpBan ipBan = super.getOne(new LambdaUpdateWrapper<IpBan>()
-                .eq(IpBan::getIp, ip)
+                .eq(IpBan::getIp, userData.getIp())
+                .eq(IpBan::getGameId, userData.getGameId())
         );
         return ipBan != null && Objects.equals(ipBan.getStatus(), BanStatusEnum.BAN_STATUS.getStatus());
     }

+ 3 - 3
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/LoginServiceImpl.java

@@ -99,7 +99,7 @@ public class LoginServiceImpl implements IRegisterLoginService {
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<UserLoginVO> loginWxCode(LoginVxCodeParam param, UserData userData) {
         //验证登录ip是否封禁
-        if (ipBanService.checkIpBan(userData.getIp())) {
+        if (ipBanService.checkIpBan(userData)) {
             return ResultVO.fail(HttpStatusEnum.IP_HALT.getMsg());
         }
         //查询微信小游戏信息
@@ -148,7 +148,7 @@ public class LoginServiceImpl implements IRegisterLoginService {
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<UserLoginVO> loginPassword(LoginPasswordParam param, UserData userData) {
         //验证登录ip是否封禁
-        if (ipBanService.checkIpBan(userData.getIp())) {
+        if (ipBanService.checkIpBan(userData)) {
             return ResultVO.fail(HttpStatusEnum.IP_HALT.getMsg());
         }
         String username = param.getUsername();
@@ -208,7 +208,7 @@ public class LoginServiceImpl implements IRegisterLoginService {
     @Transactional(rollbackFor = Exception.class)
     public ResultVO<UserLoginVO> loginMobile(LoginMobileParam param, UserData userData) {
         //验证ip是否封禁
-        if (ipBanService.checkIpBan(userData.getIp())) {
+        if (ipBanService.checkIpBan(userData)) {
             return ResultVO.fail(HttpStatusEnum.IP_HALT.getMsg());
         }
         String mobile = param.getMobile();

+ 2 - 0
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserCardServiceImpl.java

@@ -101,8 +101,10 @@ public class UserCardServiceImpl extends ServiceImpl<UserCardMapper, UserCard> i
         //新建记录
         this.save(UserCard.builder()
                 .userId(userData.getUserId())
+                .agentId(user.getAgentId())
                 .username(user.getUsername())
                 .nickname(user.getNickname())
+                .gameId(user.getGameId())
                 .regTime(user.getCreateTime())
                 .cardId(cardId)
                 .cardName(cardName)

+ 1 - 1
game-module/game-module-sdk/src/main/java/com/zanxiang/game/module/sdk/service/impl/UserTokenServiceImpl.java

@@ -121,7 +121,7 @@ public class UserTokenServiceImpl extends ServiceImpl<UserTokenMapper, UserToken
             return Boolean.FALSE;
         }
         //判断是否ip封禁
-        if (ipBanService.checkIpBan(userData.getIp())) {
+        if (ipBanService.checkIpBan(userData)) {
             return Boolean.FALSE;
         }
         //查询用户信息