WMS_MAIN/app/model/order_b2b.js
liufumingren 59bc65b443 feat(order): B2B 加急优先、分箱明细与取货储位,作业链路收口
- 列表:B2B 待处理/配送列表固定加急优先排序(wms_order_b2b.is_urgent='Y' 置顶),
  作业明细筛选口径不变
- 备货/提货:新增 setB2bUrgent/cancelB2bUrgent、startB2bPrep/cancelB2bPrep/finishB2bPrep、
  setB2bPickupPlate、pickupB2b、updateB2bOrderImages;提货即出库完成
  (写 outbound_status=fin / step=4 / delivery_time 并迁移到配送表),车牌与提货照片
  随单落库
- 分箱:新增 wms_order_b2b_items 与 order.updateB2bPackingItems、order.getB2bPackingSnapshot;
  快照按商品行返回 wms_picking 取货储位(items[].pick_locations / pick_location_count),
  列表不再携带储位明细
- 齐套校验:仓库 subject_config 新增 b2b_packing_quantity_check,备货完成时逐商品校验
  分箱数量合计等于 plan_qty 且总箱数与箱号数一致
- 拦截:B2B 订单不参与波次抓取、快捷复核批量发货、反审回待审核与克隆,命中即整批驳回
- 明细:order.pendingOrder.detail / order.deliveryOrder.detail 为 B2B 订单附加副表作业明细
  b2b、备货照片 images 与提货照片 pickup_images
- 迁移:wms_order_b2b 新增 is_urgent 与备货作业字段,新建 wms_order_b2b_items
- 文档:methods/system.json 与 methods/changes/system.json 同步至 0.3.375

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-19 18:17:19 +08:00

136 lines
3.5 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'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: '备货完成时间',
},
prep_status: {
type: ENUM('none', 'padding', 'fin'),
allowNull: false,
defaultValue: 'none',
comment: '备货状态:none=未开始 padding=备货中 fin=已完成',
},
prep_operator_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '备货人工号ID(工号,用于同工号校验)',
},
prep_operator_name: {
type: STRING(50),
allowNull: true,
comment: '备货人姓名',
},
prep_start_at: {
type: DATE,
allowNull: true,
comment: '备货开始时间',
},
is_picked_up: {
type: ENUM('Y', 'N'),
allowNull: false,
defaultValue: 'N',
comment: '是否提货:Y=已提货 N=未提货',
},
is_urgent: {
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' ],
},
{
name: 'idx_is_urgent',
fields: [ 'is_urgent' ],
},
{
name: 'idx_prep_status_operator',
fields: [ 'prep_status', 'prep_operator_id' ],
},
],
});
return OrderB2b;
};