军团:添加邮件
This commit is contained in:
24
game-server/app/services/mailService.ts
Normal file
24
game-server/app/services/mailService.ts
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user