فهرست منبع

Merge branch 'package' of GameCenter/game-center into dev

zhimo 5 ماه پیش
والد
کامیت
81e78b4a94

+ 1 - 1
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/ManageApplication.java

@@ -23,7 +23,7 @@ public class ManageApplication {
 
     public static void main(String[] args) {
         SpringApplication.run(ManageApplication.class, args);
-        System.out.println("赞象Manage服务启动成功 < (发码器隐藏前端手机号・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (发码器隐藏前端手机号100・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 14 - 14
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/GameGiftPackCodeLogServiceImpl.java

@@ -20,7 +20,6 @@ import com.zanxiang.game.module.mybatis.mapper.GameGiftPackCodeLogMapper;
 import com.zanxiang.module.redis.service.IDistributedLockComponent;
 import com.zanxiang.module.util.JsonUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
-import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.logging.log4j.util.Strings;
@@ -110,22 +109,23 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
 
     @Override
     public Map<String, Object> getGiftPackCode(Long linkLogId, String userPhone, String randomCode) {
+        //链接访问日志判断
+        GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkLogId);
+        Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
+        //判断日志参数验证是通过的
+        String userId = gameGiftPackLinkLog.getUserId() == null ? null : gameGiftPackLinkLog.getUserId().toString();
+        Assert.state(StringUtils.isNoneBlank(userId, gameGiftPackLinkLog.getServerId(), gameGiftPackLinkLog.getRoleId(),
+                gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
+        //判断手机号是否属于隐藏手机号
+        String phoneNum = userPhone.contains("****") ? gameGiftPackLinkLog.getUserPhone() : userPhone;
         //线程锁key
-        String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + userPhone;
-        //线程锁 5 分钟, 防止同一用户重复请求
-        if (!distributedLockComponent.doLock(lockKey, 0L, 5L, TimeUnit.MINUTES)) {
-            throw new BaseException("操作频繁, 请稍后重试");
-        }
+        String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + phoneNum;
+        //线程锁 3 分钟, 防止同一用户重复请求
+        Assert.state(distributedLockComponent.doLock(lockKey, 0L, 3L, TimeUnit.MINUTES), "操作频繁, 请稍后重试");
+        //执行礼包码获取
         try {
-            GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkLogId);
-            Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
-            //判断验证是通过的
-            Long userId = gameGiftPackLinkLog.getUserId();
-            Assert.state(StringUtils.isNoneBlank(userId == null ? null : userId.toString(), gameGiftPackLinkLog.getServerId(),
-                    gameGiftPackLinkLog.getRoleId(), gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
-            //返回礼包码
             Map<String, Object> resuktMap = new HashMap<>(2);
-            Tuple2<Boolean, String> tuple2 = this.getRandomCode(randomCode, userPhone, gameGiftPackLinkLog);
+            Tuple2<Boolean, String> tuple2 = this.getRandomCode(randomCode, phoneNum, gameGiftPackLinkLog);
             resuktMap.put("result", tuple2.first);
             resuktMap.put("msg", tuple2.second);
             return resuktMap;