Files
ZYZ/game-server/app/servers/gm/handler/gmMailHandler.ts
2021-12-01 11:30:25 +08:00

48 lines
2.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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';
import { CreateMailParams } from '../../../domain/backEndField/params';
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);
}
}