活动:招财进宝宝箱5点未领取发放邮箱

This commit is contained in:
luying
2022-05-27 22:41:53 +08:00
parent 1452e8b800
commit 2265c60289
8 changed files with 114 additions and 22 deletions
+1
View File
@@ -54,6 +54,7 @@ export enum MAIL_TYPE {
GUILD_FUND_BOX = 25, // 军团每日捐献宝箱补领
GUILD_BOSS = 26, // 军团boss奖励
PVP_BOX = 27, // pvp巅峰之路宝箱
DAILY_COIN = 28, // 招财进宝宝箱
};
export const SEND_NAME = '系统';
+25 -5
View File
@@ -25,20 +25,25 @@ export default class Activity_Daily_Coin extends BaseModel {
@prop({ required: true })
roundIndex: number; // 周期数
@prop({ required: true, type: Number })
receivedBox: number[]; // 周期数
receivedBox: number[]; // 已领取宝箱
@prop({ required: true })
hasNotReceivedBox: boolean; // 是否有没有领取的宝箱
@prop({ required: true })
repaireBoxed: number[]; // 是否有没有领取的宝箱
//兑换记录
public static async addExchangeRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, count: number, coinCount: number, msg: string) {
public static async addExchangeRecord(serverId: number, activityId: number, roleId: string, roundIndex: number, count: number, coinCount: number, msg: string, hasNotReceivedBox: boolean) {
let result = await ActivityDailyCoinModel.findOneAndUpdate({ serverId, activityId, roleId, roundIndex },
{ $inc: { exchangeCount: count, coinCount: coinCount }, $push: { recordMsg: msg } }, { upsert: true, new: true }).lean(true)
{ $inc: { exchangeCount: count, coinCount: coinCount }, $push: { recordMsg: msg }, $set: { hasNotReceivedBox } }, { upsert: true, new: true }).lean(true)
return result;
}
// 领取宝箱
public static async receiveBox(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number) {
public static async receiveBox(serverId: number, activityId: number, roleId: string, roundIndex: number, cellIndex: number, hasNotReceivedBox: boolean) {
let result = await ActivityDailyCoinModel.findOneAndUpdate({ serverId, activityId, roleId, roundIndex },
{ $push: { receivedBox: cellIndex } }, { upsert: true, new: true }).lean(true)
{ $push: { receivedBox: cellIndex }, $set: { hasNotReceivedBox } }, { upsert: true, new: true }).lean(true)
return result;
}
@@ -50,6 +55,21 @@ export default class Activity_Daily_Coin extends BaseModel {
return result;
}
// 未发放完
public static async findUnreceivedBox(beginTime: Date, endTime: Date) {
let result: ActivityDailyCoinModelType[] = await ActivityDailyCoinModel.find({
createdAt: { $gte: beginTime, $lte: endTime }, hasNotReceivedBox: true
}).lean(true);
return result;
}
// 凌晨5点补发邮箱
public static async repaireBox(_id: string, boxIds: number[]) {
let result = await ActivityDailyCoinModel.findByIdAndUpdate({ _id },
{ $push: { repaireBoxed: { $each: boxIds } } }, { upsert: true, new: true }).lean(true)
return result;
}
//删除活动兑换记录
public static async deleteActivity(serverId: number, activityId: number, roleId: string, roundIndex: number) {
await ActivityDailyCoinModel.deleteMany({ serverId, roleId, activityId, roundIndex });
+29 -5
View File
@@ -73,6 +73,16 @@ export class ExtraRewardItem {
if(count >= this.exchangeCount) this.status = DAILY_COIN_BOX_STATUS.CAN_OPEN;
if(receivedBox.indexOf(this.cellIndex) != -1) this.status = DAILY_COIN_BOX_STATUS.RECEIVED;
}
addExchangeCount(exchangeCount: number) {
if(this.status == DAILY_COIN_BOX_STATUS.CAN_NOT_OPEN && exchangeCount >= this.exchangeCount) {
this.status = DAILY_COIN_BOX_STATUS.CAN_OPEN;
}
}
receiveBox() {
this.status = DAILY_COIN_BOX_STATUS.RECEIVED;
}
}
// 每日兑换铜币活动数据
@@ -122,27 +132,41 @@ export class DailyCoinData extends ActivityBase {
this.exchangeCount = data.exchangeCount||0;
this.coinCount = data.coinCount || 0;
this.recordMsg = data.recordMsg || [];
this.setAllBoxStatus(data);
for(let box of this.extraReward) {
box.setRecord(this.exchangeCount, data.receivedBox||[]);
}
}
public findBoxByCellIndex(cellIndex: number) {
return this.extraReward.find(cur => cur.cellIndex == cellIndex);
}
public setAllBoxStatus(data: ActivityDailyCoinModelType) {
public addExchangeCount(count: number) {
this.exchangeCount += count;
for(let box of this.extraReward) {
box.setRecord(this.exchangeCount, data.receivedBox||[]);
box.addExchangeCount(this.exchangeCount);
}
return this.extraReward;
}
public setBoxStatus(cellIndex: number, data: ActivityDailyCoinModelType) {
public receiveBox(cellIndex: number) {
let item = this.extraReward.find(cur => cur.cellIndex == cellIndex);
if(!item) return null;
item.setRecord(data.exchangeCount, data.receivedBox||[]);
item.receiveBox();
return item
}
public hasNotReceivedBox(): boolean {
for(let box of this.extraReward) {
if(box.status == DAILY_COIN_BOX_STATUS.CAN_OPEN) return true;
}
return false;
}
public getUnReceivedBox() {
return this.extraReward.filter(cur => cur.status == DAILY_COIN_BOX_STATUS.CAN_OPEN);
}
public initData(data: string) {
this.exchangeCount = 0;
this.coinCount = 0;
@@ -194,5 +194,12 @@
"sendName": "&",
"content": "竞技新赛季开始啦,您在上赛季的巅峰之路中有奖励尚未领取,现已发送至您邮箱,请查收",
"time": 720
},
{
"id": 28,
"title": "&",
"sendName": "&",
"content": "您昨日在招财进宝中有宝箱没有领取,现已发送至您的邮箱,请查收",
"time": 720
}
]