WMS_MAIN/app/model/storage_transaction.js

165 lines
3.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 库位维度出入库流水模型。
* @param {import('egg').Application} app Egg 应用实例。
* @return {import('sequelize').ModelCtor<import('sequelize').Model>} Sequelize 模型。
*/
module.exports = app => {
const { STRING, INTEGER, BIGINT, ENUM, DATE, TEXT } = app.Sequelize;
const StorageTransaction = app.model.define('storage_transaction', {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键ID',
},
transaction_type: {
type: ENUM('INBOUND', 'OUTBOUND', 'TRANSFER_OUT', 'TRANSFER_IN', 'LOCK', 'UNLOCK'),
allowNull: false,
comment: '出入库类型',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID',
},
store_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '货主ID',
},
stock_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '商品库存ID,关联 wms_stock_warehouse.id',
},
storage_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '库位库存ID,关联 wms_storage.id',
},
space_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '库位ID',
},
quantity: {
type: INTEGER(12),
allowNull: false,
comment: '变动数量(正数)',
},
before_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更前总库存数量',
},
after_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更后总库存数量',
},
before_locked_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更前锁定数量',
},
after_locked_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更后锁定数量',
},
before_intercept_locked_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更前拦截锁定数量',
},
after_intercept_locked_quantity: {
type: INTEGER(12),
allowNull: true,
comment: '变更后拦截锁定数量',
},
batch_no: {
type: STRING(100),
allowNull: true,
comment: '批次号',
},
inventory_type: {
type: ENUM('ZP', 'CC', 'JS', 'XS', 'ZT', 'DJ', 'FP'),
defaultValue: 'ZP',
comment: '库存类型',
},
order_type: {
type: STRING(50),
allowNull: true,
comment: '关联单据类型',
},
order_no: {
type: TEXT,
allowNull: true,
comment: '关联单据号',
},
order_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '关联单据ID',
},
source_order_codes: {
type: TEXT,
allowNull: true,
comment: '来源订单号集合',
},
operator_id: {
type: STRING(100),
allowNull: true,
comment: '操作人ID',
},
operator_name: {
type: STRING(100),
allowNull: true,
comment: '操作人名称',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注',
},
created_at: {
type: DATE,
allowNull: false,
defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'),
comment: '创建时间',
},
}, {
tableName: 'wms_storage_transaction',
freezeTableName: true,
timestamps: false,
comment: '库位维度出入库流水记录表',
indexes: [
{
name: 'idx_storage_id',
fields: [ 'storage_id' ],
},
{
name: 'idx_stock_id',
fields: [ 'stock_id' ],
},
{
name: 'idx_warehouse_time',
fields: [ 'warehouse_id', 'created_at' ],
},
{
name: 'idx_order',
fields: [ 'order_type', 'order_id' ],
},
{
name: 'idx_created_at',
fields: [ 'created_at' ],
},
],
});
return StorageTransaction;
};