🐞 fix(guild): 捐赠宝箱重复领取&领取之后展示问题修复
This commit is contained in:
@@ -4,7 +4,7 @@ import { resResult } from '../../../pubUtils/util';
|
||||
import { DATA_NAME, ITEM_CHANGE_REASON, STATUS, TASK_TYPE } from '../../../consts';
|
||||
import { DonationModel } from '../../../db/Donation';
|
||||
import { getZeroPoint, nowSeconds } from '../../../pubUtils/timeUtil';
|
||||
import { getArmyDonateBaseByLv, getArmyDonateBoxBaseById } from '../../../pubUtils/data';
|
||||
import { getArmyDonateBaseByLv, getArmyDonateBoxBaseById, getArmyDonateBoxBaseByLvAndIndex } from '../../../pubUtils/data';
|
||||
import { GuildModel } from '../../../db/Guild';
|
||||
import { handleCost, addItems } from '../../../services/role/rewardService';
|
||||
import { CHAT_SERVER, GUILD_POINT_WAYS } from '../../../consts';
|
||||
@@ -16,6 +16,7 @@ import { checkTask, checkTaskInDonate } from '../../../services/task/taskService
|
||||
import { guildInter } from '../../../pubUtils/interface';
|
||||
import { lockData } from '../../../services/redLockService';
|
||||
import { getVipDonateConsume } from '../../../services/activity/monthlyTicketService';
|
||||
import { changeReceiveBoxIdByLvAndIndex } from '../../../services/donateService';
|
||||
|
||||
export default function (app: Application) {
|
||||
new HandlerService(app, {});
|
||||
@@ -44,7 +45,9 @@ export class DonationHandler {
|
||||
}
|
||||
const { guildCode: code, donateCnt, receiveBoxs } = userGuild;
|
||||
let { donateFund, reports, donationLv } = await getDonation(code, guild);
|
||||
return resResult(STATUS.SUCCESS, { receiveBoxs, donateFund, reports, donateCnt: donateCnt || 0, donationLv });
|
||||
// 根据donationLv, 和index, 转化成对应的箱子id
|
||||
let haveGotBoxIds: number[] = changeReceiveBoxIdByLvAndIndex(receiveBoxs, donationLv);
|
||||
return resResult(STATUS.SUCCESS, { receiveBoxs: haveGotBoxIds, donateFund, reports, donateCnt: donateCnt || 0, donationLv });
|
||||
}
|
||||
/**
|
||||
* 捐献
|
||||
@@ -129,10 +132,13 @@ export class DonationHandler {
|
||||
return resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
// 捐献宝箱-每级有4个
|
||||
const TOTAL_BOX_COUNT = 4;
|
||||
// 领取限制: 一天内,相同index的箱子不允许重复领取
|
||||
// 当前要领取的箱子index
|
||||
const {index: curBoxIndex} = getArmyDonateBoxBaseById(id);
|
||||
for (let haveGotId of resReceiveBoxs) {
|
||||
if ((haveGotId % TOTAL_BOX_COUNT) === (id % TOTAL_BOX_COUNT)) {
|
||||
// 已领取箱子index
|
||||
let {index: haveGotIndex} = getArmyDonateBoxBaseById(haveGotId);
|
||||
if (haveGotIndex === curBoxIndex) {
|
||||
return resResult(STATUS.GUILD_DONATE_BOXS_IS_GOT);
|
||||
}
|
||||
}
|
||||
@@ -144,6 +150,8 @@ export class DonationHandler {
|
||||
resReceiveBoxs.push(id);
|
||||
let { receiveBoxs } = await UserGuildModel.updateInfo(roleId, { receiveBoxs: resReceiveBoxs }, {}, 'receiveBoxs');
|
||||
let goods = await addItems(roleId, roleName, sid, boxRewards, ITEM_CHANGE_REASON.DONATE_BOX);
|
||||
return resResult(STATUS.SUCCESS, { receiveBoxs, goods });
|
||||
// 根据donationLv, 和index, 转化成对应的箱子id
|
||||
let haveGotBoxIds: number[] = changeReceiveBoxIdByLvAndIndex(receiveBoxs, donationLv);
|
||||
return resResult(STATUS.SUCCESS, { receiveBoxs: haveGotBoxIds, goods });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user