// app/model/picking_strategy.js 'use strict'; /** * 波次策略模型定义。 * @param {import('egg').Application} app Egg 应用实例 * @return {import('sequelize').ModelCtor} 波次策略模型 */ module.exports = app => { const { BIGINT, INTEGER, STRING, TINYINT, BOOLEAN, JSON, TEXT, DATE } = app.Sequelize; const WaveStrategy = app.model.define('wms_wave_strategy', { id: { type: INTEGER, primaryKey: true, autoIncrement: true, allowNull: false, comment: '策略ID', }, strategy_name: { type: STRING(100), allowNull: false, comment: '策略名称', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, strategy_type: { type: TINYINT, allowNull: false, comment: '策略类型:1-散单 2-团购 3-SN(序列号管理,固定先拣后分)', }, status: { type: TINYINT, allowNull: true, defaultValue: 1, comment: '状态:1-启用 0-停用', }, order_min_sku: { type: INTEGER, allowNull: true, defaultValue: 1, comment: '订单最小SKU种类数', }, order_max_sku: { type: INTEGER, allowNull: true, defaultValue: 999, comment: '订单最大SKU种类数', }, order_min_qty: { type: INTEGER, allowNull: true, defaultValue: 1, comment: '订单最小商品总数', }, order_max_qty: { type: INTEGER, allowNull: true, defaultValue: 999, comment: '订单最大商品总数', }, min_same_structure: { type: INTEGER, allowNull: true, defaultValue: 1, comment: '最小相同结构订单数', }, max_same_structure: { type: INTEGER, allowNull: true, defaultValue: 999, comment: '最大相同结构订单数', }, require_same_express: { type: BOOLEAN, allowNull: true, defaultValue: false, comment: '是否要求相同快递', }, allow_cross_owner: { type: BOOLEAN, allowNull: true, defaultValue: true, comment: '是否允许跨货主', }, batch_mode: { type: TINYINT, allowNull: false, comment: '拣货模式:1-单品单件 2-先拣后分 3-边拣边分 4-边拣边分H型 5-播种墙 6-流利架', }, batch_max_orders: { type: INTEGER, allowNull: true, defaultValue: 20, comment: '批次最大订单数', }, batch_max_skus: { type: INTEGER, allowNull: true, defaultValue: 50, comment: '批次最大SKU总数', }, group_batch_max_orders: { type: INTEGER, allowNull: true, defaultValue: 1, comment: '团购批次最大订单数(相同结构)', }, wave_prefix: { type: STRING(5), allowNull: true, comment: '波次前缀(为空时回退仓库前缀)', }, allowed_owners: { type: JSON, allowNull: true, comment: '允许的货主ID列表', }, allowed_expresses: { type: JSON, allowNull: true, comment: '允许的快递编码列表', }, allowed_provinces: { type: JSON, allowNull: true, comment: '允许的省份列表', }, allowed_platforms: { type: JSON, allowNull: true, comment: '允许的平台列表', }, description: { type: TEXT, allowNull: true, comment: '策略描述', }, creator_name: { type: STRING(50), allowNull: true, comment: '创建人姓名', }, create_time: { type: DATE, allowNull: true, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, update_time: { type: DATE, allowNull: true, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '更新时间', }, }, { tableName: 'wms_wave_strategy', timestamps: false, underscored: false, comment: '波次策略配置表', indexes: [ { name: 'idx_warehouse_type', fields: [ 'warehouse_id', 'strategy_type', 'status' ], }, { name: 'idx_batch_mode', fields: [ 'batch_mode', 'strategy_type' ], }, ], }); return WaveStrategy; };