开服冲榜活动,时间修正

back_recharge
duhui 2022-11-10 14:47:18 +08:00
parent 0f18feb57b
commit 3f4ad6acde
1 changed files with 6 additions and 18 deletions

View File

@ -50,7 +50,7 @@ public class OpenServerCompeteRankActivity extends AbstractActivity {
for (SChongRankInfo rankInfo : rankInfoMap.values()) {
int rankType = rankInfo.getRankType();
try {
long sendTime = getTime(rankType,2) - TimeUtils.now();
long sendTime = getSendTime(rankType);
ThreadManager.scheduleOne(() -> sendReward(rankType), sendTime, TimeUnit.MILLISECONDS);
LOGGER.info("===========================冲榜初始化:活动id:{}-排行榜类型:{}-{}毫秒后发送",id,rankType,sendTime);
}catch (Exception e){
@ -75,33 +75,21 @@ public class OpenServerCompeteRankActivity extends AbstractActivity {
}
/**
* 获取时间
* 获取发送时间
* @param rankType 排行榜类型
* @param timeType 1:开始时间,2:结束时间
* @return
*/
public long getTime(int rankType, int timeType){
public long getSendTime(int rankType){
SChongRankInfo info = SChongRankInfo.getMap().getOrDefault(id,new HashMap<>()).get(rankType);
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (info == null || activity == null){
return 0;
}
long activityTime = ToolsUtil.getTimeLong(activity.getStartTimeLong(),activity.getEndTimeLong(),activity.getTime(),0, timeType);
int rankTime = timeType==1 ? info.getOpenTime() : info.getCloseTime();
return activityTime + rankTime * 1000L;
long startTime = ToolsUtil.getTimeLong(activity.getStartTimeLong(),activity.getEndTimeLong(),activity.getTime(),0, 1);
long rankEndTime = startTime + info.getCloseTime()*1000L;
return rankEndTime-TimeUtils.now();
}
/**
* 排行榜是否开启
* @param rankType
* @return
*/
public boolean isOpen(int rankType){
long start = getTime(rankType, 1);
long end = getTime(rankType, 2);
long now = TimeUtils.now();
return now >= start && now < end;
}
/**
* 发奖
* @param rankType