diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java index 6d462221..ced1e18b 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/LotteryActivityDetailQryExe.java @@ -16,7 +16,7 @@ import com.red.circle.other.infra.database.rds.service.activity.LotteryUserCount import com.red.circle.other.inner.asserts.lottery.LotteryErrorCode; import java.time.LocalDate; import java.time.LocalDateTime; -import java.util.List; +import java.util.*; import java.util.stream.Collectors; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Component; @@ -52,6 +52,22 @@ public class LotteryActivityDetailQryExe { .orderByAsc(LotteryPrize::getSortOrder) .list(); + // 去重:按照 prize_name 去重,优先保留 EARLY 池的奖品(用户首次看到的) + Map uniquePrizes = new LinkedHashMap<>(); + for (LotteryPrize prize : prizes) { + String prizeName = prize.getPrizeName(); + if (!uniquePrizes.containsKey(prizeName)) { + // 如果这个奖品名称还没有,就添加 + uniquePrizes.put(prizeName, prize); + } else { + // 如果已存在,优先保留 EARLY 池的 + LotteryPrize existingPrize = uniquePrizes.get(prizeName); + if ("EARLY".equals(prize.getPrizePool()) && !"EARLY".equals(existingPrize.getPrizePool())) { + uniquePrizes.put(prizeName, prize); + } + } + } + // 查询用户抽奖券数量 int ticketCount = 0; if (activity.getNeedTicket() == 1) { @@ -81,7 +97,7 @@ public class LotteryActivityDetailQryExe { // 组装返回数据 LotteryActivityDetailCO detail = new LotteryActivityDetailCO(); detail.setActivity(convertActivityToCO(activity, usedCount)); - detail.setPrizeList(prizes.stream() + detail.setPrizeList(uniquePrizes.values().stream() .map(this::convertPrizeToCO) .collect(Collectors.toList())); detail.setUserTicketCount(ticketCount);