From 8bb6f3941ea6ee61665aa4a9868acf021453c1c2 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 19 Jan 2026 23:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E8=8D=A3=E8=AA=89id=E5=94=AF?= =?UTF-8?q?=E4=B8=80=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/activity/LotteryDrawExe.java | 19 +++++++++---------- .../command/activity/LotteryMultiDrawExe.java | 19 +++++++++---------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java index acf5faa8..ad9dbd04 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryDrawExe.java @@ -288,7 +288,7 @@ public class LotteryDrawExe { List prizes = getPrizesByPool(activityId, stage); // 3. 过滤用户已中过的BADGE类型奖品 - prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId()); + prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId(), activityId); // 4. 过滤美元奖励(充值金额为0的用户不能抽到) prizes = filterMoneyPrizes(prizes, userRechargeAmount); @@ -308,9 +308,9 @@ public class LotteryDrawExe { // 8. 如果抽中了BADGE类型奖品,记录到Redis if (selectedPrize != null && "BADGE".equals(selectedPrize.getPrizeType())) { - markBadgePrizeAsWon(progress.getUserId(), selectedPrize.getId()); + markBadgePrizeAsWon(progress.getUserId(), activityId); } - + return selectedPrize; } @@ -329,7 +329,7 @@ public class LotteryDrawExe { } // 过滤用户已中过的BADGE类型奖品 - prizes = filterAlreadyWonBadgePrizes(prizes, userId); + prizes = filterAlreadyWonBadgePrizes(prizes, userId, activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) prizes = filterMoneyPrizes(prizes, userRechargeAmount); @@ -342,7 +342,7 @@ public class LotteryDrawExe { // 如果抽中了BADGE类型奖品,记录到Redis if (selectedPrize != null && "BADGE".equals(selectedPrize.getPrizeType())) { - markBadgePrizeAsWon(userId, selectedPrize.getId()); + markBadgePrizeAsWon(userId, activityId); } return selectedPrize; @@ -663,7 +663,7 @@ public class LotteryDrawExe { * @param userId 用户ID * @return 过滤后的奖品列表 */ - private List filterAlreadyWonBadgePrizes(List prizes, Long userId) { + private List filterAlreadyWonBadgePrizes(List prizes, Long userId, Long activityId) { if (prizes == null || prizes.isEmpty()) { return prizes; } @@ -676,7 +676,7 @@ public class LotteryDrawExe { } // 检查用户是否已经中过这个BADGE - String redisKey = "lottery:badge:won:" + userId + ":" + prize.getId(); + String redisKey = "lottery:badge:won:" + userId + ":" + activityId; String won = redisService.getString(redisKey); if (won != null) { @@ -731,11 +731,10 @@ public class LotteryDrawExe { * @param userId 用户ID * @param prizeId 奖品ID */ - private void markBadgePrizeAsWon(Long userId, Long prizeId) { - String redisKey = "lottery:badge:won:" + userId + ":" + prizeId; + private void markBadgePrizeAsWon(Long userId, Long activityId) { + String redisKey = "lottery:badge:won:" + userId + ":" + activityId; // 永久存储,表示该用户已经中过这个BADGE redisService.setString(redisKey, "1"); - log.info("Mark BADGE prize as won. userId: {}, prizeId: {}", userId, prizeId); } /** diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryMultiDrawExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryMultiDrawExe.java index 400afe82..81765e6c 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryMultiDrawExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryMultiDrawExe.java @@ -302,7 +302,7 @@ public class LotteryMultiDrawExe { List prizes = getPrizesByPool(activityId, stage); // 过滤用户已中过的BADGE类型奖品 - prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId()); + prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId(), activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) prizes = filterMoneyPrizes(prizes, userRechargeAmount); @@ -321,7 +321,7 @@ public class LotteryMultiDrawExe { // 如果抽中了BADGE类型奖品,记录到Redis if (selectedPrize != null && "BADGE".equals(selectedPrize.getPrizeType())) { - markBadgePrizeAsWon(progress.getUserId(), selectedPrize.getId()); + markBadgePrizeAsWon(progress.getUserId(), activityId); } return selectedPrize; @@ -419,7 +419,7 @@ public class LotteryMultiDrawExe { } // 过滤用户已中过的BADGE类型奖品 - prizes = filterAlreadyWonBadgePrizes(prizes, userId); + prizes = filterAlreadyWonBadgePrizes(prizes, userId, activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) prizes = filterMoneyPrizes(prizes, userRechargeAmount); @@ -439,7 +439,7 @@ public class LotteryMultiDrawExe { if (randomValue <= cumulative) { // 如果抽中了BADGE类型奖品,记录到Redis if ("BADGE".equals(prize.getPrizeType())) { - markBadgePrizeAsWon(userId, prize.getId()); + markBadgePrizeAsWon(userId, activityId); } return prize; } @@ -448,7 +448,7 @@ public class LotteryMultiDrawExe { LotteryPrize lastPrize = prizes.get(prizes.size() - 1); // 如果抽中了BADGE类型奖品,记录到Redis if (lastPrize != null && "BADGE".equals(lastPrize.getPrizeType())) { - markBadgePrizeAsWon(userId, lastPrize.getId()); + markBadgePrizeAsWon(userId, activityId); } return lastPrize; } @@ -650,7 +650,7 @@ public class LotteryMultiDrawExe { * @param userId 用户ID * @return 过滤后的奖品列表 */ - private List filterAlreadyWonBadgePrizes(List prizes, Long userId) { + private List filterAlreadyWonBadgePrizes(List prizes, Long userId, Long activityId) { if (prizes == null || prizes.isEmpty()) { return prizes; } @@ -663,7 +663,7 @@ public class LotteryMultiDrawExe { } // 检查用户是否已经中过这个BADGE - String redisKey = "lottery:badge:won:" + userId + ":" + prize.getId(); + String redisKey = "lottery:badge:won:" + userId + ":" + activityId; String won = redisService.getString(redisKey); if (won != null) { @@ -714,11 +714,10 @@ public class LotteryMultiDrawExe { * @param userId 用户ID * @param prizeId 奖品ID */ - private void markBadgePrizeAsWon(Long userId, Long prizeId) { - String redisKey = "lottery:badge:won:" + userId + ":" + prizeId; + private void markBadgePrizeAsWon(Long userId, Long activityId) { + String redisKey = "lottery:badge:won:" + userId + ":" + activityId; // 永久存储,表示该用户已经中过这个BADGE redisService.setString(redisKey, "1"); - log.info("Mark BADGE prize as won in multi-draw. userId: {}, prizeId: {}", userId, prizeId); } }