重构:硬切商品来源并移除旧运维入口

This commit is contained in:
yml2213
2026-11-08 19:44:27 +08:00
parent f8cbb645fe
commit 2ebc4a0ec7
24 changed files with 273 additions and 734 deletions
@@ -2112,11 +2112,21 @@ async function ensureDraftProductForChannel(
const key = canonicalizeInternalSku(internalSku)
if (!key) return null
const definition = {
affiliate_dash: { prefix: 'aff:', category: '自动发货', unit: '件' },
work_order: { prefix: 'tpl:', category: '接单', unit: '件' },
manual: { prefix: 'man:', category: '人工', unit: '件' },
on_account: { prefix: 'man:', category: '统一结算', unit: '件' },
third_party_voucher: { prefix: 'tpv:', category: '卡券', unit: '张' },
affiliate_dash: {
prefix: 'aff:',
category: '自动发货',
unit: '件',
sourceKind: 'affiliate_dash',
},
work_order: { prefix: 'tpl:', category: '接单', unit: '件', sourceKind: 'work_order' },
manual: { prefix: 'man:', category: '人工', unit: '件', sourceKind: 'manual' },
on_account: { prefix: 'man:', category: '统一结算', unit: '件', sourceKind: 'manual' },
third_party_voucher: {
prefix: 'tpv:',
category: '卡券',
unit: '张',
sourceKind: 'third_party_voucher',
},
}[channel]
const canonicalSku = `${definition.prefix}${key}`
if (canonicalSku.length > 64) return null
@@ -2129,16 +2139,18 @@ async function ensureDraftProductForChannel(
canonical_name,
category,
unit_name,
source_kind,
status,
attributes_json,
created_at,
updated_at
) VALUES (
$1, $2, $3, $4, 'active',
$5::jsonb, $6, $6
$1, $2, $3, $4, $5, 'active',
$6::jsonb, $7, $7
)
ON CONFLICT (canonical_sku) DO UPDATE
SET status = 'active',
source_kind = EXCLUDED.source_kind,
canonical_name = CASE
WHEN BTRIM(product_catalog.canonical_name) = '' THEN EXCLUDED.canonical_name
ELSE product_catalog.canonical_name
@@ -2157,6 +2169,7 @@ async function ensureDraftProductForChannel(
key.slice(0, 120),
definition.category,
definition.unit,
definition.sourceKind,
JSON.stringify({
source: channel,
auto_created: true,