From 58cc5bb7b617977aa58e3c018dc7dc591fb1fca1 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Sun, 30 Aug 2026 07:28:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(storage):=20=E5=BF=AB=E6=8D=B7=E7=9B=B4?= =?UTF-8?q?=E5=85=A5=E5=9B=9E=E5=86=99=E8=99=9A=E6=8B=9F=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=A0=87=E8=AE=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/entry_order.js | 6 +++ app/service/systems/storage/entry.js | 3 ++ ...d-is-virtual-inbound-to-wms-entry-order.js | 40 +++++++++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 database/migrations/20260828100000-add-is-virtual-inbound-to-wms-entry-order.js diff --git a/app/model/entry_order.js b/app/model/entry_order.js index 91f3267..5c63bf6 100644 --- a/app/model/entry_order.js +++ b/app/model/entry_order.js @@ -143,6 +143,12 @@ module.exports = app => { defaultValue: 0, comment: '费用是否记录', }, + is_virtual_inbound: { + type: TINYINT(1), + allowNull: false, + defaultValue: 0, + comment: '是否虚拟入库:0=否 1=是', + }, store_name: { type: STRING(200), allowNull: true, diff --git a/app/service/systems/storage/entry.js b/app/service/systems/storage/entry.js index 8a2278f..02c09dd 100644 --- a/app/service/systems/storage/entry.js +++ b/app/service/systems/storage/entry.js @@ -1517,6 +1517,7 @@ class EntryService extends Service { * 快捷直入/虚拟入库:将入库单明细直入到虚拟库位(space_id=2),跳过收货、质检等正常流程。 * 有绑定收货单时,只取收货单中与入库单明细有交集(按 stock_id 判断)且剩余可入数量的部分直入, * 并回写收货单明细已入库数量;未绑定收货单时按明细计划数量全量直入。 + * 有绑定收货单时回写 is_virtual_inbound=0(非虚拟入库),无绑定收货单时回写 is_virtual_inbound=1(虚拟入库)。 * 采用"先同步后写库"两段式:① 先发奇门/OpenAPI 回传,② 回传成功后再开启事务写库存。 * @param {Object} data 请求体 * @param {number} data.id 入库单ID @@ -1843,6 +1844,8 @@ class EntryService extends Service { await eo.update({ order_status: 'COMPLETED', sync_status: 'SUCCESS', + // 有绑定收货单 → 非虚拟入库(0);无绑定收货单 → 虚拟入库(1) + is_virtual_inbound: receivingIds.length > 0 ? 0 : 1, sync_message: JSON.stringify({ completedAt: new Date(), totalQuantity: totalInboundQty, diff --git a/database/migrations/20260828100000-add-is-virtual-inbound-to-wms-entry-order.js b/database/migrations/20260828100000-add-is-virtual-inbound-to-wms-entry-order.js new file mode 100644 index 0000000..b8631f5 --- /dev/null +++ b/database/migrations/20260828100000-add-is-virtual-inbound-to-wms-entry-order.js @@ -0,0 +1,40 @@ +'use strict'; + +const TABLE = 'wms_entry_order'; + +/** + * 入库单主表新增 is_virtual_inbound 字段: + * 标记该入库单是否为虚拟入库(0=否,1=是)。 + * 快捷直入时,无绑定收货单的入库单为虚拟入库,有绑定收货单的为非虚拟入库。 + */ +module.exports = { + /** + * 执行迁移:新增 is_virtual_inbound 字段。 + * @param {import('sequelize').QueryInterface} queryInterface 查询接口 + * @param {import('sequelize')} Sequelize Sequelize 实例 + * @return {Promise} 无返回值 + */ + up: async (queryInterface, Sequelize) => { + const columns = await queryInterface.describeTable(TABLE); + if (!columns.is_virtual_inbound) { + await queryInterface.addColumn(TABLE, 'is_virtual_inbound', { + type: Sequelize.TINYINT(1), + allowNull: false, + defaultValue: 0, + comment: '是否虚拟入库:0=否 1=是', + }); + } + }, + + /** + * 回滚迁移:删除 is_virtual_inbound 字段。 + * @param {import('sequelize').QueryInterface} queryInterface 查询接口 + * @return {Promise} 无返回值 + */ + down: async queryInterface => { + const columns = await queryInterface.describeTable(TABLE); + if (columns.is_virtual_inbound) { + await queryInterface.removeColumn(TABLE, 'is_virtual_inbound'); + } + }, +};