后台:邮件设置修复

This commit is contained in:
luying
2021-12-09 11:25:26 +08:00
parent 24a9295ff3
commit 3db2735d6e
4 changed files with 93 additions and 14 deletions
+36
View File
@@ -6,6 +6,9 @@ import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts';
import { SearchMailParam } from '../domain/backEndField/search';
import { getCurDay, nowSeconds } from '../pubUtils/timeUtil';
import { GMMail as StategyMail } from './ServerStategy';
import { ServerlistType } from './Serverlist';
import moment = require('moment');
class Reward {
@prop({ required: true })
@@ -87,6 +90,39 @@ export default class GMMail extends BaseModel {
@prop({ required: true })
sendTime: string; // 发送时间
public setByRegionStategy(type: 'openMail'|'circleMail', gmmail: StategyMail, newServer: ServerlistType, uid) {
this.hasGoods = !!gmmail.goods?.length;
this.goods = gmmail.goods;
this.timeType = type == 'openMail'? MAIL_TIME_TYPE.DELAY: MAIL_TIME_TYPE.CIRCLE;
this.expire = gmmail.expire;
if(type == 'openMail') {
this.startTime = nowSeconds();
} else {
this.circleStart = nowSeconds();
this.circleEnd = nowSeconds() + gmmail.circleContinueDay * 24 * 60 * 60;
this.circleDay = gmmail.circleDay;
this.circleHour = gmmail.circleHour;
}
this.title = gmmail.title;
this.content = gmmail.content;
this.sendName = gmmail.sendName;
this.mailType = GM_MAIL_TYPE.SERVER;
this.receivers = [{
env: newServer.env,
serverId: newServer.id
}];
this.reason = gmmail.reason;
this.isSp = gmmail.isSp;
this.status = GM_MAIL_STATUS.PASS;
this.viewBy = uid;
this.viewAt = new Date();
if (type == 'openMail') {
this.sendTime = moment(this.startTime * 1000).format('YYYY-MM-DD HH:mm:ss');
} else {
this.sendTime = (this.circleDay == 0?'每天': '每周'+this.circleDay) + ' ' + this.circleHour;
}
}
public static async addMail(params: GMMailTypeParam, uid = 1) {
const doc = new GMMailModel();
let mail = Object.assign(doc.toJSON(), params);