From dc47209d4a919d0f37ae9e1f078d06e4ca61ad90 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Wed, 11 Feb 2026 14:34:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=E6=96=B0=E5=A2=9E500?= =?UTF-8?q?=E5=88=80=E8=BF=87=E6=BB=A4=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 | 57 +++++++++---------- .../command/activity/LotteryMultiDrawExe.java | 44 +++++++------- 2 files changed, 49 insertions(+), 52 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 ad9dbd04..00833e4d 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 @@ -291,7 +291,7 @@ public class LotteryDrawExe { prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId(), activityId); // 4. 过滤美元奖励(充值金额为0的用户不能抽到) - prizes = filterMoneyPrizes(prizes, userRechargeAmount); + prizes = filterMoneyPrizes(activityId, prizes, userRechargeAmount); // 5. 过滤会超过提现门槛的大奖 prizes = filterOverThresholdPrizes(prizes, progress, activity.getWithdrawThreshold()); @@ -332,7 +332,7 @@ public class LotteryDrawExe { prizes = filterAlreadyWonBadgePrizes(prizes, userId, activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) - prizes = filterMoneyPrizes(prizes, userRechargeAmount); + prizes = filterMoneyPrizes(activityId, prizes, userRechargeAmount); if (prizes.isEmpty()) { return null; @@ -658,7 +658,7 @@ public class LotteryDrawExe { /** * 过滤用户已中过的BADGE类型奖品. - * + * * @param prizes 奖品列表 * @param userId 用户ID * @return 过滤后的奖品列表 @@ -674,55 +674,52 @@ public class LotteryDrawExe { if (!"BADGE".equals(prize.getPrizeType())) { return true; } - + // 检查用户是否已经中过这个BADGE String redisKey = "lottery:badge:won:" + userId + ":" + activityId; String won = redisService.getString(redisKey); - + if (won != null) { - log.info("User already won this BADGE prize, filtering it out. userId: {}, prizeId: {}, prizeName: {}", + log.info("User already won this BADGE prize, filtering it out. userId: {}, prizeId: {}, prizeName: {}", userId, prize.getId(), prize.getPrizeName()); return false; } - + return true; }) .collect(Collectors.toList()); } /** - * 过滤美元奖励(充值金额为0的用户不能抽到). - * - * @param prizes 奖品列表 - * @param userRechargeAmount 用户充值金额 - * @return 过滤后的奖品列表 + * 过滤美元奖励(根据充值金额过滤不同档位的奖品) */ - private List filterMoneyPrizes(List prizes, BigDecimal userRechargeAmount) { + private List filterMoneyPrizes(Long activityId, List prizes, BigDecimal userRechargeAmount) { if (prizes == null || prizes.isEmpty()) { return prizes; } - // 如果用户充值金额>0,不需要过滤 - if (userRechargeAmount.compareTo(BigDecimal.ZERO) > 0) { + // 从Redis获取活动充值门槛,默认500 + String thresholdKey = "lottery:recharge:threshold:" + activityId; + String thresholdStr = redisService.getString(thresholdKey); + BigDecimal rechargeThreshold = thresholdStr != null ? new BigDecimal(thresholdStr) : new BigDecimal("500"); + + // 如果用户充值金额 >= 门槛,不需要过滤 + if (userRechargeAmount.compareTo(rechargeThreshold) >= 0) { return prizes; } - // 充值金额为0,过滤掉MONEY类型奖品 - List filtered = prizes.stream() - .filter(prize -> { - if ("MONEY".equals(prize.getPrizeType())) { - log.info("User has no recharge, filtering MONEY prize. userId: {}, prizeId: {}, prizeName: {}", - userRechargeAmount, prize.getId(), prize.getPrizeName()); - return false; - } - return true; - }) - .collect(Collectors.toList()); + // 如果用户充值金额 <= 0,过滤掉所有MONEY类型奖品 + if (userRechargeAmount.compareTo(BigDecimal.ZERO) <= 0) { + return prizes.stream() + .filter(prize -> !"MONEY".equals(prize.getPrizeType())) + .collect(Collectors.toList()); + } - log.info("Filter MONEY prizes completed. userRechargeAmount: {}, beforeCount: {}, afterCount: {}", - userRechargeAmount, prizes.size(), filtered.size()); - - return filtered; + // 如果用户充值金额 > 0 且 < 门槛,过滤掉 prizeValue >= 10 的MONEY奖品 + return prizes.stream() + .filter(prize -> !"MONEY".equals(prize.getPrizeType()) || + prize.getPrizeValue().compareTo(new BigDecimal("10")) < 0) + .collect(Collectors.toList()); } /** 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 81765e6c..9838d3c9 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 @@ -305,7 +305,7 @@ public class LotteryMultiDrawExe { prizes = filterAlreadyWonBadgePrizes(prizes, progress.getUserId(), activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) - prizes = filterMoneyPrizes(prizes, userRechargeAmount); + prizes = filterMoneyPrizes(activityId, prizes, userRechargeAmount); prizes = filterOverThresholdPrizes(prizes, progress, activity.getWithdrawThreshold()); if (prizes.isEmpty()) { @@ -422,7 +422,7 @@ public class LotteryMultiDrawExe { prizes = filterAlreadyWonBadgePrizes(prizes, userId, activityId); // 过滤美元奖励(充值金额为0的用户不能抽到) - prizes = filterMoneyPrizes(prizes, userRechargeAmount); + prizes = filterMoneyPrizes(activityId, prizes, userRechargeAmount); if (prizes.isEmpty()) { return null; @@ -678,41 +678,41 @@ public class LotteryMultiDrawExe { } /** - * 过滤美元奖励(充值金额为0的用户不能抽到) + * 过滤美元奖励(根据充值金额过滤不同档位的奖品) */ - private List filterMoneyPrizes(List prizes, BigDecimal userRechargeAmount) { + private List filterMoneyPrizes(Long activityId, List prizes, BigDecimal userRechargeAmount) { if (prizes == null || prizes.isEmpty()) { return prizes; } - // 如果用户充值金额>0,不需要过滤 - if (userRechargeAmount.compareTo(BigDecimal.ZERO) > 0) { + // 从Redis获取活动充值门槛,默认500 + String thresholdKey = "lottery:recharge:threshold:" + activityId; + String thresholdStr = redisService.getString(thresholdKey); + BigDecimal rechargeThreshold = thresholdStr != null ? new BigDecimal(thresholdStr) : new BigDecimal("500"); + + // 如果用户充值金额 >= 门槛,不需要过滤 + if (userRechargeAmount.compareTo(rechargeThreshold) >= 0) { return prizes; } - // 充值金额为0,过滤掉MONEY类型奖品 - List filtered = prizes.stream() - .filter(prize -> { - if ("MONEY".equals(prize.getPrizeType())) { - log.info("User has no recharge in multi-draw, filtering MONEY prize. userRechargeAmount: {}, prizeId: {}, prizeName: {}", - userRechargeAmount, prize.getId(), prize.getPrizeName()); - return false; - } - return true; - }) - .collect(Collectors.toList()); + // 如果用户充值金额 <= 0,过滤掉所有MONEY类型奖品 + if (userRechargeAmount.compareTo(BigDecimal.ZERO) <= 0) { + return prizes.stream() + .filter(prize -> !"MONEY".equals(prize.getPrizeType())) + .collect(Collectors.toList()); + } - log.info("Filter MONEY prizes completed in multi-draw. userRechargeAmount: {}, beforeCount: {}, afterCount: {}", - userRechargeAmount, prizes.size(), filtered.size()); - - return filtered; + // 如果用户充值金额 > 0 且 < 门槛,过滤掉 prizeValue >= 10 的MONEY奖品 + return prizes.stream() + .filter(prize -> !"MONEY".equals(prize.getPrizeType()) || + prize.getPrizeValue().compareTo(new BigDecimal("10")) < 0) + .collect(Collectors.toList()); } /** * 标记用户已中BADGE类型奖品(永久记录). * * @param userId 用户ID - * @param prizeId 奖品ID */ private void markBadgePrizeAsWon(Long userId, Long activityId) { String redisKey = "lottery:badge:won:" + userId + ":" + activityId;