From 6ca7fd6046f32d745c6320012a5046006490b9f1 Mon Sep 17 00:00:00 2001 From: tianfeng <769204422@qq.com> Date: Sun, 4 Jan 2026 20:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E7=8E=8B=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=91=A8=E4=B8=800=E7=82=B9=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E9=80=BB=E8=BE=91=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity/RankingRewardGrantCmdExe.java | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java index eb3c769a..a459f1d1 100644 --- a/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java +++ b/rc-service/rc-service-other/other-application/src/main/java/com/red/circle/other/app/command/activity/RankingRewardGrantCmdExe.java @@ -18,11 +18,14 @@ import com.red.circle.other.inner.model.cmd.material.GivePropsBackpackCmd; import com.red.circle.other.inner.model.dto.activity.props.ActivityRewardPropsDTO; import com.red.circle.other.inner.model.dto.sys.ActivityConfigDTO; import com.red.circle.tool.core.collection.CollectionUtils; +import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; +import java.time.DayOfWeek; import java.time.LocalDateTime; +import java.time.ZoneId; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; @@ -74,10 +77,18 @@ public class RankingRewardGrantCmdExe { Map lastUserMap, ActivityConfigVO activityConfig) { + // 检查是否为星期一0点(活动重置时间) + if (isWeeklyReset()) { + log.info("星期一0点,活动重置,收回所有用户道具"); + revokeAllUserRewards(lastUserMap); + + lastUserMap.clear(); // 清空历史,使所有用户视为新用户重新发放 + } + Set currentUserIds = currentRankMap.values().stream() .map(RankingUserData::getUserId) .collect(Collectors.toSet()); - + for (RankingRewardSnapshot.RankingUserSnapshot lastUser : lastUserMap.values()) { if (!currentUserIds.contains(lastUser.getUserId())) { log.info("用户失去排名,收回奖励, userId: {}, rank: {}", lastUser.getUserId(), lastUser.getRank()); @@ -102,6 +113,29 @@ public class RankingRewardGrantCmdExe { } } + /** + * 判断是否为星期一0点(活动重置时间). + */ + private boolean isWeeklyReset() { + LocalDateTime now = ZonedDateTimeAsiaRiyadhUtils.now().toLocalDateTime(); + return now.getDayOfWeek() == DayOfWeek.MONDAY && now.getHour() == 0 && now.getMinute() == 0; + } + + /** + * 收回所有用户的奖励(星期一重置). + */ + private void revokeAllUserRewards(Map lastUserMap) { + if (lastUserMap == null || lastUserMap.isEmpty()) { + log.info("没有需要收回的用户奖励"); + return; + } + + for (RankingRewardSnapshot.RankingUserSnapshot user : lastUserMap.values()) { + log.info("活动重置,收回用户奖励, userId: {}, rank: {}", user.getUserId(), user.getRank()); + revokeRewards(user.getUserId(), user.getRewards()); + } + } + /** * 处理奖励差异 */