pvp:定时任务修改

This commit is contained in:
luying
2021-11-09 11:39:34 +08:00
parent 87bcf57b05
commit fc653b37e6

View File

@@ -100,7 +100,7 @@ async function setPvpSeason(isForce?: boolean, minute?: number) {
let oldPvpConfig = await PVPConfigModel.findCurPVPConfig();
let pvpConfig = oldPvpConfig;
console.log(`******** setPvpSeason2 during-${during}, seasonEndTime-${pvpConfig?.seasonEndTime}, now-${nowSeconds()}`)
if(!pvpConfig || pvpConfig.seasonEndTime <= nowSeconds() || isForce) {
if(!pvpConfig || pvpConfig.seasonEndTime - PER_MINUTE <= nowSeconds() || isForce) {
if(pvpConfig && !pvpConfig.hasSettleReward) {
await pvpSeasonEnd(pvpConfig.seasonNum);
}
@@ -109,7 +109,7 @@ async function setPvpSeason(isForce?: boolean, minute?: number) {
let lastSeasonEndTime = pvpConfig? pvpConfig.seasonEndTime: 0;
console.log(`******** setPvpSeason3 lastSeasonNum-${lastSeasonNum}, lastSeasonEndTime-${lastSeasonEndTime}`)
let newSeasonStartTime = lastSeasonEndTime + PER_MINUTE;
let newSeasonStartTime = lastSeasonEndTime;
if(!during) during = getSeasonContinueDay(lastSeasonNum + 1) * PER_DAY;
let rewardTime = PVP.PVP_SEASON_REWARD_TIME_BEFORE * PER_MINUTE;
if(nowSeconds() - newSeasonStartTime > during) {
@@ -128,7 +128,7 @@ async function setPvpSeason(isForce?: boolean, minute?: number) {
}
console.log(`******** setPvpSeason5 isForce-${isForce}, newSeasonStartTime-${newSeasonStartTime}`)
let newSeasonNum = await CounterModel.getNewCounter(COUNTER.PVP_SEASON_NUM);
pvpConfig = await PVPConfigModel.createPVPConfig(newSeasonNum, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during - PER_MINUTE);
pvpConfig = await PVPConfigModel.createPVPConfig(newSeasonNum, newSeasonStartTime, newSeasonStartTime + during - rewardTime, newSeasonStartTime + during);
}
await setPvpSeasonMakeRewardJob(pvpConfig);
await setNextSeasonJob(pvpConfig);
@@ -166,7 +166,7 @@ async function setNextSeasonJob(pvpConfig: PVPConfigType) {
seasonRefreshTimeJobId.cancel();
}
//定时开启新赛季比seasonEndTime多定一分钟保证定时器时间没错
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', (pvpConfig.seasonEndTime + PER_MINUTE) * 1000, setPvpSeasonJob);
seasonRefreshTimeJobId = scheduleJob('seasonRefreshTimeJobId', (pvpConfig.seasonEndTime) * 1000, setPvpSeasonJob);
}
/**