fix(cost-center): 修复人工履约配置保存后处理报错

This commit is contained in:
yml2213
2026-11-05 17:25:57 +08:00
parent fc928c6b18
commit a024a71df3
2 changed files with 7 additions and 2 deletions
@@ -787,7 +787,7 @@ export async function rematchManualFulfillments(input: Record<string, unknown> =
}
/**
* 为已配置的人工 SKU 生成/刷新成本版本(按 1 积分 = 1 分钱换算)。
* 为已配置的人工 SKU 生成/刷新固定成本版本(按各平台积分换算率折算)。
*
* 成本版本是「成本金额」的唯一真源;积分消耗量记在配置里,
* 两者按固定换算率保持一致。
@@ -809,7 +809,7 @@ async function attachCostVersionsForManualConfigs() {
SELECT
$1, 'product', '', '', cfg.canonical_product_id, NULL,
ROUND(cfg.credit_quantity * (fp.config_json->>'rechargeUnitPriceFen')::bigint, 0)::bigint,
'1970-01-01T00:00:00+08:00', 'manual', 'active',
0, '1970-01-01T00:00:00+08:00', 'manual', 'active',
'人工履约配置:积分按平台换算率折算',
NOW(), NOW()
FROM manual_fulfillment_configs cfg
@@ -118,6 +118,11 @@ test('人工确认前必须自动匹配履约配置,配置保存/定时任务
configSource.includes('manual_sku_key'),
'人工 SKU 匹配必须统一走 order_items.manual_sku_key 生成列',
)
assert.ok(
configSource.includes('amount_fen, rate_bps') &&
configSource.includes("0, '1970-01-01T00:00:00+08:00', 'manual', 'active'"),
'人工履约固定成本版本必须同时写入 amount_fen 和 rate_bps,避免保存成功但后处理报错',
)
assert.ok(
migrationSource.includes("spec_json->>'skuNick'") &&
migrationSource.includes("spec_json->>'outSkuSn'") &&