// app/model/order_item_sn_log.js 'use strict'; module.exports = app => { const { BIGINT, STRING, DATE } = app.Sequelize; const OrderItemSnLog = app.model.define('wms_order_item_sn_log', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, sn_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '关联 wms_order_item_sn.id,不做物理外键', }, order_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '订单ID,逻辑关联分仓订单主表,不做物理外键', }, order_item_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '订单明细ID,逻辑关联分仓订单明细表,不做物理外键', }, sn_code: { type: STRING(512), allowNull: false, comment: 'SN编码(支持链接/二维码内容,最长512字符)', }, from_sn_status: { type: STRING(32), allowNull: true, comment: '变更前SN状态', }, to_sn_status: { type: STRING(32), allowNull: false, comment: '变更后SN状态', }, verify_status: { type: STRING(32), allowNull: true, comment: '本次状态变更后的核验状态', }, action_type: { type: STRING(32), allowNull: false, comment: '动作类型:BIND/VERIFY/RETURN/REISSUE/UNBIND', }, remark: { type: STRING(255), allowNull: true, comment: '备注', }, operator_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '操作人ID', }, operated_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '操作时间', }, created_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), comment: '更新时间', }, }, { tableName: 'wms_order_item_sn_log', timestamps: false, comment: '订单明细SN状态变更流水表', indexes: [ { name: 'idx_wms_order_item_sn_log_sn_id', fields: [ 'sn_id' ], }, { name: 'idx_wms_order_item_sn_log_sn_code', fields: [ 'sn_code' ], }, { name: 'idx_wms_order_item_sn_log_order_id', fields: [ 'order_id' ], }, { name: 'idx_wms_order_item_sn_log_order_item_id', fields: [ 'order_item_id' ], }, ], }); return OrderItemSnLog; };