'use strict'; /** * 容器(篮筐)资产登记表 Model。 * * 对应数据库表 `wms_container`,登记仓库的物理容器(篮筐)资产: * 容器编号、使用状态、是否损坏、损坏说明、备注等。 * 同一仓库内容器编号唯一,通过 warehouse_id 做数据隔离维度。 * 后续散单拣货把购物车商品临时转移到容器时,通过 status 标记占用/空闲。 * @param {import('egg').Application} app - Egg 应用实例 */ module.exports = app => { const { BIGINT, STRING, ENUM } = app.Sequelize; const Container = app.model.define('wms_container', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID(数据隔离维度)', }, container_no: { type: STRING(50), allowNull: false, comment: '容器编号(篮筐编号)', }, status: { type: ENUM('idle', 'in_use'), allowNull: false, defaultValue: 'idle', comment: '使用状态:idle=空闲 in_use=占用(散单商品临时转移)', }, is_damaged: { type: ENUM('Y', 'N'), allowNull: false, defaultValue: 'N', comment: '是否损坏:Y=损坏 N=正常', }, damage_remark: { type: STRING(255), allowNull: true, comment: '损坏说明', }, remark: { type: STRING(500), allowNull: true, comment: '备注', }, creator_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '登记人账户ID', }, creator_name: { type: STRING(50), allowNull: true, comment: '登记人名称快照', }, }, { tableName: 'wms_container', comment: '容器(篮筐)资产登记表', timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', paranoid: false, indexes: [ { name: 'uk_warehouse_container_no', unique: true, fields: [ 'warehouse_id', 'container_no' ] }, { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] }, { name: 'idx_status', fields: [ 'status' ] }, { name: 'idx_is_damaged', fields: [ 'is_damaged' ] }, ], }); return Container; };