后台:邮件审核人
This commit is contained in:
@@ -240,6 +240,7 @@ export class EntryHandler {
|
||||
session.set('roleName', user.name);
|
||||
session.set('eventStatus', 0);
|
||||
session.set('sid', self.app.get('serverId'));
|
||||
session.push('uid', () => { });
|
||||
session.push('sid', () => { });
|
||||
session.push('roleId', () => { });
|
||||
session.push('roleName', () => { });
|
||||
|
||||
@@ -7,7 +7,7 @@ import { STATUS } from '../../../consts/statusCode';
|
||||
import { GMMailModel } from '../../../db/GMMail';
|
||||
import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { SendMailFun } from '../../../services/mailService';
|
||||
import { GM_MAIL_TYPE } from '../../../consts';
|
||||
import { GM_MAIL_STATUS, GM_MAIL_TYPE, MAIL_TIME_TYPE } from '../../../consts';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
import { MarqueeModel } from '../../../db/Marquee';
|
||||
import { ServerlistModel } from '../../../db/Serverlist';
|
||||
@@ -22,6 +22,7 @@ import { GuildActivityCityModel } from '../../../db/GuildActivityCity';
|
||||
import { GuildActivityRecordModel } from '../../../db/GuildActivityRec';
|
||||
import { getTimeFunM } from '../../../pubUtils/timeUtil';
|
||||
import { sendUngotDividend } from '../../../services/auctionService';
|
||||
import moment = require('moment');
|
||||
let timer: NodeJS.Timer;
|
||||
export default function (app: Application) {
|
||||
return new GmHandler(app);
|
||||
@@ -31,6 +32,44 @@ export class GmHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
|
||||
//对接gm后台,下发邮件
|
||||
async sendMail(msg: { id: string, isPass: boolean }, session: BackendSession) {
|
||||
const uid: number = session.get('uid')
|
||||
let { id, isPass } = msg;
|
||||
let gmmail = await GMMailModel.getGmMailById(id);
|
||||
if(!gmmail) return resResult(STATUS.GM_MAIL_NOT_FOUND);
|
||||
let { receivers, mailType, status, timeType, startTime, circleHour, circleDay } = gmmail;
|
||||
if(status != GM_MAIL_STATUS.CREATE) {
|
||||
return resResult(STATUS.GM_MAIL_HAS_SENT);
|
||||
}
|
||||
if(isPass) {
|
||||
let f = new SendMailFun();
|
||||
await f.setWithGmMail(gmmail);
|
||||
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) {
|
||||
let roleIds = receivers.map(cur => cur.roleId);
|
||||
await f.sendToUsers(mailType, roleIds);
|
||||
} else {
|
||||
let serverIds = receivers.map(cur => cur.serverId);
|
||||
await f.sendToServer(serverIds);
|
||||
}
|
||||
// await f.saveRecord(uid);
|
||||
}
|
||||
let sendTime = '';
|
||||
if(isPass) {
|
||||
if(timeType == MAIL_TIME_TYPE.IMMEDIATE) {
|
||||
sendTime = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||
} else if (timeType == MAIL_TIME_TYPE.DELAY) {
|
||||
sendTime = moment(startTime * 1000).format('YYYY-MM-DD HH:mm:ss');
|
||||
} else if (timeType == MAIL_TIME_TYPE.CIRCLE) {
|
||||
sendTime = (circleDay == 0?'每天': '每周'+circleDay) + ' ' + circleHour;
|
||||
}
|
||||
}
|
||||
await GMMailModel.updateMailById(id, { status: isPass?GM_MAIL_STATUS.PASS: GM_MAIL_STATUS.NOT_PASS, viewAt: new Date(), viewBy: uid, sendTime }, uid);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async reloadResource(msg: {}, session: BackendSession) {
|
||||
try {
|
||||
let activityServers = this.app.getServersByType('activity');
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import { Application, BackendSession, pinus } from 'pinus';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { getEvent } from '../../../services/eventSercive';
|
||||
import { getRandSingleEelm, resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
import { GMMailModel } from '../../../db/GMMail';
|
||||
import { delGuildActivityRank, getRoleOnlineInfo } from '../../../services/redisService';
|
||||
import { SendMailFun } from '../../../services/mailService';
|
||||
import { GM_MAIL_TYPE } from '../../../consts';
|
||||
import { RewardInter } from '../../../pubUtils/interface';
|
||||
|
||||
export default function (app: Application) {
|
||||
return new GmMailHandler(app);
|
||||
}
|
||||
|
||||
export class GmMailHandler {
|
||||
constructor(private app: Application) {
|
||||
}
|
||||
|
||||
//对接gm后台,下发邮件
|
||||
async sendMail(msg: { id: string, mailType: number, roleIds?: string[], serverIds?: number[] }, session: BackendSession) {
|
||||
const uid: number = session.get('uid')
|
||||
let { id, mailType, roleIds, serverIds } = msg;
|
||||
let f = new SendMailFun();
|
||||
await f.setWithGmMail(id);
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) {
|
||||
await f.sendToUsers(mailType, roleIds);
|
||||
} else {
|
||||
await f.sendToServer(serverIds);
|
||||
}
|
||||
await f.saveRecord(uid);
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
async sendWithContent(msg: { contentId: number, mailType: number, params: { params?: string[], sendName?: string, goods?: RewardInter[], endTime?: number }, roleIds?: string[], serverIds?: number[] }, session: BackendSession) {
|
||||
let { contentId, mailType, roleIds, serverIds, params } = msg;
|
||||
let f = new SendMailFun();
|
||||
f.setWithContentId(contentId, params);
|
||||
if (mailType == GM_MAIL_TYPE.SINGLE || mailType == GM_MAIL_TYPE.GROUP) {
|
||||
await f.sendToUsers(mailType, roleIds);
|
||||
} else {
|
||||
await f.sendToServer(serverIds);
|
||||
}
|
||||
return resResult(STATUS.SUCCESS);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { Application, ChannelService, HandlerService, } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
import { setGmMails, getGmMailById, getGmMails, getGmUseMails } from '../../../pubUtils/gmData/gmDataUtil';
|
||||
import { mongoose } from '@typegoose/typegoose';
|
||||
const { ObjectId } = mongoose.Types;
|
||||
export default function (app: Application) {
|
||||
@@ -94,72 +93,4 @@ export class GMRemote {
|
||||
};
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public refreshGmMails(mails: [any]) {
|
||||
setGmMails(mails);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获得据上次刷新后,可以加入的邮件
|
||||
* @param updatedMailAt
|
||||
* @param serverId
|
||||
*/
|
||||
public getMailsByTime(updatedMailAt: number, serverId: number) {
|
||||
let gmMails = getGmMails(updatedMailAt, serverId);
|
||||
return gmMails;
|
||||
}
|
||||
// /**
|
||||
// * 获得可以领取的邮件奖
|
||||
// * @param serverId
|
||||
// * @param groupMailRewards
|
||||
// * @param mailRewards
|
||||
// */
|
||||
// public getUseMails(serverId: number, groupMailRewards: GroupMailType[], mailRewards: MailType[]) {
|
||||
// let nowTime = nowSeconds();
|
||||
// let mailGoods = [];
|
||||
// let mails = [];
|
||||
// let mailIds = [];
|
||||
// let groupMailIds = [];
|
||||
// groupMailRewards.map(({_id, goods, mailId, mailTemType})=>{
|
||||
// if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {//gm邮件检查是否有奖励以及是否可以领取
|
||||
// let gmMail = getGmMailById(mailId, serverId, nowTime);
|
||||
// if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) {
|
||||
// return;
|
||||
// }
|
||||
// mailGoods.push(...gmMail.goods);
|
||||
// } else {
|
||||
// if (!goods.length)//系统邮件,检查是否有奖励
|
||||
// return;
|
||||
// mailGoods.push(...goods);
|
||||
// }
|
||||
// mails.push({id: _id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.GROUPMAIL});
|
||||
// groupMailIds.push(_id);
|
||||
// });
|
||||
// mailRewards.map(({_id, goods, mailId, mailTemType})=>{
|
||||
// if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {//gm邮件检查是否有奖励以及是否可以领取
|
||||
// let gmMail = getGmMailById(mailId, serverId, nowTime);
|
||||
// if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) {
|
||||
// return;
|
||||
// }
|
||||
// mailGoods.push(...gmMail.goods);
|
||||
// } else {
|
||||
// if (!goods.length)//系统邮件,检查是否有奖励
|
||||
// return;
|
||||
// mailGoods.push(...goods);
|
||||
// }
|
||||
// mails.push({id: _id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.SINGLEMAIL});
|
||||
// mailIds.push(_id);
|
||||
// });
|
||||
// return {mailIds, groupMailIds, mails, mailGoods};
|
||||
// }
|
||||
/**
|
||||
* 通过模板mailId获得gm邮件
|
||||
* @param mailId
|
||||
* @param serverId
|
||||
* @param nowTime
|
||||
*/
|
||||
public getUseGmMailById(mailId: string, serverId: number, nowTime: number) {
|
||||
let gmMail = getGmMailById(mailId, serverId, nowTime);
|
||||
return gmMail;
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,6 @@ export async function stopMaintenance(maintenance: MaintenanceType, uid: number)
|
||||
let f = new SendMailFun();
|
||||
await f.setWithGmMail((<GMMailType>mail)._id);
|
||||
await f.sendToServer(serverIds);
|
||||
await f.saveRecord(uid);
|
||||
// await f.saveRecord(uid);
|
||||
}
|
||||
}
|
||||
@@ -8,13 +8,14 @@ import { gameData } from "../pubUtils/data";
|
||||
import { nowSeconds } from '../pubUtils/timeUtil';
|
||||
import { STATUS } from '../consts/statusCode';
|
||||
import { resResult } from '../pubUtils/util';
|
||||
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TYPE, SEND_NAME } from "../consts";
|
||||
import { GM_MAIL_TYPE, ITID, MAIL_STATUS, MAIL_TIME_TYPE, MAIL_TYPE, SEND_NAME, SEND_TITLE } from "../consts";
|
||||
import { MailParam } from '../domain/roleField/mail';
|
||||
import { GMMailType, GMMailModel } from "../db/GMMail";
|
||||
import { getGuildChannelSid, getWorldChannelSid } from "./chatChannelService";
|
||||
import { GMMailRecordModel } from "../db/GMMailRecord";
|
||||
import { BAG } from "../pubUtils/dicParam";
|
||||
import { GuildModel, GuildType } from "../db/Guild";
|
||||
import moment = require("moment");
|
||||
|
||||
/**
|
||||
* 获取邮件信息
|
||||
@@ -73,8 +74,9 @@ export async function sendMailToGuildByContent(contentId: MAIL_TYPE, guildCode:
|
||||
export class SendMailFun {
|
||||
private mailType: GM_MAIL_TYPE = GM_MAIL_TYPE.SINGLE; // 邮件类型 1-单人 2-多人 3-全服
|
||||
private contentId: MAIL_TYPE = MAIL_TYPE.SEND_MAIL; // 0-读GmMail,1以上读dicMail
|
||||
private params: string[] = [];
|
||||
private sendName: string = SEND_NAME;
|
||||
private title: string = SEND_TITLE;
|
||||
private content: string = '';
|
||||
private gmmail: GMMailType;
|
||||
private hasGoods: boolean = false; // 是否内含奖励
|
||||
private goods: RewardInter[] = []; // 发送的奖励
|
||||
@@ -86,41 +88,44 @@ export class SendMailFun {
|
||||
private serverMails: ServerMailType[] = [];
|
||||
|
||||
// 从dicMail读取数据
|
||||
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[] }) {
|
||||
public setWithContentId(contentId: MAIL_TYPE, params: { sendName?: string, params?: string[], goods?: RewardInter[] }) {
|
||||
let dicMail = gameData.mail.get(contentId);
|
||||
this.contentId = contentId;
|
||||
this.sendTime = nowSeconds();
|
||||
this.endTime = this.sendTime + dicMail?.time||0;
|
||||
this.setParam({ ...params });
|
||||
this.content = this.getContent(dicMail.content, params.params);
|
||||
if(dicMail.title) this.title = dicMail.title;
|
||||
if(dicMail.sendName) this.sendName = dicMail.sendName;
|
||||
this.hasGoods = params.goods.length > 0;
|
||||
this.goods = params.goods;
|
||||
}
|
||||
|
||||
getContent(content: string, params: string[]) {
|
||||
if(!content) content = '%d';
|
||||
for(let p of params) {
|
||||
content = content.replace(/%d/, p);
|
||||
}
|
||||
return content
|
||||
}
|
||||
|
||||
// 从GMMail表读取数据
|
||||
public async setWithGmMail(gmmailId: string) {
|
||||
// let gmmail = await GMMailModel.getGmMailById(gmmailId);
|
||||
// if(gmmail) {
|
||||
// this.gmmail = gmmail;
|
||||
// if(gmmail.useTempTime) {
|
||||
// this.sendTime = gmmail.sendTime;
|
||||
// this.endTime = gmmail.endTime;
|
||||
// } else {
|
||||
// this.sendTime = nowSeconds();
|
||||
// this.endTime = this.sendTime + (gmmail.continueHour||0) * 60 * 60;
|
||||
// }
|
||||
// this.setParam({ ...gmmail });
|
||||
// }
|
||||
}
|
||||
|
||||
private setParam(params: { sendName?: string, endTime?: number, params?: string[], goods?: RewardInter[], content?: string }) {
|
||||
if(params.sendName) this.sendName = params.sendName;
|
||||
if(params.endTime) this.endTime = params.endTime;
|
||||
if(params.content) {
|
||||
this.params.push(params.content);
|
||||
}
|
||||
if(params.params) this.params = params.params;
|
||||
if(params.goods) {
|
||||
this.hasGoods = params.goods.length > 0;
|
||||
this.goods = params.goods;
|
||||
public async setWithGmMail(gmmail: GMMailType) {
|
||||
this.gmmail = gmmail;
|
||||
this.contentId = 0;
|
||||
if(gmmail.timeType == MAIL_TIME_TYPE.IMMEDIATE) {
|
||||
this.sendTime = nowSeconds();
|
||||
} else if (gmmail.timeType == MAIL_TIME_TYPE.DELAY) {
|
||||
this.sendTime = gmmail.startTime;
|
||||
} else if (gmmail.timeType == MAIL_TIME_TYPE.CIRCLE) {
|
||||
this.sendTime = moment(moment().format('YYYY-MM-DD ' + gmmail.circleHour)).unix();
|
||||
}
|
||||
this.endTime = this.sendTime + gmmail.expire * 60 * 60;
|
||||
this.sendName = gmmail.sendName;
|
||||
this.title = gmmail.title;
|
||||
this.content = gmmail.content;
|
||||
this.hasGoods = gmmail.hasGoods;
|
||||
this.goods = gmmail.goods;
|
||||
return gmmail;
|
||||
}
|
||||
|
||||
private getCreateMailParams() {
|
||||
@@ -129,9 +134,10 @@ export class SendMailFun {
|
||||
mail: this.gmmail?._id,
|
||||
sendTime: this.sendTime,
|
||||
endTime: this.endTime,
|
||||
params: this.params,
|
||||
goods: this.goods,
|
||||
goods: this.goods,
|
||||
title: this.title,
|
||||
sendName: this.sendName,
|
||||
content: this.content,
|
||||
hasGoods: this.hasGoods
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user