后台:邮件

This commit is contained in:
luying
2021-12-01 11:30:25 +08:00
parent c4e4e472d1
commit 53e55b288f
16 changed files with 192 additions and 83 deletions
+65
View File
@@ -0,0 +1,65 @@
import { GM_MAIL_TYPE, MAIL_TIME_TYPE } from "../../consts";
import { isArray } from 'underscore';
export class UpdateMailParams {
hasGoods: boolean = false; // 是否有道具
goods: {id: number; count: number}[];
timeType: MAIL_TIME_TYPE; // 邮件时间类型
expire: number; // 有效时间,单位小时
startTime: number; // 发送时间,延时邮件使用
circleStart: number; // 循环邮件开始循环时间
circleEnd: number; // 循环邮件结束循环时间
circleDay: number; // 循环时间,每周几,0表示每天
circleHour: string; // 几点发送
title: string;
content: string;
sendName: string;
mailType: GM_MAIL_TYPE; // 收件人类型
receivers: {env: string; serverId: number; roleId: string; roleName: string; }[];
reason: string; // 原因
isSp: boolean = false; // 特殊邮件
isSingle: boolean;
constructor(obj: UpdateMailParams) {
this.goods = obj.goods;
this.hasGoods = obj.goods?.length > 0;
this.timeType = obj.timeType;
this.expire = obj.expire;
this.startTime = obj.startTime;
this.circleStart = obj.circleStart;
this.circleEnd = obj.circleEnd;
this.circleDay = obj.circleDay;
this.circleHour = obj.circleHour;
this.title = obj.title;
this.content = obj.content;
this.sendName = obj.sendName;
if(obj.isSingle == true) {
this.mailType = GM_MAIL_TYPE.SINGLE;
} else if (obj.isSingle == false) {
this.mailType = GM_MAIL_TYPE.SERVER;
}
this.receivers = obj.receivers;
this.reason = obj.reason;
}
checkParams() {
if(!this.title || !this.content || !this.sendName || !this.reason) return false;
if(this.timeType == MAIL_TIME_TYPE.IMMEDIATE) {
if(!this.expire) return false;
} else if (this.timeType == MAIL_TIME_TYPE.DELAY) {
if(!this.expire || !this.startTime) return false;
} else if (this.timeType == MAIL_TIME_TYPE.CIRCLE) {
if(!this.expire || !this.circleStart || !this.circleEnd || this.circleDay == undefined || !this.circleHour)
return false;
}
if(!this.receivers || !isArray(this.receivers)) return false;
if(!this.mailType) return false;
for(let { serverId, roleId, roleName } of this.receivers) {
if(!serverId) return false;
if(this.mailType == GM_MAIL_TYPE.SINGLE||this.mailType == GM_MAIL_TYPE.GROUP) {
if(!roleId || !roleName) return false;
}
}
return true;
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "@consts";
import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "../../consts";
export interface SearchUserParam {
uid?: number;