后台:邮件审核人
This commit is contained in:
@@ -51,4 +51,5 @@ export enum MAIL_TYPE {
|
||||
TREAT_GUILD_INFO = 22, // 月卡奖品
|
||||
};
|
||||
|
||||
export const SEND_NAME = '系统';
|
||||
export const SEND_NAME = '系统';
|
||||
export const SEND_TITLE = '系统邮件';
|
||||
@@ -439,6 +439,8 @@ export const STATUS = {
|
||||
GM_ACTIVITY_NOT_FIT_GROUP_TYPE: { code: 60021, simStr: '该活动不满足该活动组类型' },
|
||||
GM_MARQUEE_ERR: { code: 60022, simStr: '跑马灯定时设置错误' },
|
||||
GM_MARQUEE_CANCEL_ERR: { code: 60023, simStr: '取消失败' },
|
||||
GM_MAIL_NOT_FOUND: { code: 60024, simStr: '未找到该邮件' },
|
||||
GM_MAIL_HAS_SENT: { code: 60025, simStr: '邮件已经审批过了' },
|
||||
// 支付相关状态 70000 - 79999
|
||||
NO_PRODUCT_ID: { code: 70001, simStr: '无效商品' },
|
||||
NO_PAY_TYPE: { code: 70002, simStr: '无效支付类型' },
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
*/
|
||||
import BaseModel from './BaseModel';
|
||||
import { getModelForClass, prop, DocumentType, mongoose, ReturnModelType } from '@typegoose/typegoose';
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../consts';
|
||||
import { SearchMailParam } from '../domain/backEndField/search';
|
||||
|
||||
@@ -23,6 +22,8 @@ export class Receiver {
|
||||
roleId?: string;
|
||||
@prop({ required: true })
|
||||
roleName?: string;
|
||||
@prop({ required: true })
|
||||
hasSend?: boolean;
|
||||
}
|
||||
|
||||
export default class GMMail extends BaseModel {
|
||||
@@ -78,6 +79,14 @@ export default class GMMail extends BaseModel {
|
||||
@prop({ required: true, default: 0 })
|
||||
status: GM_MAIL_STATUS; // 邮件状态
|
||||
|
||||
@prop({ required: true })
|
||||
viewBy: number; // 审核人
|
||||
|
||||
@prop({ required: true })
|
||||
viewAt: Date; // 审核时间
|
||||
|
||||
@prop({ required: true })
|
||||
sendTime: string; // 发送时间
|
||||
|
||||
public static async addMail(params: GMMailTypeParam, uid = 1) {
|
||||
const doc = new GMMailModel();
|
||||
@@ -96,20 +105,8 @@ export default class GMMail extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getMail(updatedMailAt: number, lean = true) {
|
||||
const result: GMMailType[] = await GMMailModel.find({ $or: [{updatedAt: { $gte: new Date(updatedMailAt) }}, {sendTime: { $lte: nowSeconds() }}], endTime: { $gte: nowSeconds()} }).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async getMails( lean = true) {
|
||||
const result: GMMailType[] = await GMMailModel.find({ endTime: { $gte: nowSeconds() }}).lean(lean);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private static getSearchObj(form: SearchMailParam) {
|
||||
let searchObj = {};
|
||||
console.log('******', form)
|
||||
if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart * 1000) };
|
||||
if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd * 1000) };
|
||||
if(form.serverId) searchObj['receivers.serverId'] = form.serverId;
|
||||
|
||||
@@ -10,6 +10,9 @@ class Reward {
|
||||
|
||||
export default class MailTemp extends BaseModel {
|
||||
|
||||
@prop({ required: true })
|
||||
gmmailId: string;
|
||||
|
||||
@prop({ required: true })
|
||||
contentId: number; // dic_email_content.json中的id
|
||||
|
||||
|
||||
@@ -76,21 +76,12 @@ export class MailParam {
|
||||
}
|
||||
|
||||
setContent(mail: MailType|GroupMailType|ServerMailType) {
|
||||
let { contentId = 0, goods, sendName } = mail;
|
||||
let params = []
|
||||
let { contentId = 0, goods, sendName, content, title } = mail;
|
||||
let dicMail = gameData.mail.get(contentId);
|
||||
if(!dicMail) dicMail = gameData.mail.get(0);
|
||||
|
||||
this.content = this.getContent(dicMail.content, params);
|
||||
this.title = title;
|
||||
this.content = content;
|
||||
this.sendName = sendName||SEND_NAME;
|
||||
this.goods = goods;
|
||||
}
|
||||
|
||||
getContent(content: string, params: string[]) {
|
||||
if(!content) content = '%d';
|
||||
for(let p of params) {
|
||||
content = content.replace(/%d/, p);
|
||||
}
|
||||
return content
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ export interface DicMail {
|
||||
readonly id: number;
|
||||
// 内容 %d 替换
|
||||
readonly content: string;
|
||||
readonly title: string;
|
||||
readonly sendName: string;
|
||||
readonly time: number;
|
||||
}
|
||||
|
||||
@@ -16,6 +18,8 @@ export function loadMail() {
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_MAIL);
|
||||
arr.forEach(o => {
|
||||
if(o.title == '&') o.title = '';
|
||||
if(o.sendName == '&') o.sendName = '';
|
||||
o.time = o.time * 60 * 60;
|
||||
dicMail.set(o.id, o);
|
||||
});
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
import { mailInit, setMails, GMMail } from '../gmData/gmMail';
|
||||
import { nowSeconds } from '../timeUtil';
|
||||
const ALL_SERVER = 0;
|
||||
export let gmData:any = {};
|
||||
export async function init() {
|
||||
gmData.mails = await mailInit();
|
||||
}
|
||||
|
||||
export function getGmMails(updatedMailAt: number, serverId: number) {
|
||||
let list = [];
|
||||
let nowTime = nowSeconds();
|
||||
let serverIds = [serverId, ALL_SERVER];
|
||||
for (let serverId of serverIds) {
|
||||
let gmServerData = gmData.mails.get(serverId);
|
||||
if (!gmServerData)
|
||||
continue;
|
||||
gmServerData.forEach((gmMail)=>{
|
||||
if (gmMail.updatedAt >= updatedMailAt || gmMail.sendTime > updatedMailAt || gmMail.endTime > nowTime )
|
||||
list.push(gmMail);
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export function getUseGmMails(serverId: number) {
|
||||
let list = new Map<string, GMMail>();
|
||||
let serverIds = [serverId, ALL_SERVER];
|
||||
let nowTime = nowSeconds();
|
||||
for (let serverId of serverIds) {
|
||||
let gmServerData = gmData.mails.get(serverId);
|
||||
if (!gmServerData)
|
||||
continue;
|
||||
gmServerData.forEach((gmMail)=>{
|
||||
if (gmMail.endTime > nowTime)
|
||||
list.set(gmMail.id, gmMail);
|
||||
});
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
export function getGmMailById(id: string, serverId: number, nowTime: number) {
|
||||
let gmMail;
|
||||
if (!!gmData.mails.get(serverId)) {
|
||||
gmMail = gmData.mails.get(serverId).get(id);
|
||||
}
|
||||
if (!gmMail) {
|
||||
if (!!gmData.mails.get(ALL_SERVER)) {
|
||||
gmMail = gmData.mails.get(ALL_SERVER).get(id);
|
||||
}
|
||||
}
|
||||
if (!gmMail || gmMail.endTime < nowTime)
|
||||
return null;
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
export function setGmMails(mails: GMMail[]) {
|
||||
setMails(mails, gmData.mails);
|
||||
}
|
||||
|
||||
|
||||
export function getGmUseMails(serverId: number) {
|
||||
let list = new Map<number, any>();
|
||||
if (!!gmData.mails.get(serverId)) {
|
||||
list = gmData.mails.get(serverId);
|
||||
}
|
||||
let serverMail = gmData.mails.get(ALL_SERVER);
|
||||
if (!!serverMail) {
|
||||
list = Object.assign(list, serverMail);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
import { RewardInter } from '../interface';
|
||||
import { GMMailModel } from '../../db/GMMail';
|
||||
const _ = require('lodash');
|
||||
|
||||
export interface GMMail {
|
||||
readonly id: string;
|
||||
readonly sendRoles?: Array<{roleId: string, status: number}>;
|
||||
readonly goods: Array<RewardInter>;
|
||||
readonly sendTime: number;
|
||||
readonly endTime: number;
|
||||
readonly content: string;
|
||||
readonly gmMailType: number;
|
||||
readonly updatedAt: number;
|
||||
readonly serverId: number;
|
||||
readonly sendName: string;
|
||||
}
|
||||
|
||||
const GMMailKeys: KeysEnum<GMMail> = {
|
||||
id: true,
|
||||
sendRoles: true,
|
||||
goods: true,
|
||||
sendTime: true,
|
||||
endTime: true,
|
||||
content: true,
|
||||
gmMailType: true,
|
||||
updatedAt: true,
|
||||
serverId: true,
|
||||
sendName: true
|
||||
};
|
||||
|
||||
export async function mailInit() {
|
||||
let gmMail = new Map<number, any>();
|
||||
let mails = await GMMailModel.getMails();
|
||||
mails.map((o:any)=>{
|
||||
o.id = o._id.toString();
|
||||
o.updatedAt = Math.floor(o.updatedAt.getTime()/1000);
|
||||
let mail = gmMail.get(o.serverId);
|
||||
if (!mail)
|
||||
mail = new Map<string, GMMail>();
|
||||
o.sendName = o.sendName||'系统';
|
||||
mail.set(o.id, _.pick(o, Object.keys(GMMailKeys)));
|
||||
gmMail.set(o.serverId, mail);
|
||||
});
|
||||
return gmMail;
|
||||
}
|
||||
|
||||
|
||||
export function setMails(mails:GMMail[], gmMail) {
|
||||
mails.map((o:any)=>{
|
||||
o.id = o._id.toString();
|
||||
o.updatedAt = Math.floor(o.updatedAt.getTime()/1000);
|
||||
o.sendName = o.sendName||'系统';
|
||||
let mail = gmMail.get(o.serverId);
|
||||
if (!mail)
|
||||
mail = new Map<string, GMMail>();
|
||||
mail.set(o.id, _.pick(o, Object.keys(GMMailKeys)));
|
||||
gmMail.set(o.serverId, mail);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user