优化助力逻辑

This commit is contained in:
CounterFire2023 2024-04-23 19:43:01 +08:00
parent fe75d261d5
commit 68e679cdd2

View File

@ -251,10 +251,14 @@ class BoxController extends BaseController {
throw new ZError(16, 'user enhance times exceed')
}
const score = chest.bounsCfg[chest.bonusUsers.length] || chest.bounsCfg[chest.bounsCfg.length - 1]
let scoreTotal = 0
for (let i = 0, l = Math.min(chest.bonusUsers.length, chest.bounsCfg.length - 1); i <= l; i++) {
scoreTotal += chest.bounsCfg[i]
}
let doc = await ActivityChest.findOneAndUpdate(
{ _id: chest.id },
{
$inc: { scoreBonus: score },
scoreBonus: scoreTotal,
$push: { bonusUsers: uid },
},
)