From b3bdb566c4f111ff05b96120c597c13ed91a67b4 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sat, 22 Aug 2026 17:22:21 +0800 Subject: [PATCH] =?UTF-8?q?fix(stock):=20=E4=BF=AE=E5=A4=8D=20warehouse.im?= =?UTF-8?q?port=20=E6=9D=A1=E7=A0=81=E4=B8=8D=E7=94=9F=E6=95=88=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=B7=AE=E5=BC=82=E5=90=8C=E6=AD=A5=20wms=5Fstock=5Fb?= =?UTF-8?q?arcodes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 创建/更新成功后,若归一化 barcode 为非空数组,调用 saveWarehouseStockBarcode 同步条码 - 条码同步失败计入该行 fail_items;未传条码不触发同步,避免误清空已有条码 --- app/service/systemMethods/stock/warehouse.js | 18 +++++++++++++++++- methods/changes/system.json | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/app/service/systemMethods/stock/warehouse.js b/app/service/systemMethods/stock/warehouse.js index b06a05b..3479ff6 100644 --- a/app/service/systemMethods/stock/warehouse.js +++ b/app/service/systemMethods/stock/warehouse.js @@ -651,6 +651,23 @@ class WarehouseService extends MainService { if (hasSku) { result = await service.systems.stockStore.saveWarehouseStock(normalizedRow); + } else { + result = await service.systems.stockStore.createWarehouseStock(normalizedRow); + } + + // 条码同步:仅当传入非空条码时写入 wms_stock_barcodes 表(未传条码则保留原有条码) + const barcodes = Array.isArray(normalizedRow.barcode) ? normalizedRow.barcode : []; + if (barcodes.length > 0) { + const stockId = (result && result.id != null) ? result.id : normalizedRow.id; + if (stockId != null) { + await service.systems.stockStore.saveWarehouseStockBarcode({ + id: stockId, + barcodes, + }); + } + } + + if (hasSku) { summary.updated_count += 1; if (result && result.id != null) { summary.updated_ids.push(result.id); @@ -658,7 +675,6 @@ class WarehouseService extends MainService { summary.updated_ids.push(normalizedRow.id); } } else { - result = await service.systems.stockStore.createWarehouseStock(normalizedRow); summary.created_count += 1; if (result && result.id != null) { summary.created_ids.push(result.id); diff --git a/methods/changes/system.json b/methods/changes/system.json index c646a1c..d95a8df 100644 --- a/methods/changes/system.json +++ b/methods/changes/system.json @@ -1,4 +1,19 @@ [ + { + "version": "2026.08.22-stock.warehouse.import-barcode-sync", + "date": "2026-08-22", + "type": "fixed", + "summary": "修复 stock.warehouse.import 传入 barcode(条码)不生效的问题:归一化后条码未在新建/更新路径写入 wms_stock_barcodes 表。现在导入行携带非空 barcode 时,在商品创建/更新成功后调用 saveWarehouseStockBarcode 差异同步条码(未传条码则保留原有条码)。", + "methods": [ + "stock.warehouse.import" + ], + "notes": [ + "app/service/systemMethods/stock/warehouse.js import():创建/更新成功后,若归一化 barcode 为非空数组,则按结果 id(缺省用行内 SKU)调用 systems.stockStore.saveWarehouseStockBarcode 同步到 wms_stock_barcodes 表", + "条码同步失败计入该行 fail_items,且该行不再计入成功计数,便于定位", + "未传 barcode(空数组)时不触发同步,避免误清空已有条码;barcode 格式与导出对齐(逗号分隔字符串)" + ], + "module": "stock.warehouse" + }, { "version": "2026.08.22-storage.inventory.list-filter-zero-quantity", "date": "2026-08-22",