🐞 fix(guild): 试炼挑战奖励领取过的不允许再领

This commit is contained in:
dingchaolin
2023-03-07 16:31:53 +08:00
parent 8725d7990e
commit 50f730beae
3 changed files with 60 additions and 6 deletions
@@ -60,6 +60,39 @@ export async function getTrainBoxRewardsResult(guildCode: string) {
return resTrainBoxs
}
/**
* 领过的试炼宝箱不允许再领
*
* @export
* @param {string} guildCode
* @param {number[]} receivedTrainBox
* @return {*}
*/
export async function getTrainBoxRewardsResultWithoutAlreadyGeted(guildCode: string, receivedTrainBox:number[]) {
let guildTrains = await GuildTrainModel.findGuildTrain(guildCode);//获得未失效的宝箱奖励
let resTrainBoxs = [];
guildTrains.forEach(({ trainInstances, trainId }) => {
let { trainInstances: instances } = getArmyTrainJuDian(trainId);
let flag = false;
let boxRewards = [];
trainInstances.map(({ hid, progress, endTime, trainBoxs }) => {
let isComplete = false;
let instance = findWhere(instances, { hid });
if (progress >= instance.progress) {
isComplete = true;
if (endTime > nowSeconds())
flag = true;
}
boxRewards.push({ hid, recordBoxs: trainBoxs, trainId, endTime, isComplete });
});
if (flag && (receivedTrainBox.indexOf(trainId) == -1)) {
resTrainBoxs.push({ trainId, boxRewards });
}
})
return resTrainBoxs
}
/**
* 获得未失效的试炼宝箱奖励
* @param guildTrain