时间:整理时间方法

This commit is contained in:
luying
2021-05-08 19:09:51 +08:00
parent 6f03a96c51
commit 78e3c26a7a
51 changed files with 662 additions and 411 deletions

View File

@@ -3,11 +3,11 @@ import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
import { STATUS, TASK_TYPE } from '../../../consts';
import { GuildTrainModel } from '../../../db/GuildTrain';
import { BattleRecordModel } from '../../../db/BattleRecord';
import { nowSeconds, getHourPoint, getCurHourPoint } from '../../../pubUtils/timeUtil';
import { nowSeconds, getTimeFun, getZeroPoint } from '../../../pubUtils/timeUtil';
import { getUserGuild, getGuildTrainInfo, unlockTrain, getGuildTrainRewards } from '../../../services/guildTrainService';
import { findIndex, findWhere } from 'underscore'
import { lockData } from '../../../services/redLockService';
import { REFRESH_HOUR, GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
import { GUILD_REPORT_NUM, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
import { UserGuildModel } from '../../../db/UserGuild';
import { GuildModel } from '../../../db/Guild';
import { getArmyTrainJuDian, getTrainSoloReward, getTrainBaseByLv } from '../../../pubUtils/data';
@@ -171,10 +171,11 @@ export class GuildTrainHandler {
return resResult(STATUS.WRONG_PARMS);
}
if (time < getCurHourPoint(REFRESH_HOUR) && nowSeconds() > getCurHourPoint(REFRESH_HOUR)) {
let todayRef = <number>getTimeFun().getTimeWithHour(); // 今天的5点
if (time < todayRef && nowSeconds() > todayRef) {
return resResult(STATUS.GUILD_TRAIN_IS_RESETED);//重置前进入战斗,重置后回调该接口
}
if (time > getHourPoint(REFRESH_HOUR)) {
if (time > getZeroPoint()) { // 刷新时间如果是4点算前一天的5点
userGuild = await UserGuildModel.updateInfo(roleId, {}, { trainCount: -1 });//扣除一次挑战次数
}
await BattleRecordModel.updateBattleRecordByCode(battleCode, {