WMS_MAIN/database/migrations/20261009100000-add-is-print-to-wms-order-b2b.js
liufumingren 183e542d74 feat(order): 新增 order.convertToB2b 接口,订单转 B2B
- systems/order_b2b.js convertOrdersToB2b:
  1) 仅限待处理表(current 分表)订单,事务内 SELECT ... FOR UPDATE 后逐行校验:
     待处理(step!=0)/未打印(print_status!=fin)/未锁定(lock_status=none)/
     未拦截(intercept_status=none)/未转 B2B(is_b2b!=Y),不符合条件跳过
     (skipped_reasons 返回原因),不存在的订单计入 not_found_order_ids
  2) 事务内:订单 is_b2b 置 Y + wms_order_b2b 写入(findOrCreate by uk_order_id,
     已存在不覆盖);提交后写操作日志 ORDER_B2B_CONVERT(失败不影响主流程)
  3) 单次上限 200,仓库隔离(warehouse_id 过滤)
- systemMethods/order/index.js convertToB2b:ids/order_ids/orderIds 数组
  与 id/order_id/orderId 单值兼容,空/超限 400;白名单三处加 convertToB2b
- wms_order_b2b 新增 is_print 字段(ENUM('Y','N') 默认 N 未打印)+ idx_is_print
  (迁移 20261009100000 已执行开发库并核验 15 列)
- 验证:临时集成测试 3/3 PASS(转换落库+日志+还原、跳过分流、400 边界);
  ESLint 0 error;生产迁移待随发布执行
2026-10-09 00:22:25 +08:00

32 lines
995 B
JavaScript
Raw Permalink 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 订单作业明细表 wms_order_b2b 增加 is_print 列(是否打印,默认 N)。
*
* 字段:is_print ENUM('Y','N') NOT NULL DEFAULT 'N'(N=未打印 Y=已打印)。
* 索引:idx_is_print(按打印状态筛选)。
*/
const TABLE_NAME = 'wms_order_b2b';
const COLUMN_NAME = 'is_print';
module.exports = {
// eslint-disable-next-line no-unused-vars
async up(queryInterface, Sequelize) {
const { ENUM } = Sequelize;
await queryInterface.addColumn(TABLE_NAME, COLUMN_NAME, {
type: ENUM('Y', 'N'),
allowNull: false,
defaultValue: 'N',
comment: '是否打印:Y=已打印 N=未打印',
});
await queryInterface.addIndex(TABLE_NAME, [ COLUMN_NAME ], { name: 'idx_is_print' });
},
// eslint-disable-next-line no-unused-vars
async down(queryInterface, Sequelize) {
await queryInterface.removeIndex(TABLE_NAME, 'idx_is_print');
await queryInterface.removeColumn(TABLE_NAME, COLUMN_NAME);
},
};