feat(邮件): 添加专属邮件

This commit is contained in:
luying
2023-04-06 17:36:44 +08:00
parent ec65f880b7
commit 579ee7846f
7 changed files with 17 additions and 6 deletions

View File

@@ -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,
}
}
}

View File

@@ -84,6 +84,7 @@ export default class GroupMail extends MailTemp {
*/
public static async delMailsByRoleId(roleId: string) {
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;
}
}

View File

@@ -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;
}
}

View File

@@ -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<Reward>;

View File

@@ -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;

View File

@@ -45,6 +45,7 @@ export class UpdateMailParams {
}
this.receivers = obj.receivers;
this.reason = obj.reason;
this.isSp = obj.isSp;
}
checkParams() {

View File

@@ -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) {