feat(promo): HQ 推广码订单只计已完成并补扫码订单快链
列表与详情的订单数/转化率按 COMPLETED 实时统计;扫码、订单、事件 ID 可跳到对应页。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -357,25 +357,9 @@ export class TradeService {
|
||||
include: { product: true, imageResource: true },
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
await tx.commonPromoCode.update({
|
||||
where: { id: promoCodeId },
|
||||
data: { orderCount: { increment: 1 } },
|
||||
});
|
||||
}
|
||||
|
||||
return created;
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
this.promoCodeService.logPromoOrderEvent(
|
||||
promoCodeId,
|
||||
order.id,
|
||||
userId,
|
||||
location.clientIp ?? undefined,
|
||||
);
|
||||
}
|
||||
|
||||
this.analyticsService.trackOneSafe(userId, this.resolveTrackedUserClientApp(clientApp), {
|
||||
eventName: 'order_submit',
|
||||
refType: 'ORDER',
|
||||
@@ -526,6 +510,15 @@ export class TradeService {
|
||||
});
|
||||
if (!order) return;
|
||||
|
||||
if (order.status === 'COMPLETED' && order.promoCodeId) {
|
||||
await this.promoCodeService.recordCompletedOrder(
|
||||
order.promoCodeId,
|
||||
order.id,
|
||||
order.userId,
|
||||
order.clientIp ?? undefined,
|
||||
);
|
||||
}
|
||||
|
||||
if (!order.isTest) {
|
||||
const unit = order.saleUnit === 'BOX' ? '箱' : '瓶';
|
||||
const spec = (order.productSpec || '').trim();
|
||||
@@ -1593,6 +1586,15 @@ export class TradeService {
|
||||
});
|
||||
});
|
||||
|
||||
if (targetStatus === 'COMPLETED' && currentStatus !== 'COMPLETED' && order.promoCodeId) {
|
||||
await this.promoCodeService.recordCompletedOrder(
|
||||
order.promoCodeId,
|
||||
order.id,
|
||||
order.userId,
|
||||
order.clientIp ?? undefined,
|
||||
);
|
||||
}
|
||||
|
||||
// 发货信息管理:进入 SHIPPING 时向微信录入(解冻结算前置)
|
||||
if (targetStatus === 'SHIPPING' && currentStatus !== 'SHIPPING') {
|
||||
this.wechatOrderShipping.uploadForOrderSafe(orderId);
|
||||
@@ -1934,25 +1936,9 @@ export class TradeService {
|
||||
}),
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
await tx.commonPromoCode.update({
|
||||
where: { id: promoCodeId },
|
||||
data: { orderCount: { increment: 1 } },
|
||||
});
|
||||
}
|
||||
|
||||
return created;
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
this.promoCodeService.logPromoOrderEvent(
|
||||
promoCodeId,
|
||||
order.id,
|
||||
user.id,
|
||||
location.clientIp ?? undefined,
|
||||
);
|
||||
}
|
||||
|
||||
this.analyticsService.trackPartnerOneSafe(partnerAccountId, 'PARTNER_H5', {
|
||||
partnerAccountId: primary.id,
|
||||
eventName: 'partner_proxy_order_create',
|
||||
@@ -2347,25 +2333,9 @@ export class TradeService {
|
||||
}),
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
await tx.commonPromoCode.update({
|
||||
where: { id: promoCodeId },
|
||||
data: { orderCount: { increment: 1 } },
|
||||
});
|
||||
}
|
||||
|
||||
return created;
|
||||
});
|
||||
|
||||
if (promoCodeId) {
|
||||
this.promoCodeService.logPromoOrderEvent(
|
||||
promoCodeId,
|
||||
order.id,
|
||||
user.id,
|
||||
location.clientIp ?? undefined,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
id: order.id.toString(),
|
||||
orderNo: order.orderNo,
|
||||
|
||||
Reference in New Issue
Block a user