游戏王活动增加周一0点重置逻辑。
This commit is contained in:
parent
834f1c795d
commit
6ca7fd6046
@ -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.activity.props.ActivityRewardPropsDTO;
|
||||||
import com.red.circle.other.inner.model.dto.sys.ActivityConfigDTO;
|
import com.red.circle.other.inner.model.dto.sys.ActivityConfigDTO;
|
||||||
import com.red.circle.tool.core.collection.CollectionUtils;
|
import com.red.circle.tool.core.collection.CollectionUtils;
|
||||||
|
import com.red.circle.tool.core.date.ZonedDateTimeAsiaRiyadhUtils;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.DayOfWeek;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -74,6 +77,14 @@ public class RankingRewardGrantCmdExe {
|
|||||||
Map<Long, RankingRewardSnapshot.RankingUserSnapshot> lastUserMap,
|
Map<Long, RankingRewardSnapshot.RankingUserSnapshot> lastUserMap,
|
||||||
ActivityConfigVO activityConfig) {
|
ActivityConfigVO activityConfig) {
|
||||||
|
|
||||||
|
// 检查是否为星期一0点(活动重置时间)
|
||||||
|
if (isWeeklyReset()) {
|
||||||
|
log.info("星期一0点,活动重置,收回所有用户道具");
|
||||||
|
revokeAllUserRewards(lastUserMap);
|
||||||
|
|
||||||
|
lastUserMap.clear(); // 清空历史,使所有用户视为新用户重新发放
|
||||||
|
}
|
||||||
|
|
||||||
Set<Long> currentUserIds = currentRankMap.values().stream()
|
Set<Long> currentUserIds = currentRankMap.values().stream()
|
||||||
.map(RankingUserData::getUserId)
|
.map(RankingUserData::getUserId)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
@ -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<Long, RankingRewardSnapshot.RankingUserSnapshot> 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理奖励差异
|
* 处理奖励差异
|
||||||
*/
|
*/
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user