获得试炼奖励
This commit is contained in:
@@ -9,6 +9,8 @@ import { STATUS } from '../consts/statusCode';
|
||||
import { deepCopy, resResult } from '../pubUtils/util';
|
||||
import { BattleRecordModel } from '../db/BattleRecord';
|
||||
import { getArmyBossRank } from '../pubUtils/data';
|
||||
import { getMailContent } from '../services/mailService';
|
||||
import { pushMail } from '../pubUtils/interface';
|
||||
/**
|
||||
*
|
||||
* @param bossInstance
|
||||
@@ -119,24 +121,17 @@ export async function bossResult(code: string, serverId: number, dataName: strin
|
||||
return b.score - a.score + a.time - b.time;
|
||||
});
|
||||
let mails = new Array<MailType>();
|
||||
let pushMessage = [];
|
||||
let pushMessage = new Array<pushMail>();
|
||||
recordRanks.forEach(async function({roleId, score}, index){
|
||||
let rankLv = index + 1;
|
||||
const doc = new MailModel();
|
||||
let goods = getArmyBossRankReward(rankLv);
|
||||
if (!goods || !goods.length)
|
||||
return;
|
||||
const mail = Object.assign(doc.toJSON(), {roleId, goods, sendName: '系统', mailId: 1, sendTime: nowSeconds(), content:'恭喜玩家获得演武台第' + rankLv +'名 奖励如下:'});
|
||||
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}]});
|
||||
}
|
||||
await getMailContent(roleId, 1, [JSON.stringify(rankLv)], goods, mails, pushMessage);
|
||||
});
|
||||
await MailModel.addMails(mails);
|
||||
pushMessage.forEach(({route, data, uids })=>{
|
||||
pinus.app.channelService.pushMessageByUids(route, resResult(STATUS.SUCCESS, {mails:data}), uids);
|
||||
pinus.app.channelService.pushMessageByUids(route, resResult(STATUS.SUCCESS, { mails:data }), uids);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user