From 6420fb8d1db93c3a387d952347012eac3500f213 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Mon, 20 Oct 2025 20:27:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=BD=E5=A5=96=20=E6=A6=82=E7=8E=87?= =?UTF-8?q?=E6=8A=BD=E5=A5=96=E9=80=BB=E8=BE=91=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/command/activity/LotteryDrawExe.java | 47 ++++++++++++------- 1 file changed, 31 insertions(+), 16 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 0511e351..ea2c8cf8 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 @@ -23,7 +23,6 @@ import com.red.circle.tool.core.date.TimestampUtils; import java.math.BigDecimal; import java.sql.Timestamp; import java.time.LocalDate; -import java.time.format.DateTimeFormatter; import java.time.temporal.WeekFields; import java.util.ArrayList; import java.util.List; @@ -210,7 +209,7 @@ public class LotteryDrawExe { } /** - * 判断奖品池阶段. + * 判断奖品池阶段(新方案:前期给大奖,中期消耗,后期凑整). */ private String determinePrizePool(LotteryUserProgress progress, LotteryActivity activity) { int drawCount = progress.getTotalDrawCount(); @@ -220,25 +219,25 @@ public class LotteryDrawExe { : new BigDecimal("10"); // 默认阶段配置 - int earlyMax = activity.getEarlyStageMaxCount() != null ? activity.getEarlyStageMaxCount() : 20; + int earlyMax = activity.getEarlyStageMaxCount() != null ? activity.getEarlyStageMaxCount() : 15; int middleMax = activity.getMiddleStageMaxCount() != null ? activity.getMiddleStageMaxCount() : 50; BigDecimal lateTrigger = activity.getLateStageTriggerAmount() != null ? activity.getLateStageTriggerAmount() - : new BigDecimal("2"); + : new BigDecimal("6"); - // 后期池:抽奖次数多 且 接近门槛 + // 前期池:1-15次 + if (drawCount < earlyMax) { + return "EARLY"; + } + + // 后期池:次数>=50 或 距离门槛<=6美元 BigDecimal gap = threshold.subtract(totalAmount); - if (drawCount >= middleMax && gap.compareTo(lateTrigger) <= 0) { + if (drawCount >= middleMax || gap.compareTo(lateTrigger) <= 0) { return "LATE"; } - // 中期池:抽奖次数中等 - if (drawCount >= earlyMax) { - return "MIDDLE"; - } - - // 前期池 - return "EARLY"; + // 中期池:16-49次 + return "MIDDLE"; } /** @@ -258,7 +257,7 @@ public class LotteryDrawExe { } /** - * 过滤会超过门槛的奖品. + * 过滤会超过门槛的奖品(新增:前期拿大奖后的慢速模式). */ private List filterOverThresholdPrizes(List prizes, LotteryUserProgress progress, @@ -268,14 +267,30 @@ public class LotteryDrawExe { } BigDecimal currentAmount = progress.getTotalAmount(); + int drawCount = progress.getTotalDrawCount(); - // 如果已经达到门槛,本周不再发放任何奖品 + // 如果已经达到门槛,只允许发虚拟物品 if (currentAmount.compareTo(threshold) >= 0) { log.info("User reached threshold, no more prizes this week. userId: {}, amount: {}", progress.getUserId(), currentAmount); - return new ArrayList<>(); + // 只允许发虚拟物品 + return prizes.stream() + .filter(prize -> prize.getPrizeValue().compareTo(BigDecimal.ZERO) == 0) + .collect(Collectors.toList()); } + // 特殊情况:前期(<50次)已经拿到>=5美元,进入"慢速模式" + if (currentAmount.compareTo(new BigDecimal("5.0")) >= 0 && drawCount < 50) { + log.info("User got big prize early, entering slow mode. userId: {}, amount: {}, count: {}", + progress.getUserId(), currentAmount, drawCount); + + // 只允许0.1美元和虚拟物品(prize_value<=0.15) + return prizes.stream() + .filter(prize -> prize.getPrizeValue().compareTo(new BigDecimal("0.15")) <= 0) + .collect(Collectors.toList()); + } + + // 正常防超额过滤 return prizes.stream() .filter(prize -> { // 过滤掉会让用户超过门槛的大奖