活动:修复限时排行榜
This commit is contained in:
@@ -43,23 +43,22 @@ export default class Activity extends BaseModel {
|
||||
|
||||
// 获取正在开启和即将到来的活动列表
|
||||
public static async findOpenAndComingActivityes() {
|
||||
let now = new Date();
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ endTime: { $gte: now } }).lean();
|
||||
let result: ActivityModelType[] = await ActivityModel.find({ isEnable: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动类型查询开启的活动数据
|
||||
public static async findOpenActivityByType(activityGroupId: number[], type: number, date: Date) {
|
||||
public static async findOpenActivityByType(activityGroupId: number[], type: number) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find(
|
||||
{ groupId: { $in: activityGroupId }, type, beginTime: { $lte: date }, endTime: { $gte: date } }
|
||||
{ groupId: { $in: activityGroupId }, type, isEnable: true }
|
||||
).sort({ activityId: -1 }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
//根据活动类型查询开启的活动数据
|
||||
public static async findOpenActivityByTypes(activityGroupId: number[], types: number[], date: Date) {
|
||||
public static async findOpenActivityByTypes(activityGroupId: number[], types: number[]) {
|
||||
let result: ActivityModelType[] = await ActivityModel.find(
|
||||
{ groupId: { $in: activityGroupId }, type: { $in: types }, beginTime: { $lte: date }, endTime: { $gte: date } }
|
||||
{ groupId: { $in: activityGroupId }, type: { $in: types }, isEnable: true }
|
||||
).sort({ activityId: -1 }).lean(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ export abstract class ActivityBase {
|
||||
this.endTime = moment(activityData.endTime).add(this.delayDay, 'd').valueOf();
|
||||
this.todayIndex = deltaDays(moment(this.beginTime).toDate(), new Date) + 1;
|
||||
this.roundIndex = 1;
|
||||
this.nextRefreshTime = this.endTime;
|
||||
this.name = activityData.name;
|
||||
this.isEnable = activityData.isEnable;
|
||||
this.interval = activityData.interval * 86400;
|
||||
@@ -102,6 +101,8 @@ export abstract class ActivityBase {
|
||||
this.roundIndex = Math.ceil((moment(new Date).valueOf() - this.beginTime) / (activityData.interval * 86400000));
|
||||
this.nextRefreshTime = moment(this.beginTime).add(activityData.interval * (this.roundIndex - 1), 'day').add(activityData.effectDay, 'd').valueOf();
|
||||
this.todayIndex = Math.ceil(((moment(new Date).valueOf() - this.beginTime) / (24 * 60 * 60 * 1000)));
|
||||
} else {
|
||||
this.nextRefreshTime = this.endTime;
|
||||
}
|
||||
if(activityData.hideDayByServer > 0) {
|
||||
let hidOverTime = moment(serverTime * 1000).add(activityData.hideDayByServer, 'd').startOf('d').add(REFRESH_TIME, 'h').valueOf();
|
||||
|
||||
@@ -49,8 +49,8 @@ export class TimeLimitRankData extends ActivityBase {
|
||||
public getRewardByRank(rank: number) {
|
||||
let result: TimeLimitRankReward;
|
||||
for(let reward of this.rankRewards) {
|
||||
if(reward.rank > rank) break;
|
||||
result = reward;
|
||||
if(reward.rank >= rank) break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -68,8 +68,8 @@ export class TimeLimitRankData extends ActivityBase {
|
||||
let dataObj: TimeLimitInDb = JSON.parse(data);
|
||||
this.rankType = dataObj.rankType;
|
||||
this.hid = dataObj.hid;
|
||||
this.rankEndTime = new Date(moment(this.beginTime).add(dataObj.rankEndDay, 'd').format(`YYYY-MM-DD ${dataObj.rankEndTime}`)).getTime() ;
|
||||
this.sendMailTime = this.rankEndTime + this.sendMailTime * 1000;
|
||||
this.rankEndTime = new Date(moment(this.beginTime).add(dataObj.rankEndDay - 1, 'd').format(`YYYY-MM-DD ${dataObj.rankEndTime}`)).getTime() ;
|
||||
this.sendMailTime = this.rankEndTime + dataObj.sendMailTime * 1000;
|
||||
for(let rank of dataObj.rankRewards) {
|
||||
this.rankRewards.push(new TimeLimitRankReward(rank));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user