✨ feat(邮件): 添加专属邮件
This commit is contained in:
@@ -125,6 +125,7 @@ class MailTemp {
|
|||||||
private goods: RewardInter[] = []; // 发送的奖励
|
private goods: RewardInter[] = []; // 发送的奖励
|
||||||
public sendTime: number;
|
public sendTime: number;
|
||||||
private endTime: number;
|
private endTime: number;
|
||||||
|
private isSp: boolean = false;
|
||||||
|
|
||||||
// 从dicMail读取数据
|
// 从dicMail读取数据
|
||||||
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) {
|
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) {
|
||||||
@@ -171,6 +172,7 @@ class MailTemp {
|
|||||||
this.content = gmmail.content;
|
this.content = gmmail.content;
|
||||||
this.hasGoods = gmmail.hasGoods;
|
this.hasGoods = gmmail.hasGoods;
|
||||||
this.goods = gmmail.goods;
|
this.goods = gmmail.goods;
|
||||||
|
this.isSp = gmmail.isSp;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +194,8 @@ class MailTemp {
|
|||||||
title: this.title,
|
title: this.title,
|
||||||
sendName: this.sendName,
|
sendName: this.sendName,
|
||||||
content: this.content,
|
content: this.content,
|
||||||
hasGoods: this.hasGoods
|
hasGoods: this.hasGoods,
|
||||||
|
isSp: this.isSp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -83,7 +83,8 @@ export default class GroupMail extends MailTemp {
|
|||||||
* @param roleId
|
* @param roleId
|
||||||
*/
|
*/
|
||||||
public static async delMailsByRoleId(roleId: string) {
|
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() },
|
sendTime:{ $lte: nowSeconds() },
|
||||||
$or: [{
|
$or: [{
|
||||||
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false
|
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false
|
||||||
@@ -160,7 +161,7 @@ export default class GroupMail extends MailTemp {
|
|||||||
* @param lean
|
* @param lean
|
||||||
*/
|
*/
|
||||||
public static async findRewardsMails(roleId: string, lean = true) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export default class Mail extends MailTemp {
|
|||||||
* @param roleId
|
* @param roleId
|
||||||
*/
|
*/
|
||||||
public static async delMailsByRoleId(roleId: string) {
|
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[] = [];
|
let result: MailType[] = [];
|
||||||
for(let _id of ids) {
|
for(let _id of ids) {
|
||||||
let rec = await MailModel.findByIdAndUpdate(_id, { $set:{ status: MAIL_STATUS.DELETE }}, { new: true }).lean();
|
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
|
* @param lean
|
||||||
*/
|
*/
|
||||||
public static async findRewardsMails(roleId: string, lean = true) {
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ export default class MailTemp extends BaseModel {
|
|||||||
@prop({ required: true })
|
@prop({ required: true })
|
||||||
hasGoods: boolean;
|
hasGoods: boolean;
|
||||||
|
|
||||||
|
@prop({ required: true })
|
||||||
|
isSp: boolean;
|
||||||
|
|
||||||
@prop({ required: true, type: Reward, default: [], _id: false })
|
@prop({ required: true, type: Reward, default: [], _id: false })
|
||||||
goods: Array<Reward>;
|
goods: Array<Reward>;
|
||||||
|
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ export default class ServerMail extends MailTemp {
|
|||||||
public static async delMailsByRoleId(roleId: string) {
|
public static async delMailsByRoleId(roleId: string) {
|
||||||
const ids: { _id: string }[] = await ServerMailModel.find(
|
const ids: { _id: string }[] = await ServerMailModel.find(
|
||||||
{
|
{
|
||||||
|
isSp: false,
|
||||||
sendTime:{ $lte: nowSeconds() },
|
sendTime:{ $lte: nowSeconds() },
|
||||||
$or: [{
|
$or: [{
|
||||||
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false
|
roleStatus: {$elemMatch: {roleId, status: MAIL_STATUS.READ}}, hasGoods:false
|
||||||
@@ -133,7 +134,7 @@ export default class ServerMail extends MailTemp {
|
|||||||
* @param lean
|
* @param lean
|
||||||
*/
|
*/
|
||||||
public static async findRewardsMails(serverId: number, roleId: string, lean = true) {
|
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[] = [];
|
let result: ServerMailType[] = [];
|
||||||
for(let mail of allMails) {
|
for(let mail of allMails) {
|
||||||
let { roleStatus } = mail;
|
let { roleStatus } = mail;
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ export class UpdateMailParams {
|
|||||||
}
|
}
|
||||||
this.receivers = obj.receivers;
|
this.receivers = obj.receivers;
|
||||||
this.reason = obj.reason;
|
this.reason = obj.reason;
|
||||||
|
this.isSp = obj.isSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkParams() {
|
checkParams() {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ export class MailParam {
|
|||||||
endTime: number = 0; // 过期时间
|
endTime: number = 0; // 过期时间
|
||||||
goods: ItemReward[] = []; // 奖励
|
goods: ItemReward[] = []; // 奖励
|
||||||
status: MAIL_STATUS = MAIL_STATUS.CREATE; // 状态
|
status: MAIL_STATUS = MAIL_STATUS.CREATE; // 状态
|
||||||
|
isSp: boolean = false; // 特殊
|
||||||
|
|
||||||
constructor(mailType: GM_MAIL_TYPE, mail: MailType|GroupMailType|ServerMailType, roleId?: string) {
|
constructor(mailType: GM_MAIL_TYPE, mail: MailType|GroupMailType|ServerMailType, roleId?: string) {
|
||||||
this.setMail(mailType, mail);
|
this.setMail(mailType, mail);
|
||||||
@@ -32,6 +33,7 @@ export class MailParam {
|
|||||||
this.mailType = mailType;
|
this.mailType = mailType;
|
||||||
this.sendTime = mail.sendTime;
|
this.sendTime = mail.sendTime;
|
||||||
this.endTime = mail.endTime;
|
this.endTime = mail.endTime;
|
||||||
|
this.isSp = mail.isSp;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSingleMail(mail: MailType, roleId?: string) {
|
setSingleMail(mail: MailType, roleId?: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user