军团:添加邮件

This commit is contained in:
luying
2021-01-24 11:58:03 +08:00
parent cd7d0c7e62
commit b5d84c03e4
10 changed files with 143 additions and 43 deletions

View File

@@ -0,0 +1,24 @@
import { RewardInter } from "../pubUtils/interface";
import { MailModel } from "../db/Mail";
import { getRedis } from "./redisService";
import { pinus } from "pinus";
import { gameData } from "../pubUtils/data";
export async function sendMail(operate: number, toRoleId: string, sendName: string, params: string[], goods: RewardInter[] = []) {
let content = getContent( operate, params);
let mail = await MailModel.addMail({roleId: toRoleId, goods, sendName, mailId: 1, content});
let key = 'login_roleId_' + toRoleId;
let sid = await getRedis(key);
if (!!sid) {
pinus.app.rpc.connector.connectorRemote.pushMessage.toServer(sid, toRoleId, 'onMailsAdd', [mail]);
}
}
export function getContent(operate: number, params: string[]) {
let content = gameData.mail.get(operate)||'%d';
for(let p of params) {
content = content.replace(/%d/, p);
}
return content
}