邮件 活跃度下发
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
import {Application, BackendSession} from 'pinus';
|
||||
import {Application, BackendSession, pinus} from 'pinus';
|
||||
import { RoleModel } from '../../../db/Role';
|
||||
import { EventRecordModel } from '../../../db/EventRecord';
|
||||
import { getEvent } from '../../../services/eventSercive';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts/statusCode';
|
||||
|
||||
|
||||
import { GMMailModel } from '../../../db/GMMail';
|
||||
import { setGmMails } from '../../../pubUtils/gmData/gmDataUtil';
|
||||
export default function(app: Application) {
|
||||
return new GmHandler(app);
|
||||
}
|
||||
@@ -70,7 +70,6 @@ export class GmHandler {
|
||||
channel.add(roleId, sid);
|
||||
}
|
||||
|
||||
|
||||
let tsid = channel.getMember(roleId)['sid'];
|
||||
channelService.pushMessageByUids(eventName, resResult(STATUS.SUCCESS, content), [{
|
||||
uid: roleId,
|
||||
@@ -78,4 +77,10 @@ export class GmHandler {
|
||||
}]);
|
||||
return resResult(STATUS.SUCCESS, { msg: content });
|
||||
}
|
||||
|
||||
async addMail(msg: { endTime: number, serverId: number, sendName: string, content: string, goods, sendRoles:[{roleId: string, status: number}], gmMailType: number, sendTime: number, }) {
|
||||
let {sendRoles, endTime, content, sendName, gmMailType, sendTime, goods, serverId} = msg;
|
||||
let mail = await GMMailModel.addMail({serverId, sendRoles, sendName, endTime, content, gmMailType, sendTime, goods});
|
||||
setGmMails([mail]);
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
import { Application, ChannelService, FrontendSession, RemoterClass } from 'pinus';
|
||||
import { Application, ChannelService } from 'pinus';
|
||||
import { resResult } from '../../../pubUtils/util';
|
||||
import { STATUS } from '../../../consts';
|
||||
|
||||
import { setGmMails, getGmMailById, getGmMails } from '../../../pubUtils/gmData/gmDataUtil';
|
||||
import { MAIL_TYPE, MAIL_TEM_TYPE } from "../../../consts/constModules/mailConst";
|
||||
import { mailData } from "../../../pubUtils/interface";
|
||||
import { getContent } from '../../../services/mailService';
|
||||
import { findWhere } from 'underscore';
|
||||
export default function (app: Application) {
|
||||
return new ChatRemote(app);
|
||||
return new GMRemote(app);
|
||||
}
|
||||
|
||||
// rpc 定义挪到单独的定义文件(user.rpc.define.ts)。解决ts-node 有可能找不到定义的问题。
|
||||
@@ -13,11 +17,11 @@ export default function (app: Application) {
|
||||
// declare global {
|
||||
// interface UserRpc {
|
||||
// chat: {
|
||||
// chatRemote: RemoterClass<FrontendSession, ChatRemote>;
|
||||
// GMRemote: RemoterClass<FrontendSession, GMRemote>;
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
export class ChatRemote {
|
||||
export class GMRemote {
|
||||
|
||||
constructor(private app: Application) {
|
||||
this.app = app;
|
||||
@@ -91,4 +95,47 @@ export class ChatRemote {
|
||||
};
|
||||
channel.pushMessage('onLeave', resResult(STATUS.SUCCESS, param));
|
||||
}
|
||||
|
||||
public async refreshGmMails(mails:[any]) {
|
||||
setGmMails(mails);
|
||||
}
|
||||
|
||||
public async getMailInfos(roleId: string, serverId: number, mails: [any], groupMails: [any]) {
|
||||
let list: mailData[] = [];
|
||||
mails.map(async function({ mailId, goods, sendTime, params, status, _id, mailTemType, sendName, endTime}) {
|
||||
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
|
||||
let { content } = getContent(parseInt(mailId), params);
|
||||
if (!content)
|
||||
return;
|
||||
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
|
||||
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
|
||||
let gmMail = getGmMailById(mailId, serverId);
|
||||
if (!gmMail)
|
||||
return;
|
||||
let { goods, sendTime, content, endTime, sendName } = gmMail;
|
||||
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
|
||||
}
|
||||
});
|
||||
groupMails.map(async function({ mailId, goods, sendTime, endTime, params, sendRoles, _id, mailTemType, sendName }) {
|
||||
let { status } = findWhere(sendRoles, {roleId});
|
||||
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
|
||||
let { content } = getContent( parseInt(mailId), params);
|
||||
if (!content)
|
||||
return;
|
||||
list.push({ id: _id, mailId, goods, sendTime, content, endTime, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
|
||||
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
|
||||
let gmMail = getGmMailById(mailId, serverId);
|
||||
if (!gmMail)
|
||||
return;
|
||||
let { goods, sendTime, content, endTime, sendName } = gmMail;
|
||||
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
|
||||
}
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
public async getMails(updatedMailAt: number, serverId: number) {
|
||||
let gmMails = getGmMails(updatedMailAt, serverId);
|
||||
return gmMails;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user