训练场宝箱展示bug

This commit is contained in:
mamengke01
2021-02-06 11:56:18 +08:00
parent d9bea0444c
commit d9458ede5f
22 changed files with 246 additions and 108 deletions
@@ -20,6 +20,8 @@ import { lockData } from '../../../services/redLockService';
import { DATA_NAME } from '../../../consts/dataName';
import { openGuildRefine } from '../../../services/guildRefineService';
import { unlockTrain } from '../../../services/guildTrainService';
import { removeBossRank } from '../../../services/guildBossService';
import { removeTrainRank } from '../../../services/guildTrainService';
export default function (app: Application) {
return new GuildHandler(app);
}
@@ -601,7 +603,9 @@ export class GuildHandler {
const guild = await GuildModel.quit(code, roleId, serverId, role.ce, userGuild.auth == GUILD_AUTH.MANAGER);
if(!guild) return resResult(STATUS.GUILD_QUIT_ERROR);
//删除排名信息
await removeBossRank(code, roleId);
await removeTrainRank(code, roleId, guild.trainId);
// 添加动态
const rec = await GuildRecModel.createGuildRec(roleId, code, GUILD_REC_TYPE.QUIT_GUILD, [roleName]);
this.app.rpc.chat.guildRemote.addRec.toServer(CHAT_SERVER,rec);
@@ -635,6 +639,10 @@ export class GuildHandler {
const guild = await GuildModel.quit(code, memberRoleId, serverId, role.ce, userGuild.auth == GUILD_AUTH.MANAGER);
if(!guild) return resResult(STATUS.GUILD_KICK_ERROR);
//删除排名信息
await removeBossRank(code, roleId);
await removeTrainRank(code, roleId, guild.trainId);
this.app.rpc.chat.guildRemote.memberQuit.toServer(CHAT_SERVER,code, roleId, guild);
@@ -85,13 +85,14 @@ export class GuildTrainHandler {
let { trainInstances: instances } = getArmyTrainJuDian(trainId);
let flag = false;
let boxRewards = [];
let isComplete = false;
trainInstances.map(({hid, progress, endTime, trainBoxs})=>{
let instance = findWhere(instances, { hid });
let isComplete = false;
if ( progress >= instance.progress)
if ( progress >= instance.progress) {
isComplete = true;
if (endTime > nowSeconds())
flag = true;
if (endTime > nowSeconds())
flag = true;
}
boxRewards.push({hid, recordBoxs: trainBoxs, trainId, endTime, isComplete});
});
if (flag) {
@@ -150,13 +151,13 @@ export class GuildTrainHandler {
return resResult(STATUS.WRONG_PARMS);
const { guildCode: code } = userGuild;
const battleRecord = await BattleRecordModel.getBattleRecordByCode(battleCode, true);
// if (!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId || battleRecord.record.guildCode != code) {
// return resResult(STATUS.WRONG_PARMS);
// }
if (!battleRecord || battleRecord.status != 0 || roleId != battleRecord.roleId || battleRecord.record.guildCode != code) {
return resResult(STATUS.WRONG_PARMS);
}
let time = Math.floor(battleRecord.createdAt.getTime()/1000);
// if (userGuild.trainCount - 1 < 0) {
// return resResult(STATUS.WRONG_PARMS);
// }
if (userGuild.trainCount - 1 < 0) {
return resResult(STATUS.WRONG_PARMS);
}
if (time < getCurHourPoint(REFRESH_HOUR) && nowSeconds() > getCurHourPoint(REFRESH_HOUR)) {
return resResult(STATUS.GUILD_TRAIN_IS_RESETED);//关卡已经重置
@@ -87,7 +87,7 @@ export class WishPoolHandler {
count = wishGoodsHero.count;
}
const id = genCode(6);
let { wishGoods: resWishGoods } = await UserGuildModel.pushAndUpdate(roleId, {}, { wishGoods: { type, goodId, count, receiveCnt: 0, drawCnt: 0, id} }, 'wishGoods');
let { wishGoods: resWishGoods } = await UserGuildModel.pushAndUpdate(roleId, {}, { wishGoods: { type, goodId, count, receiveCnt: 0, drawCnt: 0, id, donateNames:[]} }, 'wishGoods');
return resResult(STATUS.SUCCESS, { wishGoods: resWishGoods });
}
@@ -118,7 +118,7 @@ export class WishPoolHandler {
if (wishGood.receiveCnt >= wishGood.count)
return resResult(STATUS.HAS_RECEIVE_WISH_GOOD);//已经收到
let { wishDntCnt } = await UserGuildModel.donateGoods(dntRoleId, 1, 'wishDntCnt');
let { wishGoods: resWishGoods } = await UserGuildModel.donateUpdate(wishRoleId, id, 'wishGoods');
let { wishGoods: resWishGoods } = await UserGuildModel.donateUpdate(wishRoleId, dntRoleName, id, 'wishGoods');
let key = 'login_roleId_' + wishRoleId;
let sid = await getRedis(key);
let goods = await addItems(wishRoleId, role.roleName , sid , [{ id : wishGood.goodId, count: 1 }]);
@@ -78,7 +78,7 @@ export class GmHandler {
return resResult(STATUS.SUCCESS, { msg: content });
}
async addMail(msg: { endTime: number, serverId: number, sendName: string, content: string, goods, sendRoles:[{roleId: string, status: number}], gmMailType: number, sendTime: number, }) {
async addMail(msg: { endTime: number, serverId: number, sendName: string, content: string, goods, sendRoles:[{roleId: string, status: number}], gmMailType: number, sendTime: number }) {
let {sendRoles, endTime, content, sendName, gmMailType, sendTime, goods, serverId} = msg;
let mail = await GMMailModel.addMail({serverId, sendRoles, sendName, endTime, content, gmMailType, sendTime, goods});
setGmMails([mail]);
+27 -7
View File
@@ -1,11 +1,12 @@
import { Application, ChannelService } from 'pinus';
import { resResult } from '../../../pubUtils/util';
import { STATUS } from '../../../consts';
import { setGmMails, getGmMailById, getGmMails } from '../../../pubUtils/gmData/gmDataUtil';
import { setGmMails, getGmMailById, getGmMails, getGmUseMails } from '../../../pubUtils/gmData/gmDataUtil';
import { MAIL_TYPE, MAIL_TEM_TYPE } from "../../../consts/constModules/mailConst";
import { mailData } from "../../../pubUtils/interface";
import { getContent } from '../../../services/mailService';
import { findWhere } from 'underscore';
import { nowSeconds } from '../../../pubUtils/timeUtil';
export default function (app: Application) {
return new GMRemote(app);
}
@@ -102,33 +103,38 @@ export class GMRemote {
public async getMailInfos(roleId: string, serverId: number, mails: [any], groupMails: [any]) {
let list: mailData[] = [];
let nowTime = nowSeconds();
mails.map(async function({ mailId, goods, sendTime, params, status, _id, mailTemType, sendName, endTime}) {
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
if (endTime < nowTime)
return;
let { content } = getContent(parseInt(mailId), params);
if (!content)
return;
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
let gmMail = getGmMailById(mailId, serverId);
let gmMail = getGmMailById(mailId, serverId, nowTime);
if (!gmMail)
return;
let { goods, sendTime, content, endTime, sendName } = gmMail;
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.SINGLEMAIL, sendName });
}
});
groupMails.map(async function({ mailId, goods, sendTime, endTime, params, sendRoles, _id, mailTemType, sendName }) {
let { status } = findWhere(sendRoles, {roleId});
if (mailTemType == MAIL_TEM_TYPE.GAMEMAIL) { //模板邮件
if (endTime < nowTime)
return;
let { content } = getContent( parseInt(mailId), params);
if (!content)
return;
list.push({ id: _id, mailId, goods, sendTime, content, endTime, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
list.push({ id: _id, goods, sendTime, content, endTime, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
} else if (mailTemType == MAIL_TEM_TYPE.GMTYPE) { //系统邮件
let gmMail = getGmMailById(mailId, serverId);
let gmMail = getGmMailById(mailId, serverId, nowTime);
if (!gmMail)
return;
let { goods, sendTime, content, endTime, sendName } = gmMail;
list.push({ id: _id, mailId, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
list.push({ id: _id, goods, sendTime, endTime, content, status, mailType: MAIL_TYPE.GROUPMAIL, sendName });
}
});
return list;
@@ -138,4 +144,18 @@ export class GMRemote {
let gmMails = getGmMails(updatedMailAt, serverId);
return gmMails;
}
public async getUseMails(serverId: number) {
let gmMails = getGmUseMails(serverId);
return gmMails;
}
/**
*
* @param mailId
* @param serverId
* @param nowTime
*/
public getUseGmMailById(mailId: string, serverId: number, nowTime: number ) {
let gmMail = getGmMailById(mailId, serverId, nowTime);
return gmMail;
}
}
@@ -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);