后台:邮件审核人

This commit is contained in:
luying
2021-12-01 17:42:36 +08:00
parent fe372de419
commit eafc060093
14 changed files with 103 additions and 307 deletions
+37 -31
View File
@@ -8,13 +8,14 @@ import { gameData } from "../pubUtils/data";
import { nowSeconds } from '../pubUtils/timeUtil';
import { STATUS } from '../consts/statusCode';
import { resResult } from '../pubUtils/util';
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TYPE, SEND_NAME } from "../consts";
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, SEND_NAME, SEND_TITLE } from "../consts";
import { MailParam } from '../domain/roleField/mail';
import { GMMailType, GMMailModel } from "../db/GMMail";
import { getGuildChannelSid, getWorldChannelSid } from "./chatChannelService";
import { GMMailRecordModel } from "../db/GMMailRecord";
import { BAG } from "../pubUtils/dicParam";
import { GuildModel, GuildType } from "../db/Guild";
import moment = require("moment");
/**
* 获取邮件信息
@@ -73,8 +74,9 @@ export async function sendMailToGuildByContent(contentId: MAIL_TYPE, guildCode:
export class SendMailFun {
private mailType: GM_MAIL_TYPE = GM_MAIL_TYPE.SINGLE; // 邮件类型 1-单人 2-多人 3-全服
private contentId: MAIL_TYPE = MAIL_TYPE.SEND_MAIL; // 0-读GmMail,1以上读dicMail
private params: string[] = [];
private sendName: string = SEND_NAME;
private title: string = SEND_TITLE;
private content: string = '';
private gmmail: GMMailType;
private hasGoods: boolean = false; // 是否内含奖励
private goods: RewardInter[] = []; // 发送的奖励
@@ -86,41 +88,44 @@ export class SendMailFun {
private serverMails: ServerMailType[] = [];
// 从dicMail读取数据
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }) {
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) {
let dicMail = gameData.mail.get(contentId);
this.contentId = contentId;
this.sendTime = nowSeconds();
this.endTime = this.sendTime + dicMail?.time||0;
this.setParam({ ...params });
this.content = this.getContent(dicMail.content, params.params);
if(dicMail.title) this.title = dicMail.title;
if(dicMail.sendName) this.sendName = dicMail.sendName;
this.hasGoods = params.goods.length > 0;
this.goods = params.goods;
}
getContent(content: string, params: string[]) {
if(!content) content = '%d';
for(let p of params) {
content = content.replace(/%d/, p);
}
return content
}
// 从GMMail表读取数据
public async setWithGmMail(gmmailId: string) {
// let gmmail = await GMMailModel.getGmMailById(gmmailId);
// if(gmmail) {
// this.gmmail = gmmail;
// if(gmmail.useTempTime) {
// this.sendTime = gmmail.sendTime;
// this.endTime = gmmail.endTime;
// } else {
// this.sendTime = nowSeconds();
// this.endTime = this.sendTime + (gmmail.continueHour||0) * 60 * 60;
// }
// this.setParam({ ...gmmail });
// }
}
private setParam(params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[], content?: string }) {
if(params.sendName) this.sendName = params.sendName;
if(params.endTime) this.endTime = params.endTime;
if(params.content) {
this.params.push(params.content);
}
if(params.params) this.params = params.params;
if(params.goods) {
this.hasGoods = params.goods.length > 0;
this.goods = params.goods;
public async setWithGmMail(gmmail: GMMailType) {
this.gmmail = gmmail;
this.contentId = 0;
if(gmmail.timeType == MAIL_TIME_TYPE.IMMEDIATE) {
this.sendTime = nowSeconds();
} else if (gmmail.timeType == MAIL_TIME_TYPE.DELAY) {
this.sendTime = gmmail.startTime;
} else if (gmmail.timeType == MAIL_TIME_TYPE.CIRCLE) {
this.sendTime = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix();
}
this.endTime = this.sendTime + gmmail.expire * 60 * 60;
this.sendName = gmmail.sendName;
this.title = gmmail.title;
this.content = gmmail.content;
this.hasGoods = gmmail.hasGoods;
this.goods = gmmail.goods;
return gmmail;
}
private getCreateMailParams() {
@@ -129,9 +134,10 @@ export class SendMailFun {
mail: this.gmmail?._id,
sendTime: this.sendTime,
endTime: this.endTime,
params: this.params,
goods: this.goods,
goods: this.goods,
title: this.title,
sendName: this.sendName,
content: this.content,
hasGoods: this.hasGoods
}
}