时间:整理时间方法
This commit is contained in:
@@ -22,7 +22,7 @@ import { addUserToChannel, getSimpleRoleInfo } from '../../../services/roleServi
|
||||
import { ChannelUser } from '../../../domain/ChannelUser';
|
||||
import { pushComBtlTeamMsg, pushFriendTeamInviteMsg, pushNormalItemMsg, pushTeamInviteMsg } from '../../../services/chatService';
|
||||
import { EXTERIOR } from '../../../pubUtils/dicParam';
|
||||
import { getTodayZeroDate } from '../../../pubUtils/timeUtil';
|
||||
import { getZeroPointD, getTimeFunD } from '../../../pubUtils/timeUtil';
|
||||
import { FriendParams } from '../../../domain/roleField/friend';
|
||||
import { checkTask, checkTaskWithGoods } from '../../../services/taskService';
|
||||
import { gameData, getWarByBlueprtId } from '../../../pubUtils/data';
|
||||
@@ -595,7 +595,8 @@ export class ComBattleHandler {
|
||||
*/
|
||||
async getTeamRec(msg: {}, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
let teams = await ComBattleTeamModel.getTeamByRoleAndTime(roleId, null, new Date(new Date().setHours(0, 0, 0, 0) - 2 * 24 * 60 * 60 * 1000));
|
||||
let timef = getTimeFunD();
|
||||
let teams = await ComBattleTeamModel.getTeamByRoleAndTime(roleId, null, <Date>timef.getBeforeDayWithHour(2));
|
||||
if (!teams) return resResult(STATUS.COM_BATTLE_NO_RECENT_REC);
|
||||
|
||||
return resResult(STATUS.SUCCESS, {teamInfos: teams});
|
||||
@@ -707,7 +708,7 @@ export class ComBattleHandler {
|
||||
async getRecentTeammates(msg: { }, session: BackendSession) {
|
||||
let roleId = session.get('roleId');
|
||||
|
||||
const teams = await ComBattleTeamModel.getTeamByRoleAndTime(roleId, null, getTodayZeroDate());
|
||||
const teams = await ComBattleTeamModel.getTeamByRoleAndTime(roleId, null, getZeroPointD());
|
||||
let roleIdList = new Array<string>();
|
||||
for(let { roleIds } of teams) {
|
||||
for(let r of roleIds) {
|
||||
|
||||
@@ -19,7 +19,7 @@ export class DungeonBattleHandler {
|
||||
let roleId = session.get('roleId');
|
||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime, dungeonHeroes=[] } = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
if(shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME)) {
|
||||
if(shouldRefresh(dungeonRefTime, curTime)) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export class DungeonBattleHandler {
|
||||
|
||||
let { dungeonCnt = 0, dungeonBuyCnt = 0, dungeonRefTime } = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
let needRefresh = shouldRefresh(dungeonRefTime, curTime, DUNGEON_CONST.REFRESH_TIME);
|
||||
let needRefresh = shouldRefresh(dungeonRefTime, curTime);
|
||||
if(needRefresh) {
|
||||
dungeonCnt = 0; dungeonBuyCnt = 0;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { Application, BackendSession } from 'pinus';
|
||||
import { resResult, genCode, getRandSingleEelm } from '../../../pubUtils/util';
|
||||
import { STATUS, TASK_TYPE, AUCTION_SOURCE } from '../../../consts';
|
||||
import { STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { BossInstanceModel } from '../../../db/BossInstance';
|
||||
import { BattleRecordModel } from '../../../db/BattleRecord';
|
||||
import { nowSeconds, getTodayZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { nowSeconds, getZeroPoint } from '../../../pubUtils/timeUtil';
|
||||
import { getBossInstanceInfo, bossResult, checkBossBattleMemberExists, pushBossHpMessage, getBossInstanceWhenEnd, addBossInstance } from '../../../services/guildBossService';
|
||||
import { findWhere } from 'underscore'
|
||||
import { GUILD_STRUCTURE, GUILD_BOSS_STATUS, GUILD_POINT_WAYS } from '../../../consts/constModules/guildConst';
|
||||
@@ -16,7 +16,6 @@ import { getBossByLv } from '../../../pubUtils/data';
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { pushGuildBossSucMsg } from '../../../services/chatService';
|
||||
import { checkTask } from '../../../services/taskService';
|
||||
import { genAuction } from '../../../services/auctionService';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GuildHandler(app);
|
||||
@@ -75,7 +74,7 @@ export class GuildHandler {
|
||||
if (!!res.err)
|
||||
return resResult(STATUS.REDLOCK_ERR);
|
||||
let bossInstance = await BossInstanceModel.findBossInstance(code);
|
||||
if (!!bossInstance && ( bossInstance.bossHp > 0 || bossInstance.startTime >= getTodayZeroPoint() )) {
|
||||
if (!!bossInstance && ( bossInstance.bossHp > 0 || bossInstance.startTime >= getZeroPoint() )) {
|
||||
res.releaseCallback();
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_OPENED_TODAY);
|
||||
}
|
||||
@@ -116,7 +115,7 @@ export class GuildHandler {
|
||||
if (bossInstance.bossHp <= 0)
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_COMPLETE);
|
||||
let myRank = findWhere(bossInstance.ranks, {roleId});
|
||||
if (!!myRank && myRank.time > getTodayZeroPoint())
|
||||
if (!!myRank && myRank.time > getZeroPoint())
|
||||
return resResult(STATUS.GUILD_SCRIPT_IS_BATTLED);
|
||||
let { warId, ranks } = bossInstance;
|
||||
const battleCode = genCode(8); // 关卡唯一值
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Application, BackendSession, pinus, ChannelService } from 'pinus';
|
||||
import { resResult, getRandEelm, getRefTime, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { Application, BackendSession, ChannelService } from 'pinus';
|
||||
import { resResult, getRandEelm, shouldRefresh, sortArrRandom } from '../../../pubUtils/util';
|
||||
import { STATUS, GUILD_OPERATE, GUILD_AUTH, GUILD_JOB, GUILD_APPLY_TYPE, GUILD_STRUCTURE, GUILD_REC_TYPE, GUILD_STRUCTURE_NAME, MAIL_TYPE, REDIS_KEY, GUILD_SELECT, USER_GUILD_SELECT, TASK_TYPE } from '../../../consts';
|
||||
import { UserGuildModel } from '../../../db/UserGuild';
|
||||
import { checkAuth, joinGuild, getGuildWithRefActive, getUserGuildWithRefActive, addActive, settleGuildWeekly } from '../../../services/guildService';
|
||||
@@ -8,9 +8,9 @@ import { RoleModel, RoleType } from '../../../db/Role';
|
||||
import { ARMY } from '../../../pubUtils/dicParam';
|
||||
import { handleCost, addItems } from '../../../services/rewardService';
|
||||
import { getGoldObject } from '../../../pubUtils/itemUtils';
|
||||
import { nowSeconds, getBeforeDaySeconds, getSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { nowSeconds, getTimeFun } from '../../../pubUtils/timeUtil';
|
||||
import { GuildListInfo } from '../../../domain/battleField/guild';
|
||||
import { GuildRankParam, GuildLeader } from '../../../domain/rank';
|
||||
import { GuildLeader } from '../../../domain/rank';
|
||||
import { UserGuildApplyModel } from '../../../db/UserGuildApply';
|
||||
import { hasStructureConsume, getStructureConsume, gameData } from '../../../pubUtils/data';
|
||||
import { GuildRecModel } from '../../../db/GuildRec';
|
||||
@@ -420,13 +420,13 @@ export class GuildHandler {
|
||||
|
||||
let guild = await GuildModel.findByCode(myGuild.guildCode, serverId, GUILD_SELECT.INVITED_MEMBER);
|
||||
let invitedMembers = guild.invitedMembers;
|
||||
if(shouldRefresh(guild.inviteTime, new Date(), 0)) {
|
||||
if(shouldRefresh(guild.inviteTime, new Date())) {
|
||||
invitedMembers = [];
|
||||
}
|
||||
|
||||
// 离线时间,三天内在线且尚未加入军团。按以下规则排序 离线时间 玩家等级 玩家战力
|
||||
|
||||
const day = getBeforeDaySeconds(3);
|
||||
const day = <number>getTimeFun().getBeforeDay(3);
|
||||
|
||||
const { quitGuildTime: quitTime = 0 } = await RoleModel.findByRoleId(roleId);
|
||||
let allList = await RoleModel.getInviteList(day, serverId);
|
||||
@@ -472,7 +472,7 @@ export class GuildHandler {
|
||||
}
|
||||
}
|
||||
}
|
||||
await GuildModel.recordInvitedMember(code, serverId, roleIds, shouldRefresh(guild.inviteTime, new Date(), 0));
|
||||
await GuildModel.recordInvitedMember(code, serverId, roleIds, shouldRefresh(guild.inviteTime, new Date()));
|
||||
this.channelService.pushMessageByUids('onGuildInvite', resResult(STATUS.SUCCESS, { code }), uids);
|
||||
|
||||
return resResult(STATUS.SUCCESS, { roleIds: result });
|
||||
@@ -717,7 +717,7 @@ export class GuildHandler {
|
||||
|
||||
// 离线72小时
|
||||
const { roleName: oldRoleName, quitTime } = await RoleModel.findByRoleId(leaderRoleId);
|
||||
if (quitTime > getBeforeDaySeconds(3)) {
|
||||
if (quitTime > <number>getTimeFun().getBeforeDay(3)) {
|
||||
return resResult(STATUS.GUILD_LEADER_LOGIN);
|
||||
}
|
||||
// 上周周功勋最高的人
|
||||
@@ -830,9 +830,8 @@ export class GuildHandler {
|
||||
const checkResult = await checkAuth(GUILD_OPERATE.GET_REC, roleId, code);
|
||||
if (!checkResult) return resResult(STATUS.GUILD_AUTH_NOT_ENOUGH);
|
||||
|
||||
let startTime = getRefTime(new Date(), 0, -3);
|
||||
// console.log(startTime)
|
||||
const list = await GuildRecModel.getGuildRec(code, getSeconds(startTime));
|
||||
const list = await GuildRecModel.getGuildRec(code, <number>getTimeFun().getBeforeDayWithHour(3));
|
||||
|
||||
return resResult(STATUS.SUCCESS, { list });
|
||||
}
|
||||
@@ -987,7 +986,7 @@ export class GuildHandler {
|
||||
const serverId = session.get('serverId');
|
||||
const guild = await GuildModel.findByCode(code, serverId);
|
||||
const leader = <RoleType>guild.leader;
|
||||
let threeDaysBefore = getBeforeDaySeconds(3);
|
||||
let threeDaysBefore = <number>getTimeFun().getBeforeDay(3);
|
||||
await RoleModel.updateRoleInfo(leader.roleId, { quitTime: threeDaysBefore } );
|
||||
|
||||
return resResult(STATUS.SUCCESS, { code });
|
||||
|
||||
@@ -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, {
|
||||
|
||||
@@ -86,7 +86,7 @@ export class TowerBattleHandler {
|
||||
let {timeReward, startTime, deltaTime} = result.data;
|
||||
let {hangUpSpdUpCnt, lastSpdUpTime} = await RoleModel.findByRoleId(roleId);
|
||||
let curTime = new Date();
|
||||
if (!lastSpdUpTime || (shouldRefresh(lastSpdUpTime, curTime, HANG_UP_CONSTS.REFRESH_TIME, 1) && hangUpSpdUpCnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT)) {
|
||||
if (!lastSpdUpTime || (shouldRefresh(lastSpdUpTime, curTime) && hangUpSpdUpCnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT)) {
|
||||
hangUpSpdUpCnt = HANG_UP_CONSTS.MAX_SPD_UP_CNT;
|
||||
}
|
||||
let num = HANG_UP_CONSTS.MAX_SPD_UP_CNT - hangUpSpdUpCnt + 1;
|
||||
@@ -167,7 +167,7 @@ export class TowerBattleHandler {
|
||||
let { towerLv, towerTaskRefTime, towerTaskReCnt = 0 } = await RoleModel.findByRoleId(roleId);
|
||||
let curTasks = await TowerTaskRecModel.getCurTasks(roleId); // 当前显示中的任务
|
||||
|
||||
const needRefresh = shouldRefresh(towerTaskRefTime, curTime, TOWER_TASK_CONST.REFRESH_TIME);
|
||||
const needRefresh = shouldRefresh(towerTaskRefTime, curTime);
|
||||
|
||||
if(needRefresh) {
|
||||
const batchCode = genCode(8);
|
||||
|
||||
Reference in New Issue
Block a user