diff --git a/apps/backend/src/services/cost-center/cost-center.test.ts b/apps/backend/src/services/cost-center/cost-center.test.ts index 728cdbaa..832575d7 100644 --- a/apps/backend/src/services/cost-center/cost-center.test.ts +++ b/apps/backend/src/services/cost-center/cost-center.test.ts @@ -272,3 +272,20 @@ test('mapping lookup follows specificity and concrete-shop priority', () => { 50, ) }) + +/** + * 2026-10-29 生产:改「接单模板」商品价格 500。 + * + * PostgreSQL 报 `inconsistent types deduced for parameter $1`(integer versus bigint): + * 同一个 $1 在 `reward_amount = $1` 处按 bigint 推断,在 `CASE ... THEN $1 ELSE 0` + * 处又因为 `0` 是 integer 被推断成 integer。node-pg 不发送参数类型,必须显式转换。 + */ +test('接单模板改价 SQL 的参数必须显式指定 bigint', async () => { + const { readFile } = await import('node:fs/promises') + const source = await readFile(new URL('./product-catalog-service.ts', import.meta.url), 'utf8') + assert.ok( + source.includes( + 'unit_price_fen = CASE WHEN unit_price_fen > 0 THEN $1::bigint ELSE 0::bigint END', + ), + ) +}) diff --git a/apps/backend/src/services/cost-center/product-catalog-service.ts b/apps/backend/src/services/cost-center/product-catalog-service.ts index 1f8e5577..cca1d79f 100644 --- a/apps/backend/src/services/cost-center/product-catalog-service.ts +++ b/apps/backend/src/services/cost-center/product-catalog-service.ts @@ -1471,8 +1471,8 @@ export async function setAdminProductPrice( if (rule) { await query( `UPDATE work_product_rules - SET reward_amount = $1, - unit_price_fen = CASE WHEN unit_price_fen > 0 THEN $1 ELSE 0 END, + SET reward_amount = $1::bigint, + unit_price_fen = CASE WHEN unit_price_fen > 0 THEN $1::bigint ELSE 0::bigint END, cost_item_id = $2, updated_at = $3 WHERE id = $4`,