添加天梯排行榜,修复setHour有时差的bug
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
import { DAILY_CONST } from './../consts/consts';
|
||||
import { setLocalHours } from './../pubUtils/util';
|
||||
|
||||
|
||||
/**
|
||||
* 战斗记录接口
|
||||
@@ -27,11 +30,11 @@ export default class DailyRecord extends BaseModel {
|
||||
const dailyRecord = await DailyRecordModel.findOne({ roleId, type }).lean(lean);
|
||||
let {count = 0, refTime = 0, buyCount = 0} = dailyRecord||{};
|
||||
let now = new Date();
|
||||
let today = now.setHours(0, 0, 0, 0);
|
||||
let today = setLocalHours(DAILY_CONST.REFRESH_TIME, now);
|
||||
|
||||
console.log('******dailyTime*******', today, now, new Date(), refTime);
|
||||
if(today > refTime) {
|
||||
refTime = today;
|
||||
count = 0;
|
||||
buyCount = 0;
|
||||
refTime = today; count = 0; buyCount = 0;
|
||||
}
|
||||
let result = await DailyRecordModel.findOneAndUpdate({roleId, type}, {$set: {refTime, count, buyCount}}, {new: true, upsert: true});
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user