From 020f364572473627163a69b212f02f07c54ffd64 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Mon, 2 Nov 2026 16:19:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=B1=A5=E7=BA=A6):=20=E9=87=8D=E6=8C=82?= =?UTF-8?q?=E5=A4=87=E8=B4=A7/=E9=87=87=E8=B4=AD/=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E6=8A=B5=E6=89=A3=E6=97=B6=E6=B8=85=E6=8E=89=E9=85=8D=E9=80=81?= =?UTF-8?q?=E7=9B=B4=E4=BE=9B=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复盘点/删除库存触发的 order_item_fulfillment_one_source 约束冲突:旧行 direct_delivery_cover=true 与新来源并存。 --- .../src/services/orderItemFulfillmentService.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/server/src/services/orderItemFulfillmentService.ts b/server/src/services/orderItemFulfillmentService.ts index f3c70eb..0d24634 100644 --- a/server/src/services/orderItemFulfillmentService.ts +++ b/server/src/services/orderItemFulfillmentService.ts @@ -24,13 +24,14 @@ export async function linkOrderItemToPreparation( const cover = Math.max(0, Number(input.inventoryCoverQty) || 0); await db.query( `INSERT INTO order_item_fulfillments ( - order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, updated_at - ) VALUES ($1::uuid, $2, $3::uuid, NULL, $4, NOW()) + order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, direct_delivery_cover, updated_at + ) VALUES ($1::uuid, $2, $3::uuid, NULL, $4, false, NOW()) ON CONFLICT (order_item_id) DO UPDATE SET order_code = EXCLUDED.order_code, supplier_preparation_id = EXCLUDED.supplier_preparation_id, purchase_code = NULL, inventory_cover_qty = EXCLUDED.inventory_cover_qty, + direct_delivery_cover = false, updated_at = NOW()`, [input.orderItemId, input.orderCode, input.preparationId, cover] ); @@ -48,13 +49,14 @@ export async function linkOrderItemToPurchase( const cover = Math.max(0, Number(input.inventoryCoverQty) || 0); await db.query( `INSERT INTO order_item_fulfillments ( - order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, updated_at - ) VALUES ($1::uuid, $2, NULL, $3, $4, NOW()) + order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, direct_delivery_cover, updated_at + ) VALUES ($1::uuid, $2, NULL, $3, $4, false, NOW()) ON CONFLICT (order_item_id) DO UPDATE SET order_code = EXCLUDED.order_code, supplier_preparation_id = NULL, purchase_code = EXCLUDED.purchase_code, inventory_cover_qty = EXCLUDED.inventory_cover_qty, + direct_delivery_cover = false, updated_at = NOW()`, [input.orderItemId, input.orderCode, input.purchaseCode, cover] ); @@ -71,13 +73,14 @@ export async function linkOrderItemToInventoryCover( } await db.query( `INSERT INTO order_item_fulfillments ( - order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, updated_at - ) VALUES ($1::uuid, $2, NULL, NULL, $3, NOW()) + order_item_id, order_code, supplier_preparation_id, purchase_code, inventory_cover_qty, direct_delivery_cover, updated_at + ) VALUES ($1::uuid, $2, NULL, NULL, $3, false, NOW()) ON CONFLICT (order_item_id) DO UPDATE SET order_code = EXCLUDED.order_code, supplier_preparation_id = NULL, purchase_code = NULL, inventory_cover_qty = EXCLUDED.inventory_cover_qty, + direct_delivery_cover = false, updated_at = NOW()`, [input.orderItemId, input.orderCode, cover] );