feat(promo): HQ 推广码订单只计已完成并补扫码订单快链

列表与详情的订单数/转化率按 COMPLETED 实时统计;扫码、订单、事件 ID 可跳到对应页。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 12:55:19 +08:00
parent 737efb89a3
commit fccfd7abbe
15 changed files with 421 additions and 124 deletions
@@ -100,6 +100,27 @@ export class WechatTradeManageService {
remark,
}),
});
if (order.promoCodeId) {
const already = await tx.logPromoEvent.findFirst({
where: { orderId: order.id, eventType: 'ORDER' },
select: { id: true },
});
if (!already) {
await tx.commonPromoCode.update({
where: { id: order.promoCodeId },
data: { orderCount: { increment: 1 } },
});
await tx.logPromoEvent.create({
data: {
promoCodeId: order.promoCodeId,
eventType: 'ORDER',
userId: order.userId,
orderId: order.id,
clientIp: order.clientIp,
},
});
}
}
});
await this.logEvent(evt, order.id, 'SUCCESS', methodLabel);