feat: 支持第三方卡券收到订单后自动核销

This commit is contained in:
yml2213
2026-11-05 15:19:39 +08:00
parent 1df88cc639
commit 92ceb9697b
11 changed files with 323 additions and 30 deletions
@@ -12,6 +12,7 @@ import {
planInternalSkuChannels,
type InternalSkuChannelRow,
} from './internal-sku-channel-service.js'
import { scheduleVoucherConsumeForOrderItems } from './voucher-consume-queue-service.js'
type CarrierCandidate = {
id: number
@@ -188,7 +189,13 @@ async function selectSafeFallback(input: {
input.includeAssignedMissingCarrier,
],
)
return (result.rowCount || 0) > 0
const updated = (result.rowCount || 0) > 0
if (updated) {
await scheduleVoucherConsumeForOrderItems([input.orderItemId], 'order_received').catch(
() => undefined,
)
}
return updated
}
/**