fix(finance): 卡券商品补内部 SKU 规则,待分类自动分流
- 自动创建 tpv: 商品时补渠道能力和 internal_sku 规则 - 迁移 116 为已存在的卡券商品回填内部 SKU 规则 - 同内部中文 SKU 的待分类订单自动进入第三方卡券
This commit is contained in:
@@ -182,6 +182,29 @@ async function ensureVoucherProductForItem(item: ItemRow): Promise<number | null
|
||||
[item.id, productId],
|
||||
)
|
||||
|
||||
await query(
|
||||
`
|
||||
INSERT INTO product_channel_capabilities (product_id, channel, priority, is_fallback, enabled, source)
|
||||
VALUES ($1, 'third_party_voucher', 10, FALSE, TRUE, 'auto')
|
||||
ON CONFLICT (product_id, channel) DO NOTHING
|
||||
`,
|
||||
[productId],
|
||||
)
|
||||
|
||||
// 同一内部中文 SKU 跨平台码统一分流到卡券渠道。
|
||||
await query(
|
||||
`
|
||||
INSERT INTO sku_channel_rules (
|
||||
provider, shop_id, match_key_type, match_key, channel, priority,
|
||||
source, enabled, note, created_at, updated_at
|
||||
)
|
||||
VALUES ('', '', 'internal_sku', $1, 'third_party_voucher', 10, 'voucher', TRUE,
|
||||
'卡券商品自动建商品后生成', NOW(), NOW())
|
||||
ON CONFLICT (provider, shop_id, match_key_type, match_key, channel) DO NOTHING
|
||||
`,
|
||||
[internalSku],
|
||||
)
|
||||
|
||||
const skuCode = String(item.sku_code || '').trim()
|
||||
if (skuCode) {
|
||||
await query(
|
||||
|
||||
Reference in New Issue
Block a user