From 579ee7846f432d2126c531ec3ebc0c9b5f240fbd Mon Sep 17 00:00:00 2001 From: luying Date: Thu, 6 Apr 2023 17:36:44 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E9=82=AE=E4=BB=B6):=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=93=E5=B1=9E=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game-server/app/services/mailService.ts | 5 ++++- shared/db/GroupMail.ts | 5 +++-- shared/db/Mail.ts | 4 ++-- shared/db/MailTemp.ts | 3 +++ shared/db/ServerMail.ts | 3 ++- shared/domain/backEndField/params.ts | 1 + shared/domain/roleField/mail.ts | 2 ++ 7 files changed, 17 insertions(+), 6 deletions(-) diff --git a/game-server/app/services/mailService.ts b/game-server/app/services/mailService.ts index 36dc5f086..ac37ce3ff 100644 --- a/game-server/app/services/mailService.ts +++ b/game-server/app/services/mailService.ts @@ -125,6 +125,7 @@ class MailTemp { private goods: RewardInter[] = []; // 发送的奖励 public sendTime: number; private endTime: number; + private isSp: boolean = false; // 从dicMail读取数据 public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) { @@ -171,6 +172,7 @@ class MailTemp { this.content = gmmail.content; this.hasGoods = gmmail.hasGoods; this.goods = gmmail.goods; + this.isSp = gmmail.isSp; return true; } @@ -192,7 +194,8 @@ class MailTemp { title: this.title, sendName: this.sendName, content: this.content, - hasGoods: this.hasGoods + hasGoods: this.hasGoods, + isSp: this.isSp, } } } diff --git a/shared/db/GroupMail.ts b/shared/db/GroupMail.ts index 8a317c4ae..52989efda 100644 --- a/shared/db/GroupMail.ts +++ b/shared/db/GroupMail.ts @@ -83,7 +83,8 @@ export default class GroupMail extends MailTemp { * @param roleId */ public static async delMailsByRoleId(roleId: string) { - const ids: { _id: string }[] = await GroupMailModel.find( { + const ids: { _id: string }[] = await GroupMailModel.find({ + isSp: false, sendTime:{ $lte: nowSeconds() }, $or: [{ roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false @@ -160,7 +161,7 @@ export default class GroupMail extends MailTemp { * @param lean */ public static async findRewardsMails(roleId: string, lean = true) { - const result: GroupMailType[] = await GroupMailModel.find({ roleStatus: { $elemMatch:{roleId, status:{ $in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ ] }} }, sendTime:{$lte: nowSeconds()} }).lean(lean); + const result: GroupMailType[] = await GroupMailModel.find({ roleStatus: { $elemMatch:{roleId, status:{ $in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ ] }} }, sendTime:{$lte: nowSeconds()}, isSp: false }).lean(lean); return result; } } diff --git a/shared/db/Mail.ts b/shared/db/Mail.ts index c7225ef6f..c99897ca0 100644 --- a/shared/db/Mail.ts +++ b/shared/db/Mail.ts @@ -87,7 +87,7 @@ export default class Mail extends MailTemp { * @param roleId */ public static async delMailsByRoleId(roleId: string) { - const ids: { _id: string }[] = await MailModel.find({ roleId, $or: [{ $and: [{ status: MAIL_STATUS.READ, hasGoods: false }] }, { status: MAIL_STATUS.RECEIVED }], sendTime:{$lte: nowSeconds()} }).select('_id').lean(); + const ids: { _id: string }[] = await MailModel.find({ roleId, $or: [{ $and: [{ status: MAIL_STATUS.READ, hasGoods: false }] }, { status: MAIL_STATUS.RECEIVED }], sendTime:{$lte: nowSeconds()}, isSp: false }).select('_id').lean(); let result: MailType[] = []; for(let _id of ids) { let rec = await MailModel.findByIdAndUpdate(_id, { $set:{ status: MAIL_STATUS.DELETE }}, { new: true }).lean(); @@ -128,7 +128,7 @@ export default class Mail extends MailTemp { * @param lean */ public static async findRewardsMails(roleId: string, lean = true) { - const result: MailType[] = await MailModel.find({ roleId, status: {$in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ ] }, sendTime:{$lte: nowSeconds()} }).lean(lean); + const result: MailType[] = await MailModel.find({ roleId, status: {$in: [ MAIL_STATUS.CREATE, MAIL_STATUS.READ ] }, sendTime:{$lte: nowSeconds()}, isSp: false }).lean(lean); return result; } } diff --git a/shared/db/MailTemp.ts b/shared/db/MailTemp.ts index e795ddd71..027714c95 100644 --- a/shared/db/MailTemp.ts +++ b/shared/db/MailTemp.ts @@ -35,6 +35,9 @@ export default class MailTemp extends BaseModel { @prop({ required: true }) hasGoods: boolean; + @prop({ required: true }) + isSp: boolean; + @prop({ required: true, type: Reward, default: [], _id: false }) goods: Array; diff --git a/shared/db/ServerMail.ts b/shared/db/ServerMail.ts index 65380bd9b..824300aa2 100644 --- a/shared/db/ServerMail.ts +++ b/shared/db/ServerMail.ts @@ -98,6 +98,7 @@ export default class ServerMail extends MailTemp { public static async delMailsByRoleId(roleId: string) { const ids: { _id: string }[] = await ServerMailModel.find( { + isSp: false, sendTime:{ $lte: nowSeconds() }, $or: [{ roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false @@ -133,7 +134,7 @@ export default class ServerMail extends MailTemp { * @param lean */ public static async findRewardsMails(serverId: number, roleId: string, lean = true) { - const allMails: ServerMailType[] = await ServerMailModel.find({ serverId, sendTime:{$lte: nowSeconds()} }).lean(lean); + const allMails: ServerMailType[] = await ServerMailModel.find({ serverId, sendTime:{$lte: nowSeconds()}, isSp: false }).lean(lean); let result: ServerMailType[] = []; for(let mail of allMails) { let { roleStatus } = mail; diff --git a/shared/domain/backEndField/params.ts b/shared/domain/backEndField/params.ts index 21d792bb0..a543ae16a 100644 --- a/shared/domain/backEndField/params.ts +++ b/shared/domain/backEndField/params.ts @@ -45,6 +45,7 @@ export class UpdateMailParams { } this.receivers = obj.receivers; this.reason = obj.reason; + this.isSp = obj.isSp; } checkParams() { diff --git a/shared/domain/roleField/mail.ts b/shared/domain/roleField/mail.ts index 0c654d6b6..32574e416 100644 --- a/shared/domain/roleField/mail.ts +++ b/shared/domain/roleField/mail.ts @@ -15,6 +15,7 @@ export class MailParam { endTime: number = 0; // 过期时间 goods: ItemReward[] = []; // 奖励 status: MAIL_STATUS = MAIL_STATUS.CREATE; // 状态 + isSp: boolean = false; // 特殊 constructor(mailType: GM_MAIL_TYPE, mail: MailType|GroupMailType|ServerMailType, roleId?: string) { this.setMail(mailType, mail); @@ -32,6 +33,7 @@ export class MailParam { this.mailType = mailType; this.sendTime = mail.sendTime; this.endTime = mail.endTime; + this.isSp = mail.isSp; } setSingleMail(mail: MailType, roleId?: string) {