fix: 新手礼包接口报错

This commit is contained in:
guanchao
2026-10-12 18:18:42 +08:00
parent cd6cc03db8
commit 2e2c9a9242
+12 -5
View File
@@ -166,11 +166,18 @@ export async function refreshStarterPack(user: any, trigger = false, collection
register_time: user.register_time ?? null,
levelAmount: user.levelAmount ?? null,
...(options?.reason === "low_coin" ? { coinAmount: user.coinAmount ?? null } : {}),
...(options?.reason === 'low_health' ? { healthAmount: user.healthAmount ?? null,
userPowerTime: user.userPowerTime ?? null, healthtimestamp: user.healthtimestamp ?? null } : {}),
...(options?.reason === 'low_props' ? { freezeAmount: user.freezeAmount ?? null,
hammerAmount: user.hammerAmount ?? null, magicAmount: user.magicAmount ?? null } : {}),
}).update(patch);
...(options?.reason === 'low_health' ? {
healthAmount: user.healthAmount ?? null,
userPowerTime: user.userPowerTime ?? null, healthtimestamp: user.healthtimestamp ?? null
} : {}),
...(options?.reason === 'low_props' ? {
freezeAmount: user.freezeAmount ?? null,
hammerAmount: user.hammerAmount ?? null, magicAmount: user.magicAmount ?? null
} : {}),
}).update({
...patch,
starterPackOffer: db.command.set(patch.starterPackOffer),
});
const fresh = await db.collection(collection).where({ _id: user._id }).getOne();
if (!fresh.data) throw new Error('未获取到玩家数据');
user = fresh.data;