cp榜边界值修复

This commit is contained in:
tianfeng 2026-03-30 10:45:27 +08:00
parent 79e476dfd1
commit afe830f313

View File

@ -46,11 +46,10 @@ public class CpRankingBadgeTask {
@TaskCacheLock(key = "CP_RANKING_BADGE_TASK", expireSecond = 20) @TaskCacheLock(key = "CP_RANKING_BADGE_TASK", expireSecond = 20)
public void sendWeekRankingReward() { public void sendWeekRankingReward() {
try { try {
// 1. 获取本周前三名CP对 // 1. 获取本周前三名CP对为空时不return继续执行收回逻辑
List<WeekCpValueCount> thisWeekTop3 = weekCpValueCountService.listThisWeekTop(SysOriginPlatformEnum.ATYOU.name(), 3); List<WeekCpValueCount> thisWeekTop3 = weekCpValueCountService.listThisWeekTop(SysOriginPlatformEnum.ATYOU.name(), 3);
if (CollectionUtils.isEmpty(thisWeekTop3)) { if (CollectionUtils.isEmpty(thisWeekTop3)) {
log.warn("CP排名徽章任务本周前三名数据为空"); log.warn("CP排名徽章任务本周前三名数据为空将收回所有旧徽章");
return;
} }
// 2. 查询所有持有CP排名徽章的用户 // 2. 查询所有持有CP排名徽章的用户
@ -63,9 +62,10 @@ public class CpRankingBadgeTask {
// 3. 构建"用户应得徽章集合"Map<userId, Set<badgeId>> // 3. 构建"用户应得徽章集合"Map<userId, Set<badgeId>>
// 一个用户可能在多对CP中所以可以有多个徽章 // 一个用户可能在多对CP中所以可以有多个徽章
// 本周无数据时为空Map后续收回逻辑会清空所有旧徽章
Map<Long, Set<Long>> userShouldHaveBadgesMap = new HashMap<>(); Map<Long, Set<Long>> userShouldHaveBadgesMap = new HashMap<>();
for (int rank = 0; rank < thisWeekTop3.size() && rank < 3; rank++) { for (int rank = 0; !CollectionUtils.isEmpty(thisWeekTop3) && rank < thisWeekTop3.size() && rank < 3; rank++) {
WeekCpValueCount rankingData = thisWeekTop3.get(rank); WeekCpValueCount rankingData = thisWeekTop3.get(rank);
Long badgeId = CP_BADGE_IDS[rank]; Long badgeId = CP_BADGE_IDS[rank];