商品流水增加锁定类目语义类型

This commit is contained in:
liufumingren 2026-07-06 19:28:45 +08:00
parent 223e42fcf6
commit df1bd38601
4 changed files with 35 additions and 4 deletions

View File

@ -11,9 +11,9 @@ module.exports = app => {
comment: '主键ID',
},
transaction_type: {
type: ENUM('INBOUND', 'OUTBOUND'),
type: ENUM('INBOUND', 'OUTBOUND', 'LOCK'),
allowNull: false,
comment: '出入库类型',
comment: '出入库类型:INBOUND入库 OUTBOUND出库 LOCK锁定',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,

View File

@ -732,9 +732,9 @@ class stockStoreService extends Service {
// 写入流水(除非显式跳过)
const skipLog = meta.skipTransactionLog === true;
if (!skipLog && ctx.service && ctx.service.systems && ctx.service.systems.stockTransaction) {
// transaction_type 字段为 ENUM('INBOUND','OUTBOUND'),锁定/解锁属于出库流程
// 锁定操作使用 LOCK 类型,释放操作使用 OUTBOUND
await ctx.service.systems.stockTransaction.create({
transaction_type: 'OUTBOUND',
transaction_type: isLocking ? 'LOCK' : 'OUTBOUND',
warehouse_id: stockRecord.warehouse_id,
store_id: stockRecord.store_id,
stock_id: stockId,

View File

@ -127,6 +127,10 @@ function formatTransactionType(transactionType) {
return '移库入';
}
if (normalizedType === 'LOCK') {
return '锁定';
}
return rawType;
}

View File

@ -0,0 +1,27 @@
'use strict';
/**
* 为 wms_stock_transaction.transaction_type ENUM 增加 LOCK。
* LOCK:库存锁定流水(如分配订单锁定库存)。
*/
module.exports = {
async up(queryInterface) {
const { sequelize } = queryInterface;
await sequelize.query(`
ALTER TABLE wms_stock_transaction
MODIFY COLUMN transaction_type ENUM(
'INBOUND', 'OUTBOUND', 'LOCK'
) NOT NULL COMMENT '出入库类型:INBOUND入库 OUTBOUND出库 LOCK锁定'
`);
},
async down(queryInterface) {
const { sequelize } = queryInterface;
await sequelize.query(`
ALTER TABLE wms_stock_transaction
MODIFY COLUMN transaction_type ENUM(
'INBOUND', 'OUTBOUND'
) NOT NULL COMMENT '出入库类型'
`);
},
};