🐞 fix(gvg): 添加可以不发奖励的开关

This commit is contained in:
luying
2023-03-10 13:29:57 +08:00
parent a194376c87
commit 38b7b66263
4 changed files with 29 additions and 15 deletions
+16 -4
View File
@@ -55,9 +55,11 @@ function getMailInfos(roleId: string, mails: MailType[], groupMails: GroupMailTy
return list;
}
export async function sendMailByContent(contentId: MAIL_TYPE, hisRoleId: string, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }) {
export async function sendMailByContent(contentId: MAIL_TYPE, hisRoleId: string, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }, dontSendReward?: boolean) {
let f = new SendMailFun();
let code = f.setWithContentId(contentId, params);
if(dontSendReward) f.setMailHide();
await f.createSingleMails(code, [hisRoleId]);
await f.pushToUsers();
}
@@ -72,11 +74,13 @@ export async function sendMailToGuildByContent(contentId: MAIL_TYPE, guildCode:
return true;
}
export async function sendMailToLeagueByContent(contentId: MAIL_TYPE, leagueCode: string, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }, league?: GVGLeagueType) {
export async function sendMailToLeagueByContent(contentId: MAIL_TYPE, leagueCode: string, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }, league?: GVGLeagueType, dontSendReward?: boolean) {
console.log('###### sendMailToLeagueByContent', dontSendReward)
if(!league) league = await GVGLeagueModel.findByCodeWithoutPopulate(leagueCode);
if(!league) return false;
let f = new SendMailFun();
let code = f.setWithContentId(contentId, params);
if(dontSendReward) f.setMailHide();
await f.createGroupMails(code, league.members.map(cur => cur.roleId), null, leagueCode);
await f.pushToUsers();
return true;
@@ -201,11 +205,16 @@ export class SendMailFun {
private mails: MailType[] = [];
private groupMails: GroupMailType[] = [];
private serverMails: ServerMailType[] = [];
private hideMail = false;
public getMailTemp(code: string) {
return this.mailTemps.get(code);
}
public setMailHide() {
this.hideMail = true;
}
// 从dicMail读取数据
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) {
let mailTemp = new MailTemp();
@@ -228,7 +237,8 @@ export class SendMailFun {
let mapTemp = this.mailTemps.get(code);
if(mapTemp.sendTime < nowSeconds()) return;
for(let roleId of roleIds) {
let originMail = await MailModel.addMail({ roleId, ...mapTemp.getCreateMailParams() });
console.log('#### createSingleMails this.hideMail', this.hideMail, this.hideMail? MAIL_STATUS.HIDE: MAIL_STATUS.CREATE)
let originMail = await MailModel.addMail({ roleId, status: this.hideMail? MAIL_STATUS.HIDE: MAIL_STATUS.CREATE, ...mapTemp.getCreateMailParams() });
this.mails.push(originMail);
}
if(mapTemp.gmmail) await GMMailModel.sendMail(mapTemp.gmmail._id, mapTemp.sendTime);
@@ -239,8 +249,9 @@ export class SendMailFun {
let mapTemp = this.mailTemps.get(code);
if(mapTemp.sendTime < nowSeconds()) return;
let roleStatus = roleIds.map(roleId => {
return { roleId, status: MAIL_STATUS.CREATE }
return { roleId, status: this.hideMail? MAIL_STATUS.HIDE: MAIL_STATUS.CREATE }
})
console.log('#### createGroupMails', this.hideMail, roleStatus)
let originMail = await GroupMailModel.addMail({ roleStatus, guildCode, leagueCode, ...mapTemp.getCreateMailParams() });
if(mapTemp.gmmail) await GMMailModel.sendMail(mapTemp.gmmail._id, mapTemp.sendTime);
this.groupMails.push(originMail);
@@ -266,6 +277,7 @@ export class SendMailFun {
// 将存储的邮件发出
public async pushToUsers(myRoleId?: string, mySid?: string) {
if(this.hideMail) return;
// 将可以发的邮件发出
let pushByRoleId = new Map<string, MailParam[]>();
let pushByGuildCode = new Map<string, MailParam[]>();