后台:邮件
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ import { COUNTER } from '../consts';
|
||||
import { CounterModel } from './Counter';
|
||||
import { HeroModel } from './Hero';
|
||||
import { RoleModel } from './Role';
|
||||
import { SearchEquipParam } from '@domain/backEndField/search';
|
||||
import { SearchEquipParam } from '../domain/backEndField/search';
|
||||
|
||||
export class RandSe {
|
||||
@prop({ required: true })
|
||||
|
||||
+5
-6
@@ -5,7 +5,8 @@ import BaseModel from './BaseModel';
|
||||
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';
|
||||
import { SearchMailParam } from '../domain/backEndField/search';
|
||||
import { UpdateMailParams } from '../domain/backEndField/params';
|
||||
|
||||
class Reward {
|
||||
@prop({ required: true })
|
||||
@@ -14,7 +15,7 @@ class Reward {
|
||||
count: number;
|
||||
}
|
||||
|
||||
class Receiver {
|
||||
export class Receiver {
|
||||
@prop({ required: true })
|
||||
env: string;
|
||||
@prop({ required: true })
|
||||
@@ -66,9 +67,6 @@ export default class GMMail extends BaseModel {
|
||||
@prop({ required: true })
|
||||
mailType: GM_MAIL_TYPE; // 收件人类型
|
||||
|
||||
@prop({ required: true })
|
||||
env: string; // 大区环境变量
|
||||
|
||||
@prop({ required: true, type: Receiver, _id: false })
|
||||
receivers: Receiver[];
|
||||
|
||||
@@ -81,7 +79,8 @@ export default class GMMail extends BaseModel {
|
||||
@prop({ required: true })
|
||||
status: GM_MAIL_STATUS; // 邮件状态
|
||||
|
||||
public static async addMail(params: GMMailTypeParam, uid = 1) {
|
||||
|
||||
public static async addMail(params: UpdateMailParams, uid = 1) {
|
||||
const doc = new GMMailModel();
|
||||
let mail = Object.assign(doc.toJSON(), params);
|
||||
let result: GMMailType = await GMMailModel.findOneAndUpdate({ _id: mail._id }, { $set: {...mail, updatedBy: uid}, $setOnInsert: { createdBy: uid } }, {upsert: true, new: true}).lean();
|
||||
|
||||
+5
-1
@@ -362,12 +362,16 @@ export default class Role extends BaseModel {
|
||||
const role: RoleType = await RoleModel.findOne({ roleId }).select(select).lean({ getters, virtuals });
|
||||
return role;
|
||||
}
|
||||
|
||||
public static async findByRoleIds(roleIds: string[], select?: string, getters = false, virtuals = true) {
|
||||
const role: RoleType[] = await RoleModel.find({ roleId: { $in: roleIds } }).select(select).lean({ getters, virtuals });
|
||||
return role;
|
||||
}
|
||||
|
||||
public static async findByRoleName(roleName: string, select?: string, getters = false, virtuals = true) {
|
||||
const role: RoleType = await RoleModel.findOne({ roleName }).select(select).lean({ getters, virtuals });
|
||||
return role;
|
||||
}
|
||||
|
||||
public static async createRole(uid: number, serverId: number, roleInfo: { roleId: string; roleName: string; seqId: number; code: string, lv?: number, exp?: number }, lean = true) {
|
||||
const user = await User.findUserByUid(uid);
|
||||
if (!user) return null;
|
||||
|
||||
@@ -87,6 +87,11 @@ export default class Serverlist extends BaseModel {
|
||||
return server;
|
||||
}
|
||||
|
||||
public static async findByServerIds(serverIds: number[]) {
|
||||
let servers: ServerlistType[] = await ServerlistModel.find({ id: { $in: serverIds } }).select('medianCe activityGroupId').lean({ getters: true, virtuals: true });
|
||||
return servers;
|
||||
}
|
||||
|
||||
public static async updateByServerId(serverId: number, update: ServerlistUpdate) {
|
||||
let server: ServerlistType = await ServerlistModel.findOneAndUpdate({ id: serverId }, { $set: update }).lean({ getters: true, virtuals: true });
|
||||
return server;
|
||||
|
||||
@@ -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,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;
|
||||
|
||||
@@ -76,7 +76,8 @@ export class MailParam {
|
||||
}
|
||||
|
||||
setContent(mail: MailType|GroupMailType|ServerMailType) {
|
||||
let { contentId = 0, params, goods, sendName } = mail;
|
||||
let { contentId = 0, goods, sendName } = mail;
|
||||
let params = []
|
||||
let dicMail = gameData.mail.get(contentId);
|
||||
if(!dicMail) dicMail = gameData.mail.get(0);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user