From 2e42d473022d6ab6c7e5327302bff242966c05b4 Mon Sep 17 00:00:00 2001 From: liufumingren Date: Thu, 8 Oct 2026 21:57:53 +0800 Subject: [PATCH] =?UTF-8?q?fix(order):=20B2B=20=E4=BD=9C=E4=B8=9A=E6=98=8E?= =?UTF-8?q?=E7=BB=86=E5=89=AF=E8=A1=A8=E6=94=B9=E4=B8=BA=E5=85=B3=E8=81=94?= =?UTF-8?q?=20order=5Fdelivery=EF=BC=88=E5=8F=91=E8=B4=A7=E5=8D=95?= =?UTF-8?q?=EF=BC=89=E8=80=8C=E9=9D=9E=E5=87=BA=E5=BA=93=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一版误将 B2B 作业明细副表挂在出库单主表 wms_order_stockout 下, 实际业务为订单(发货单)侧作业:改为 wms_order_b2b,order_id 关联 wms_order_delivery 分表 id(类似 wms_order_express 运单号表), delivery_order_code 为发货单号快照。 - 迁移 20261008193000-create-wms-order-b2b.js(表 wms_order_b2b) - 模型 app/model/order_b2b.js(ctx.model.OrderB2b),删除 order_stockout_b2b - 回滚 order_stockout.js 的 hasOne 关联 - 开发库已撤销旧表并重建新表核验 14 列;生产库待随发布执行 - 字段:total_box_count/pickup_plate_number/prep_remark/ prep_duration_seconds/is_picked_up/picked_up_at/delivery_order_code --- app/model/order_stockout_b2b.js | 144 ------------------ ...=> 20261008193000-create-wms-order-b2b.js} | 0 2 files changed, 144 deletions(-) delete mode 100644 app/model/order_stockout_b2b.js rename database/migrations/{20261008193000-create-wms-order-stockout-b2b.js => 20261008193000-create-wms-order-b2b.js} (100%) diff --git a/app/model/order_stockout_b2b.js b/app/model/order_stockout_b2b.js deleted file mode 100644 index 34e1fe0..0000000 --- a/app/model/order_stockout_b2b.js +++ /dev/null @@ -1,144 +0,0 @@ -'use strict'; - -/** - * B2B 出库作业明细表 Model。 - * - * 对应数据库表 `wms_order_stockout_b2b`,与出库单主表 `wms_order_stockout` 一对一 - * (order_id 关联 wms_order_stockout.id),记录 B2B 出库单(order_type=B2BCK)的 - * 提货作业信息:总箱数、提货车牌、备货备注、备货用时、是否提货等。 - * - * 与主表一致不分表(不按仓库分表),通过 warehouse_id/store_id 维度隔离, - * 落表方式类似 wms_order_express(运单号表)。 - * @param {import('egg').Application} app - Egg 应用实例 - */ -module.exports = app => { - const { STRING, INTEGER, BIGINT, ENUM, DATE } = app.Sequelize; - - const OrderStockoutB2b = app.model.define('wms_order_stockout_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_stockout.id', - }, - warehouse_id: { - type: BIGINT(20).UNSIGNED, - allowNull: false, - comment: '仓库ID', - }, - store_id: { - type: BIGINT(20).UNSIGNED, - allowNull: true, - comment: '货主ID', - }, - stockout_order_code: { - type: STRING(50), - allowNull: true, - comment: '出库单号快照', - }, - 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: '备货用时(秒)', - }, - 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: '创建时间', - }, - updated_at: { - type: DATE, - allowNull: false, - comment: '更新时间', - }, - deleted_at: { - type: DATE, - allowNull: true, - comment: '软删除时间', - }, - }, { - tableName: 'wms_order_stockout_b2b', - comment: 'B2B出库作业明细表', - timestamps: false, - indexes: [ - { - name: 'uk_order_id', - unique: true, - fields: [ 'order_id' ], - }, - { - name: 'idx_warehouse_id', - fields: [ 'warehouse_id' ], - }, - { - name: 'idx_store_id', - fields: [ 'store_id' ], - }, - { - name: 'idx_stockout_order_code', - fields: [ 'stockout_order_code' ], - }, - { - name: 'idx_pickup_plate_number', - fields: [ 'pickup_plate_number' ], - }, - { - name: 'idx_is_picked_up', - fields: [ 'is_picked_up' ], - }, - { - name: 'idx_deleted_at', - fields: [ 'deleted_at' ], - }, - ], - }); - - /** - * 关联关系定义。 - * - 关联出库单主表 - */ - OrderStockoutB2b.associate = function() { - const { OrderStockout, OrderStockoutB2b } = app.model; - - OrderStockoutB2b.belongsTo(OrderStockout, { - foreignKey: 'order_id', - as: 'stockout', - }); - }; - - return OrderStockoutB2b; -}; diff --git a/database/migrations/20261008193000-create-wms-order-stockout-b2b.js b/database/migrations/20261008193000-create-wms-order-b2b.js similarity index 100% rename from database/migrations/20261008193000-create-wms-order-stockout-b2b.js rename to database/migrations/20261008193000-create-wms-order-b2b.js