训练场宝箱展示bug

This commit is contained in:
mamengke01
2021-02-06 11:55:36 +08:00
parent d9bea0444c
commit d9458ede5f
22 changed files with 246 additions and 108 deletions

View File

@@ -7,6 +7,7 @@ import { findWhere } from 'underscore';
import { MAIL_STATUS, MAIL_TEM_TYPE, MAIL_TYPE } from '../../../consts/constModules/mailConst';
import { handleCost, addItems } from '../../../services/rewardService';
import { getGmMailById } from '../../../pubUtils/gmData/gmDataUtil';
import { nowSeconds } from '../../../pubUtils/timeUtil';
export default function(app: Application) {
return new RoleHandler(app);
}
@@ -75,6 +76,7 @@ export class RoleHandler {
let { id, type, mailType } = msg;
let mailGoods = [];
let mails = [];
let nowTime: number = nowSeconds();
if (type == 1) {//单个领取
let mail;
if (mailType == MAIL_TYPE.SINGLEMAIL) {
@@ -88,38 +90,52 @@ export class RoleHandler {
} else {
return resResult(STATUS.WRONG_PARMS);
}
mails.push({id, status: MAIL_STATUS.DELETE, mailType});
mails.push({ id, status: MAIL_STATUS.RECEIVED, mailType });
if (mail.mailTemType == MAIL_TEM_TYPE.GMTYPE) {
let gmMail = getGmMailById(id, serverId);
let gmMail = await this.app.rpc.gm.gmRemote.getUseGmMailById.toServer('gm-server-1', id, serverId, nowTime);
if (!gmMail)
return resResult(STATUS.WRONG_PARMS);
mailGoods.push(...gmMail.goods);
} else {
mailGoods.push(...mail.goods);
}
} else {//一键领取
let ids;
let ids = [];
let gmMails = await this.app.rpc.gm.gmRemote.getUseMails.toServer('gm-server-1', serverId);
let groupMailRewards = await GroupMailModel.findRewardsMails(roleId);
ids = groupMailRewards.map(({_id, goods, mailTemType})=>{
groupMailRewards.map(({_id, goods, mailTemType})=>{
if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {
let gmMail = getGmMailById(id, serverId);
let gmMail = gmMails.get(id);
if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) {
return;
}
mailGoods.push(...gmMail.goods);
} else {
if (goods.length)
return;
mailGoods.push(...goods);
}
mails.push({id: _id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.GROUPMAIL});
return _id;
mails.push({id: _id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.GROUPMAIL});
ids.push(_id);
});
if (!!ids.length)
await GroupMailModel.updateMailStatus(ids, MAIL_STATUS.RECEIVED, roleId);
let mailRewards = await MailModel.findRewardsMails(roleId);
ids = mailRewards.map(({_id, goods, mailTemType})=>{
ids = [];
mailRewards.map(({_id, goods, mailTemType})=>{
if (mailTemType == MAIL_TEM_TYPE.GMTYPE) {
let gmMail = getGmMailById(id, serverId);
let gmMail = gmMails.get(id);
if (!gmMail || !gmMail.goods.length|| gmMail.endTime < nowSeconds()) {
return;
}
mailGoods.push(...gmMail.goods);
} else {
if (goods.length)
return;
mailGoods.push(...goods);
}
mails.push({id, status: MAIL_STATUS.DELETE, mailType: MAIL_TYPE.SINGLEMAIL});
return _id;
mails.push({id, status: MAIL_STATUS.RECEIVED, mailType: MAIL_TYPE.SINGLEMAIL});
ids.push(_id);
});
if (!!ids.length)
await MailModel.updateMailStatus(ids, MAIL_STATUS.RECEIVED);