核销代码

This commit is contained in:
2026-07-06 22:10:45 +08:00
parent 047cf879f8
commit 386ee9e754
6 changed files with 191 additions and 16 deletions
@@ -100,7 +100,10 @@ export class BenefitService {
const coupon = await tx.benefitCoupon.findUniqueOrThrow({
where: { id: BigInt(alloc.couponId) },
});
const allocAmount = alloc.amount;
const allocAmount = Number(alloc.amount);
if (!Number.isFinite(allocAmount) || allocAmount <= 0) {
throw new Error('BENEFIT_ALLOC_INVALID');
}
const updated = await tx.benefitCoupon.updateMany({
where: { id: coupon.id, version: coupon.version, balance: { gte: allocAmount } },
data: {