获得试炼奖励

This commit is contained in:
mamengke01
2021-02-02 14:42:44 +08:00
parent ec870dbd2e
commit 5da98956b9
7 changed files with 64 additions and 27 deletions
+19 -4
View File
@@ -1,8 +1,11 @@
import { RewardInter } from "../pubUtils/interface";
import { MailModel } from "../db/Mail";
import { RewardInter, pushMail } from "../pubUtils/interface";
import { MailModel, MailType } from "../db/Mail";
import { getRedis } from "./redisService";
import { pinus } from "pinus";
import { gameData } from "../pubUtils/data";
import { nowSeconds } from '../pubUtils/timeUtil';
import { STATUS } from '../consts/statusCode';
import { resResult } from '../pubUtils/util';
export async function sendMail(operate: number, toRoleId: string, sendName: string = '系统', params: string[] = [], goods: RewardInter[] = []) {
let content = getContent( operate, params);
@@ -11,7 +14,7 @@ export async function sendMail(operate: number, toRoleId: string, sendName: stri
let key = 'login_roleId_' + toRoleId;
let sid = await getRedis(key);
if (!!sid) {
pinus.app.rpc.connector.connectorRemote.pushMessage.toServer(sid, toRoleId, 'onMailsAdd', [mail]);
pinus.app.channelService.pushMessageByUids('onMailsAdd', resResult(STATUS.SUCCESS, { mails:[mail] }), [{uid: toRoleId, sid}]);
}
}
@@ -21,4 +24,16 @@ export function getContent(operate: number, params: string[]) {
content = content.replace(/%d/, p);
}
return content
}
}
export async function getMailContent(roleId: string, operate: number, params: string[], goods:RewardInter[], mails:MailType[], pushMessage:pushMail[], sendName: string = '系统') {
const doc = new MailModel();
let content = getContent( operate, params);
const mail = Object.assign(doc.toJSON(), {roleId, goods, sendName, mailId: 1, sendTime: nowSeconds(), content});
mails.push(mail);
let key = 'login_roleId_' + roleId;
let sid = await getRedis(key);
if (!!sid) {
pushMessage.push({route: 'onMailsAdd', data:[mail], uids: [{uid:roleId, sid}]});
}
}