后台:邮件查询

This commit is contained in:
luying
2021-11-29 20:33:36 +08:00
parent 7e46663868
commit c4e4e472d1
13 changed files with 236 additions and 44 deletions

View File

@@ -5,9 +5,17 @@ export enum MAIL_STATUS {
RECEIVED = 2,
};
export const MAIL_TEM_TYPE = {
GAMEMAIL: 1,
GMTYPE: 2,
export enum MAIL_TIME_TYPE {
IMMEDIATE = 1, // 即时邮件
DELAY = 2, // 延时邮件
CIRCLE = 3, // 循环邮件
};
export enum GM_MAIL_STATUS {
CREATE = 0, // 创建
PASS = 1, // 审批通过
NOT_PASS = -1, // 审批不通过
};
export enum GM_MAIL_TYPE {

View File

@@ -2,8 +2,10 @@
* 邮件的模板在GM后台能看到的邮件列表
*/
import BaseModel from './BaseModel';
import { getModelForClass, prop, DocumentType } from '@typegoose/typegoose';
import { getModelForClass, prop, DocumentType, mongoose } 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';
class Reward {
@prop({ required: true })
@@ -12,28 +14,72 @@ class Reward {
count: number;
}
class Receiver {
@prop({ required: true })
env: string;
@prop({ required: true })
serverId: number;
@prop({ required: true })
roleId?: string;
@prop({ required: true })
roleName?: string;
}
export default class GMMail extends BaseModel {
@prop({ required: false})
hasGoods: boolean; // 有效时间,单位小时
@prop({ required: true, type: Reward, default: [], _id: false })
goods: Reward[];
@prop({ required: true, default: true })
useTempTime: boolean; // 生成邮件是否按照模板时间
timeType: MAIL_TIME_TYPE; // 邮件时间类型
@prop({ required: false})
continueHour: number; // 如果不按模板时间sendTime为生成单独邮件的时候endTime为sendTime+continueHour,单位小时
expire: number; // 有效时间,单位小时
@prop({ required: true })
sendTime: number; // 如果按照模板时间发送时间10位时间戳
startTime: number; // 发送时间,延时邮件使用
@prop({ required: true })
endTime: number; // 如果按照模板时间过期时间10位时间
circleStart: number; // 循环邮件开始循环时间
@prop({ required: true })
circleEnd: number; // 循环邮件结束循环时间
@prop({ required: true })
circleDay: number; // 循环时间每周几0表示每天
@prop({ required: true })
circleHour: number; // 几点发送
@prop({ required: true })
title: string;
@prop({ required: true })
content: string;
@prop({ required: true })
sendName: string;
@prop({ required: true })
mailType: GM_MAIL_TYPE; // 收件人类型
@prop({ required: true })
env: string; // 大区环境变量
@prop({ required: true, type: Receiver, _id: false })
receivers: Receiver[];
@prop({ required: true })
reason: string; // 原因
@prop({ required: true })
isSp: boolean; // 特殊邮件
@prop({ required: true })
status: GM_MAIL_STATUS; // 邮件状态
public static async addMail(params: GMMailTypeParam, uid = 1) {
const doc = new GMMailModel();
@@ -63,14 +109,21 @@ export default class GMMail extends BaseModel {
}
private static getSearchObj(form: {_id?: string, content?: string}) {
private static getSearchObj(form: SearchMailParam) {
let searchObj = {};
if(form['_id']) searchObj['_id'] = form._id;
if(form['content']) searchObj['context'] = { $regex: new RegExp(form.content.toString(), 'i') }
if(form.createTimeStart) searchObj['createdAt'] = { $gt: new Date(form.createTimeStart) };
if(form.createTimeEnd) searchObj['createdAt'] = { $lt: new Date(form.createTimeEnd) };
if(form.serverId) searchObj['receivers.serverId'] = form.serverId;
if(form.roleId) searchObj['receivers.roleId'] = form.roleId;
if(form.roleName) searchObj['receivers.roleName'] = { $regex: new RegExp(form.roleName.toString(), 'i') }
if(form.status) searchObj['status'] = form.status;
if(form.mailType) searchObj['mailType'] = form.mailType;
if(form.hasGoods != undefined) searchObj['hasGoods'] = form.hasGoods;
if(form.title) searchObj['title'] = { $regex: new RegExp(form.title.toString(), 'i') }
return searchObj
}
public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: {_id?: string, content?: string} = {}) {
public static async findByCondition(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchMailParam = {}) {
let searchObj = this.getSearchObj(form);
let sort = {};
@@ -86,7 +139,7 @@ export default class GMMail extends BaseModel {
}
public static async countByCondition(form: {_id?: string, content?: string} = {}) {
public static async countByCondition(form: SearchMailParam = {}) {
let searchObj = this.getSearchObj(form);
const result = await GMMailModel.count(searchObj);
@@ -96,7 +149,12 @@ export default class GMMail extends BaseModel {
}
export const GMMailModel = getModelForClass(GMMail);
export let GMMailModel = getModelForClass(GMMail);
export function loadGMMailModel(connect: mongoose.Connection) {
GMMailModel = getModelForClass(GMMail, {
existingConnection: connect
});
}
export interface GMMailType extends Pick<DocumentType<GMMail>, keyof GMMail> { };

View File

@@ -5,7 +5,7 @@ import { CounterModel } from './Counter';
import { COUNTER, EQUIP_TYPE, HERO_CE_RATIO } from '../consts';
import { reduceCe } from '../pubUtils/util';
import Skin from './Skin';
import { SearchHeroParam } from '@domain/backEndField/search';
import { SearchHeroParam } from '../domain/backEndField/search';
type CeAttrUpdate = Partial<CeAttrData>;
export class CeAttrData {

View File

@@ -1,6 +1,5 @@
import BaseModel from './BaseModel';
import { prop, Ref, mongoose } from '@typegoose/typegoose';
import GMMail from './GMMail';
import { prop } from '@typegoose/typegoose';
class Reward {
@prop({ required: true })
@@ -14,21 +13,21 @@ export default class MailTemp extends BaseModel {
@prop({ required: true })
contentId: number; // dic_email_content.json中的id
@prop({ ref: 'GMMail', type: mongoose.Schema.Types.ObjectId })
mail: Ref<GMMail>;
@prop({ required: true })
sendTime: number;
@prop({ required: true })
endTime: number;
@prop({ required: true, type: String, _id: false})
params: string[];
@prop({ required: true })
title: string; // 标题
@prop({ required: true })
sendName: string; // 发件人
@prop({ required: true })
content: string; // 内容
@prop({ required: true })
hasGoods: boolean;

View File

@@ -71,8 +71,15 @@ export default class Serverlist extends BaseModel {
medianCe: number; // 中位数武将战力、缩小10000倍后的结果
public static async getAllServerList() {
let servers: ServerlistType[] = await ServerlistModel.find().lean({ getters: true, virtuals: true });
return servers;
let id = await CounterModel.getCounter(COUNTER.SERVER);
let result: ServerlistType[] = [];
let n = Math.ceil(id/1000);
console.log('****', id, n)
for(let i = 0; i < n; i++) {
let servers: ServerlistType[] = await ServerlistModel.find().limit(1000).skip(i * 1000).lean({ getters: true, virtuals: true });
result.push(...servers);
}
return result;
}
public static async findByServerId(serverId: number) {

View File

@@ -6,6 +6,7 @@ import { loadGMUserModel } from './GMUser'
import { loadGMUserGroupModel } from "./GMUserGroup";
import { loadRegionModel } from "./Region";
import { loadServerlistModel } from "./Serverlist";
import { loadGMMailModel } from './GMMail';
export function loadGmDb(connect: mongoose.Connection) {
loadApiModel(connect);
@@ -15,4 +16,5 @@ export function loadGmDb(connect: mongoose.Connection) {
loadGMRecordModel(connect);
loadRegionModel(connect);
loadServerlistModel(connect);
loadGMMailModel(connect);
}

View File

@@ -1,3 +1,5 @@
import { GM_MAIL_STATUS, GM_MAIL_TYPE } from "@consts";
export interface SearchUserParam {
uid?: number;
tel?: string;
@@ -20,4 +22,16 @@ export interface SearchEquipParam {
roleId?: string;
roleName?: string;
id?: number;
}
export interface SearchMailParam {
createTimeStart?: number;
createTimeEnd?: number;
serverId?: number;
roleId?: string;
roleName?: string;
title?: string;
status?: GM_MAIL_STATUS;
mailType?: GM_MAIL_TYPE;
hasGoods?: boolean;
}

View File

@@ -1,119 +1,149 @@
[
{
"id": 0,
"title": "邮件标题",
"title": "&",
"sendName": "&",
"content": "%d",
"time": 24
},
{
"id": 1,
"title": "&",
"sendName": "&",
"content": "您对军团%d的申请被拒绝",
"time": 24
},
{
"id": 2,
"title": "&",
"sendName": "&",
"content": "由于被弹劾,您在军团%d的大将军职务已卸任",
"time": 24
},
{
"id": 3,
"title": "&",
"sendName": "&",
"content": "您被任命为军团%d的大将军",
"time": 24
},
{
"id": 4,
"title": "&",
"sendName": "&",
"content": "您被军团%d踢出",
"time": 24
},
{
"id": 5,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,您昨日的军团活跃奖励忘记领取了,现已通过邮件发放,请查收",
"time": 24
},
{
"id": 6,
"title": "&",
"sendName": "&",
"content": "您被任命为军团%d的管理",
"time": 24
},
{
"id": 7,
"title": "&",
"sendName": "&",
"content": "您已卸任军团%d的管理",
"time": 24
},
{
"id": 8,
"title": "&",
"sendName": "&",
"content": "小将军您的军团已开启boss%d请赶往支援",
"time": 24
},
{
"id": 9,
"title": "&",
"sendName": "&",
"content": "恭喜小将军军团上下一心已成功压制boss%d您在此次压制中获得如下奖励",
"time": 24
},
{
"id": 10,
"title": "&",
"sendName": "&",
"content": "小将军,您在上周军团练兵场中有奖励尚未领取,奖励如下:",
"time": 24
},
{
"id": 11,
"title": "&",
"sendName": "&",
"content": "小将军,%d赠送您一个%d请查收",
"time": 24
},
{
"id": 12,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,您在%d赛季结算奖励如下:",
"time": 24
},
{
"id": 13,
"title": "&",
"sendName": "&",
"content": "恭喜小将军,您在%d赛季最终获得了第%d名获得如下奖励",
"time": 24
},
{
"id": 14,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,您参与军团活动奖励已通过邮件发放,请查收:",
"time": 24
},
{
"id": 15,
"title": "&",
"sendName": "&",
"content": "小将军很抱歉,您在拍卖行的出价已被超过,元宝退还给您,请查收:",
"time": 24
},
{
"id": 16,
"title": "&",
"sendName": "&",
"content": "恭喜小将军,您已在拍卖行成功拍下以下物品,请查收:",
"time": 24
},
{
"id": 17,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,您昨日的拍卖分红忘记领取了,现已通过邮件发放,请查收",
"time": 24
},
{
"id": 18,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,您的背包中装备数量已满,请及时清理背包哦。溢出装备已通过邮件发放,请查收",
"time": 24
},
{
"id": 19,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,派遣任务已开始下一天的任务,前一天未完成的派遣任务已通过邮件发放,请查收",
"time": 24
},
{
"id": 20,
"title": "&",
"sendName": "&",
"content": "亲爱的小将军,以下是您未领取的【月卡】每日奖励,请查收",
"time": 24
},
{
"id": 21,
"content": "修改账号名",
"time": 24
},
{
"id": 22,
"content": "修改公会名或公会公告",
"time": 24
}
]