feat(storage): 快捷直入回写虚拟入库标记

This commit is contained in:
liufumingren 2026-08-30 07:28:29 +08:00
parent ebaf5d0051
commit 58cc5bb7b6
3 changed files with 49 additions and 0 deletions

View File

@ -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,

View File

@ -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,

View File

@ -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<void>} 无返回值
*/
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<void>} 无返回值
*/
down: async queryInterface => {
const columns = await queryInterface.describeTable(TABLE);
if (columns.is_virtual_inbound) {
await queryInterface.removeColumn(TABLE, 'is_virtual_inbound');
}
},
};