Explorar o código

fix : 发码器代码完成提交2400

bilingfeng hai 5 meses
pai
achega
67f96e1471

+ 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服务启动成功 < (发码器代码完成提交2200・・)ノ(._.`) \n" +
+        System.out.println("赞象Manage服务启动成功 < (发码器代码完成提交2400・・)ノ(._.`) \n" +
                 "___  ___  ___   _   _   ___  _____  _____ \n" +
                 "|  \\/  | / _ \\ | \\ | | / _ \\|  __ \\|  ___|\n" +
                 "| .  . |/ /_\\ \\|  \\| |/ /_\\ \\ |  \\/| |__  \n" +

+ 3 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/controller/api/GameGiftPackApi.java

@@ -69,8 +69,8 @@ public class GameGiftPackApi {
     @ApiOperation(value = "领取礼包码")
     @GetMapping(value = "/code/send")
     @ApiResponses(value = {@ApiResponse(code = 200, message = "成功", response = Tuple2.class)})
-    public ResultVO<Tuple2<Boolean, String>> codeSend(@RequestParam Long linkId, @RequestParam String userPhone,
-                                                      @RequestParam String randomCode) {
-        return ResultVO.ok(gameGiftPackCodeLogService.getGiftPackCode(linkId, userPhone, randomCode));
+    public ResultVO<Map<String, Object>> codeSend(@RequestParam Long linkLogId, @RequestParam String userPhone,
+                                                  @RequestParam String randomCode) {
+        return ResultVO.ok(gameGiftPackCodeLogService.getGiftPackCode(linkLogId, userPhone, randomCode));
     }
 }

+ 4 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IGameGiftPackCodeLogService.java

@@ -2,11 +2,12 @@ package com.zanxiang.game.module.manage.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.github.sd4324530.jtuple.Tuple2;
 import com.zanxiang.game.module.manage.pojo.params.GameGiftPackCodeLogListParam;
 import com.zanxiang.game.module.manage.pojo.vo.GameGiftPackCodeLogVO;
 import com.zanxiang.game.module.mybatis.entity.GameGiftPackCodeLog;
 
+import java.util.Map;
+
 /**
  * @author : lingfeng
  * @time : 2022-09-23
@@ -25,10 +26,10 @@ public interface IGameGiftPackCodeLogService extends IService<GameGiftPackCodeLo
     /**
      * 领取礼包码
      *
-     * @param linkId     : 访问记录id
+     * @param linkLogId  : 访问记录id
      * @param userPhone  : 用户手机号
      * @param randomCode : 验证码
      * @return : 返回礼包码或者错误信息
      */
-    Tuple2<Boolean, String> getGiftPackCode(Long linkId, String userPhone, String randomCode);
+    Map<String, Object> getGiftPackCode(Long linkLogId, String userPhone, String randomCode);
 }

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

@@ -32,6 +32,7 @@ import org.springframework.util.Assert;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
@@ -108,23 +109,28 @@ public class GameGiftPackCodeLogServiceImpl extends ServiceImpl<GameGiftPackCode
     }
 
     @Override
-    public Tuple2<Boolean, String> getGiftPackCode(Long linkId, String userPhone, String randomCode) {
+    public Map<String, Object> getGiftPackCode(Long linkLogId, String userPhone, String randomCode) {
         //线程锁key
         String lockKey = RedisKeyConstant.GAME_GIFT_PACK_LOCK + userPhone;
         //线程锁 5 分钟, 防止同一用户重复请求
         if (!distributedLockComponent.doLock(lockKey, 0L, 5L, TimeUnit.MINUTES)) {
             throw new BaseException("操作频繁, 请稍后重试");
         }
-        GameGiftPackLinkLog gameGiftPackLinkLog = gameGiftPackLinkLogService.getById(linkId);
-        Assert.notNull(gameGiftPackLinkLog, "参数错误, 链接访问日志信息不存在");
-        //判断验证是通过的
-        Long userId = gameGiftPackLinkLog.getUserId();
-        Assert.state(StringUtils.isNoneBlank(userId == null ? null : userId.toString(), gameGiftPackLinkLog.getServerId(),
-                gameGiftPackLinkLog.getRoleId(), gameGiftPackLinkLog.getRoleName()), "参数错误, 链接访问记录信息缺失");
-        //获取礼包码, 且执行释放锁动作
         try {
-            return this.getRandomCode(randomCode, userPhone, gameGiftPackLinkLog);
+            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);
+            resuktMap.put("result", tuple2.first);
+            resuktMap.put("msg", tuple2.second);
+            return resuktMap;
         } finally {
+            //执行释放锁动作
             distributedLockComponent.unlock(lockKey);
         }
     }