kk 4 тижнів тому
батько
коміт
f0fae9c906

+ 23 - 11
game-business/src/main/java/com/game/business/task/AppGameBettingTask.java

@@ -159,10 +159,6 @@ public class AppGameBettingTask {
             return;
         }
 
-        if(type != 2 && type != 3){
-            return;
-        }
-
         JSONArray gameArry = null;
         String classCode = null;
         for (int i = 0; i < dataArry.size(); i++) {
@@ -222,19 +218,15 @@ public class AppGameBettingTask {
                 continue;
             }
 
-            if(type == 3){
+            // 修改倍数
+            if(type == 4){
 
-                String redisKey = CacheConstants.GAME_LOTTERY_TASK_CREATE.concat(appGame.getId() + ":" + gameCode);
+                String redisKey = CacheConstants.GAME_LOTTERY_ITEM_MULTIPLE.concat(appGame.getId() + ":" + gameCode);
                 if(!redisCache.redisTemplate.opsForValue().setIfAbsent(redisKey, 1)){
                     continue;
                 }
-
                 try {
 
-                    appGame.setGameDate(gameDate);
-                    appGameService.updateAppGame(appGame);
-
-                    // 修改倍数
                     if(gameCode.equals(Common.GAME_ONE_CODE)){
 
                         String gameLotteryBet = gameLotteryObject.getString("gameLotteryBet");
@@ -275,6 +267,26 @@ public class AppGameBettingTask {
                             appGameItemService.updateAppGameItem(gameItem);
                         }
                     }
+                }catch (Exception e){
+                    e.printStackTrace();
+                }finally {
+                    redisCache.redisTemplate.delete(redisKey);
+                }
+
+                continue;
+            }
+
+            if(type == 3){
+
+                String redisKey = CacheConstants.GAME_LOTTERY_TASK_CREATE.concat(appGame.getId() + ":" + gameCode);
+                if(!redisCache.redisTemplate.opsForValue().setIfAbsent(redisKey, 1)){
+                    continue;
+                }
+
+                try {
+
+                    appGame.setGameDate(gameDate);
+                    appGameService.updateAppGame(appGame);
 
                     AppGameLottery appGameLottery = new AppGameLottery();
                     appGameLottery.setGameId(appGame.getId());

+ 5 - 0
game-common/src/main/java/com/game/common/constant/CacheConstants.java

@@ -67,4 +67,9 @@ public class CacheConstants
      */
     public static final String GAME_LOTTERY_TASK_CREATE = "game_lottery_task_create:";
 
+    /**
+     * 倍数记录锁
+     */
+    public static final String GAME_LOTTERY_ITEM_MULTIPLE = "game_lottery_item_multiple:";
+
 }