✨ feat(活动): 月基金每月补发
This commit is contained in:
@@ -73,6 +73,7 @@ export enum MAIL_TYPE {
|
||||
LEAGUE_MAIL = 42, // 联军邮件
|
||||
VESTIGE_REWARD = 43, // 补发遗迹邮件
|
||||
GVG_BOX_REWARD = 44, // 云台补发
|
||||
MONTHLY_FUND = 45, // 补发月基金奖励
|
||||
};
|
||||
|
||||
export const SEND_NAME = '系统';
|
||||
|
||||
@@ -44,13 +44,16 @@ export default class Activity_Monthly_Fund extends BaseModel {
|
||||
@prop({ required: true, type: SignRecord, _id: false })
|
||||
record: SignRecord[]; // 铸造记录
|
||||
|
||||
@prop({ required: true })
|
||||
hasReceivedAll: boolean; // 铸造记录
|
||||
|
||||
public static async findData(serverId: number, activityId: number, roundIndex: number, roleId: string) {
|
||||
let result: ActivityMonthlyFundModelType[] = await ActivityMonthlyFundModel.find({ serverId, roleId, activityId, roundIndex }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async buy(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number, productID: string) {
|
||||
let result: ActivityMonthlyFundModelType = await ActivityMonthlyFundModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex }, { $setOnInsert: { record: [], productID } }, { new: true, upsert: true }).lean();
|
||||
let result: ActivityMonthlyFundModelType = await ActivityMonthlyFundModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex }, { $setOnInsert: { record: [], productID, hasReceivedAll: false } }, { new: true, upsert: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -58,6 +61,20 @@ export default class Activity_Monthly_Fund extends BaseModel {
|
||||
let result: ActivityMonthlyFundModelType = await ActivityMonthlyFundModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex, 'record.dayIndex': { $ne: dayIndex } }, { $push: { record: new SignRecord(dayIndex, todayIndex)} }, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async setReceivedAll(serverId: number, activityId: number, roleId: string, roundIndex: number, pageIndex: number) {
|
||||
let result: ActivityMonthlyFundModelType = await ActivityMonthlyFundModel.findOneAndUpdate({ serverId, roleId, activityId, roundIndex, pageIndex }, { $set: { hasReceivedAll: true }}, { new: true }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findNotReceivedReward(roundIndex: number) {
|
||||
let result: ActivityMonthlyFundModelType[] = await ActivityMonthlyFundModel.find({ roundIndex, hasReceivedAll: false }).lean();
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateHasReceivedAll(_ids: string[]) {
|
||||
await ActivityMonthlyFundModel.updateMany({ _id: { $in: _ids }}, { $set: { hasReceivedAll: true } });
|
||||
}
|
||||
}
|
||||
|
||||
export const ActivityMonthlyFundModel = getModelForClass(Activity_Monthly_Fund);
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
// 周基金
|
||||
import moment = require('moment');
|
||||
import { SHOP_REFRESH_TYPE } from '../../consts';
|
||||
import { ActivityModelType } from '../../db/Activity';
|
||||
import { ActivityMonthlyFundModelType } from '../../db/ActivityMonthlyFund';
|
||||
import { getZeroPointD } from '../../pubUtils/timeUtil';
|
||||
import { deltaDays } from '../../pubUtils/util';
|
||||
import { ActivityBase } from './activityField';
|
||||
|
||||
interface MonthlyFundRewardInDb {
|
||||
@@ -68,7 +72,7 @@ class MonthlyFundPage {
|
||||
this.hasBought = true;
|
||||
for(let { dayIndex } of playerData.record) {
|
||||
let reward = this.rewards.find(cur => cur.dayIndex == dayIndex);
|
||||
if(reward) reward.setHasReceived();
|
||||
if(reward || playerData.hasReceivedAll) reward.setHasReceived();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +80,7 @@ class MonthlyFundPage {
|
||||
return this.rewards.find(cur => cur.dayIndex == dayIndex);
|
||||
}
|
||||
|
||||
private hasReceivedAll() {
|
||||
public hasReceivedAll() {
|
||||
return !this.rewards.find(cur => !cur.hasReceived);
|
||||
}
|
||||
|
||||
@@ -103,6 +107,8 @@ export class MonthlyFundData extends ActivityBase {
|
||||
let obj = new MonthlyFundPage(data, this.beginTime);
|
||||
if(obj) this.list.push(obj);
|
||||
}
|
||||
this.roundIndex = parseInt(moment(this.beginTime).format('YYYYMM'));
|
||||
this.todayIndex = deltaDays(getZeroPointD(SHOP_REFRESH_TYPE.MONTHLY), new Date) + 1;
|
||||
}
|
||||
|
||||
public setPlayerRecords(playerDatas: ActivityMonthlyFundModelType[]) {
|
||||
|
||||
@@ -313,5 +313,12 @@
|
||||
"sendName": "学宫驿使",
|
||||
"content": "亲爱的百家传人,逐鹿中原本轮备战期已结束,您在联军云台中的宝箱奖励尚未领取,现已发送至邮箱,请查收",
|
||||
"time": 720
|
||||
},
|
||||
{
|
||||
"id": 45,
|
||||
"title": "&",
|
||||
"sendName": "学宫驿使",
|
||||
"content": "月基金",
|
||||
"time": 720
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user