fix: 战令结算时未覆盖到未解锁奖励导致无法正常领取结算奖励
This commit is contained in:
parent
a0345698d2
commit
ca9c8d22e2
|
|
@ -46,8 +46,10 @@ export function expiredSnapshots(user: any, now = Date.now()): any {
|
||||||
for (const key of Object.keys(stages)) {
|
for (const key of Object.keys(stages)) {
|
||||||
const stage = stages[key], end = Number(stage?.time || key);
|
const stage = stages[key], end = Number(stage?.time || key);
|
||||||
if (!end || end > now || result[String(end)]) continue;
|
if (!end || end > now || result[String(end)]) continue;
|
||||||
result[String(end)] = { end, stage: copy({ ...stage, time: String(end) }), frozenAt: now,
|
result[String(end)] = {
|
||||||
claimed: false, emptySeen: false, offer: 'unused' };
|
end, stage: copy({ ...stage, time: String(end) }), frozenAt: now,
|
||||||
|
claimed: false, emptySeen: false, offer: 'unused'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
@ -87,8 +89,10 @@ async function flushPending(user: any, table: string): Promise<any> {
|
||||||
* can commit until that receipt has been durably copied to the independent archive. */
|
* can commit until that receipt has been durably copied to the independent archive. */
|
||||||
export async function commitUserSettlement(user: any, row: any, patch: any, expected: any, table = 'users', unset: any = {}): Promise<any> {
|
export async function commitUserSettlement(user: any, row: any, patch: any, expected: any, table = 'users', unset: any = {}): Promise<any> {
|
||||||
const revision = (Number(user.passSettlementRevision) || 0) + 1;
|
const revision = (Number(user.passSettlementRevision) || 0) + 1;
|
||||||
const written = await collection(table).updateOne({ ...expected, _id: user._id,
|
const written = await collection(table).updateOne({
|
||||||
passSettlementRevision: user.passSettlementRevision ?? null, passSettlementPending: null }, {
|
...expected, _id: user._id,
|
||||||
|
passSettlementRevision: user.passSettlementRevision ?? null, passSettlementPending: null
|
||||||
|
}, {
|
||||||
$set: { ...patch, passSettlementRevision: revision, passSettlementPending: { revision, row } },
|
$set: { ...patch, passSettlementRevision: revision, passSettlementPending: { revision, row } },
|
||||||
...(Object.keys(unset).length ? { $unset: unset } : {})
|
...(Object.keys(unset).length ? { $unset: unset } : {})
|
||||||
});
|
});
|
||||||
|
|
@ -184,7 +188,7 @@ export async function mutateSettlement(user: any, body: any, table = 'users'): P
|
||||||
rewards = normalizeRewards(body.rewards);
|
rewards = normalizeRewards(body.rewards);
|
||||||
if (body.claimFlags) for (const lane of purchase ? ['passCheck'] : ['free', 'passCheck']) {
|
if (body.claimFlags) for (const lane of purchase ? ['passCheck'] : ['free', 'passCheck']) {
|
||||||
const flags = body.claimFlags[lane];
|
const flags = body.claimFlags[lane];
|
||||||
if (!Array.isArray(flags) || flags.length > 10000 || flags.some(v => v !== 0 && v !== 1 && v !== null)) fail('领取记录无效', 400);
|
if (!Array.isArray(flags) || flags.length > 10000 || flags.some(v => v !== 0 && v !== -1 && v !== 1 && v !== null)) fail('领取记录无效', 400);
|
||||||
next.stage[lane] = [...(next.stage[lane] || [])];
|
next.stage[lane] = [...(next.stage[lane] || [])];
|
||||||
flags.forEach((v, i) => { if (v === 0) next.stage[lane][i] = 0; });
|
flags.forEach((v, i) => { if (v === 0) next.stage[lane][i] = 0; });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user