feat(cost-center): 第三方卡券渠道归一与采购价配置

- 归一新增 tpv:<SKU> 直达,卡券单无需手工映射
- 成本配置/总览/异常支持 third_party_voucher 与 archived 维度
- 新增卡券采购价面板,写入 sys_third_party_voucher_cost
- 修正 man: 商品改价误用不存在的 sys_manual_cost
This commit is contained in:
yml2213
2026-10-31 19:52:32 +08:00
parent 0ce3c8fa97
commit f4e0c47744
16 changed files with 264 additions and 40 deletions
@@ -80,7 +80,7 @@ export async function getAdminCostCenterOverview(params: { scope?: string } = {}
AND (
$1::text IS NULL
OR ce.order_item_id IN (
SELECT oi.id FROM order_items oi WHERE oi.fulfillment_mode = $1
SELECT oi.id FROM order_items oi WHERE COALESCE(oi.fulfillment_channel, CASE WHEN oi.fulfillment_status = 'archived' THEN 'archived' ELSE 'pending' END) = $1
)
)
) AS open_exception_count,
@@ -89,7 +89,7 @@ export async function getAdminCostCenterOverview(params: { scope?: string } = {}
FROM order_items oi
WHERE oi.canonical_product_id IS NULL
AND oi.fulfillment_status <> 'archived'
AND ($1::text IS NULL OR oi.fulfillment_mode = $1)
AND ($1::text IS NULL OR COALESCE(oi.fulfillment_channel, CASE WHEN oi.fulfillment_status = 'archived' THEN 'archived' ELSE 'pending' END) = $1)
) AS unmapped_order_item_count
`,
[scope],
@@ -121,7 +121,12 @@ export async function getAdminCostCenterOverview(params: { scope?: string } = {}
}
}
const COST_CENTER_SCOPES = new Set(['affiliate_dash', 'work_order', 'manual'])
const COST_CENTER_SCOPES = new Set([
'affiliate_dash',
'work_order',
'third_party_voucher',
'manual',
])
function normalizeScope(raw: unknown): CostCenterScope | null {
const value = String(raw ?? '').trim()