🐞 fix(guild): 练兵场-挑战奖励不能重复领取

This commit is contained in:
dingchaolin
2023-03-07 20:25:15 +08:00
parent bf2a409a93
commit 94b75fbc1b
3 changed files with 38 additions and 12 deletions

View File

@@ -80,7 +80,17 @@ export class GuildTrainHandler {
if (!userGuild)
return resResult(STATUS.WRONG_PARMS);
const { guildCode: code, trainBoxRewards = []} = userGuild;
let resTrainBoxs = await getTrainBoxRewardsResultWithoutAlreadyGeted(code, trainBoxRewards);
let alreadyGetTrainBoxReards: { [hid: number]: string[] } = {}; // {英雄id:[军团id]}
trainBoxRewards.forEach(item => {
if (typeof item != 'object' || !item.hid || !item.guildCode) {
return;
}
if (!alreadyGetTrainBoxReards[item.hid]) {
alreadyGetTrainBoxReards[item.hid] = [];
}
alreadyGetTrainBoxReards[item.hid].push(item.guildCode);
});
let resTrainBoxs = await getTrainBoxRewardsResultWithoutAlreadyGeted(code, alreadyGetTrainBoxReards);
return resResult(STATUS.SUCCESS, { trainBoxRewards: resTrainBoxs });
}
/**
@@ -309,7 +319,7 @@ export class GuildTrainHandler {
let goods = await addItems(roleId, roleName, sid, [good], ITEM_CHANGE_REASON.TRAIN_BOX_REWARD);
let resGuildTrain = await GuildTrainModel.receiveBoxByIndex(code, roleId, trainId, hid, index, good);
let resUserGuild = await UserGuildModel.receiveTrainBoxRewards(roleId, trainId);
let resUserGuild = await UserGuildModel.receiveTrainBoxRewards(roleId, hid, resGuildTrain.guildCode);
res.releaseCallback();//解锁
if (!resGuildTrain || !resUserGuild) {