'use strict'; /** * B2B 订单作业明细表 Model。 * * 对应数据库表 `wms_order_b2b`,与发货单(订单)分表 wms_order_delivery_% 一对一, * 记录 B2B 订单的备货/提货作业信息:总箱数、提货车牌、备货备注、备货用时、 * 备货完成时间、是否提货等。 * * 不分表(不按仓库分表),关联读统一使用 warehouse_id + order_id(分表 id 按仓库 * 各自发号,跨仓可能重叠,故不单独依赖 order_id)。取消 B2B 时物理删除行,不做软删除。 * @param {import('egg').Application} app - Egg 应用实例 */ module.exports = app => { const { STRING, INTEGER, BIGINT, ENUM, DATE } = app.Sequelize; const OrderB2b = app.model.define('wms_order_b2b', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, order_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '订单ID,关联 wms_order_delivery 分表 id', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, total_box_count: { type: INTEGER(11), allowNull: false, defaultValue: 0, comment: '总箱数', }, pickup_plate_number: { type: STRING(20), allowNull: true, comment: '提货车牌', }, prep_remark: { type: STRING(500), allowNull: true, comment: '备货备注', }, prep_duration_seconds: { type: INTEGER(11), allowNull: false, defaultValue: 0, comment: '备货用时(秒)', }, prep_at: { type: DATE, allowNull: true, comment: '备货完成时间', }, is_picked_up: { type: ENUM('Y', 'N'), allowNull: false, defaultValue: 'N', comment: '是否提货:Y=已提货 N=未提货', }, picked_up_at: { type: DATE, allowNull: true, comment: '提货时间', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, }, { tableName: 'wms_order_b2b', comment: 'B2B订单作业明细表', timestamps: false, indexes: [ { name: 'uk_warehouse_order', unique: true, fields: [ 'warehouse_id', 'order_id' ], }, { name: 'idx_pickup_plate_number', fields: [ 'pickup_plate_number' ], }, { name: 'idx_is_picked_up', fields: [ 'is_picked_up' ], }, ], }); return OrderB2b; };