feat(ops): show order redeem records including FIFO secondary coupons
CI / verify (pull_request) Has been cancelled

Persist redeem allocations and surface them on HQ order detail with backfill for history.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-22 23:38:51 +08:00
parent f2303f7fb8
commit e0d3c840a2
5 changed files with 542 additions and 21 deletions
@@ -39,14 +39,56 @@ export class AdminRedeemService {
const record = await this.prisma.redeemRecord.findUnique({
where: { id },
include: {
user: true,
store: { include: { partnerAccount: { select: { id: true, companyName: true } } } },
coupon: true,
user: { select: { id: true, userNo: true, phone: true, nickname: true } },
store: {
select: {
id: true,
name: true,
cityName: true,
address: true,
partnerAccount: { select: { id: true, companyName: true } },
},
},
coupon: {
select: {
id: true,
couponNo: true,
totalAmount: true,
usedAmount: true,
balance: true,
status: true,
orderId: true,
order: { select: { id: true, orderNo: true } },
},
},
allocations: {
orderBy: { sortOrder: 'asc' },
include: {
coupon: {
select: {
id: true,
couponNo: true,
order: { select: { id: true, orderNo: true } },
},
},
},
},
payout: true,
rating: true,
},
});
if (!record) throw new NotFoundException('核销记录不存在');
return serializeBigInt(record);
return serializeBigInt({
...record,
allocations: record.allocations.map((a) => ({
couponId: a.couponId,
amount: Number(a.amount),
sortOrder: a.sortOrder,
couponNo: a.coupon.couponNo,
orderId: a.coupon.order?.id ?? null,
orderNo: a.coupon.order?.orderNo ?? null,
})),
});
}
}