添加天梯排行榜,修复setHour有时差的bug

This commit is contained in:
luying
2020-11-06 17:31:23 +08:00
parent bd93d9dc1c
commit 04ecef03b5
29 changed files with 285 additions and 148 deletions
+4 -5
View File
@@ -2,7 +2,7 @@ import { Application, FrontendOrBackendSession } from 'pinus';
import { getGamedata } from '../pubUtils/gamedata';
import EventRecord, { EventRecordModel } from '../db/EventRecord';
import { RoleModel } from '../db/Role';
import { genCode, decodeStrSingle, decodeStr, getRandomWithWeight, resResult } from '../pubUtils/util';
import { genCode, decodeStrSingle, decodeStr, getRandomWithWeight, resResult, setLocalHours } from '../pubUtils/util';
import { EVENT_STATUS, EVENT_RECORD_STATUS, EVENT_TYPE, EVENT_RANDOM_TYPE_ONE_OPEN, EVENT_QUIZ_NUM, EVENT_ANSWER_STATUS } from '../consts/consts';
import { EVENT_REFRESH_NUM } from '../consts/consts';
import { STATUS } from '../consts/statusCode';
@@ -62,8 +62,8 @@ export async function setBattleStatus(app: Application, session: FrontendOrBacke
*/
export function getEventTime(now: Date) {
let curTime = Number(now);
let todayA = now.setHours(12, 0, 0, 0) - 8*60*60*1000; // 每天12点,修复时差
let todayB = now.setHours(18, 0, 0, 0) - 8*60*60*1000; // 每天18点,修复时差
let todayA = setLocalHours(12, now); // 每天12点
let todayB = setLocalHours(18, now); // 每天18点
let yesterdayB = todayB - 86400000; // 前一天12点
let t = 0;
if(curTime < todayA) {
@@ -196,7 +196,7 @@ export async function refreshEvent(num: number, roleId: string, roleName: string
let role = await RoleModel.findByRoleId(roleId);
dicEvent = dicEvent.filter(cur => { // 筛选适合等级
let { suitLevel } = cur;
suitLevel = decodeStrSingle('eventSuitLevel', suitLevel);
suitLevel = decodeStrSingle('suitLevel', suitLevel);
return suitLevel.min <= role.lv && suitLevel.max >= role.lv
});
if(EVENT_RANDOM_TYPE_ONE_OPEN) {
@@ -292,7 +292,6 @@ function randomPosition(positionStr: string, prePoint: Array<number>, curPoint:
* @param msg
*/
function pushEventMsg(app: Application, roleId: string, channelName: string, msg: any ) {
console.log('***pushEventMsg', channelName)
let channelService = app.get('channelService');
let param = { msg };