WMS_MAIN/database/migrations/20260813120300-create-wms-return-query-log.js
liufumingren 38b29be776 feat: 新增退回拆包模块(returnUnpack)与序列表原子取号
- 新增 wms_return_unpack 主表/明细/视频 与 wms_return_query_log 表(model + 迁移)
- 新增序列表 wms_number_sequence,单号取号改为 INSERT...ON DUPLICATE KEY 原子递增(含历史 seed 对齐)
- 补齐 wms_order_delivery 基表缺失 25 列(修复 Unknown column)
- 权限固定 ID 540-549 + 角色授权迁移
- 修复 returnReceived.create 出参 record 包装;修复 afterSale 发件人查询列名(name→company_name)
- detail 接口按设计走 548 权限校验
2026-08-13 21:40:50 +08:00

76 lines
2.4 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';
/**
* 创建退回查询记录表 wms_return_query_log。
*
* 用途:登记「货主未退回、但做过查询退回」的运单号,仓库 + 货主隔离。
* 创建拆包单未命中原单时,据此反查运单号对应的货主并回写 store_id(限最近 3 个月内登记)。
* is_back / is_notified 供定时任务扫描拆包通知;拆包单提交确认时更新 is_back=1。
*
* 索引:
* idx_warehouse_store_waybill(仓库+货主+运单号,核心)
* idx_warehouse_store(仓库+货主隔离查询)
* idx_waybill_code(按运单号查询)
*/
const TABLE_NAME = 'wms_return_query_log';
module.exports = {
// eslint-disable-next-line no-unused-vars
async up(queryInterface, Sequelize) {
const { BIGINT, STRING, DATE, TINYINT } = Sequelize;
await queryInterface.createTable(TABLE_NAME, {
id: {
type: BIGINT(20).UNSIGNED,
primaryKey: true,
autoIncrement: true,
allowNull: false,
comment: '主键',
},
warehouse_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '仓库ID(隔离维度)',
},
store_id: {
type: BIGINT(20).UNSIGNED,
allowNull: false,
comment: '货主ID(隔离维度)',
},
waybill_code: {
type: STRING(50),
allowNull: false,
comment: '查询过的运单号',
},
remark: {
type: STRING(500),
allowNull: true,
comment: '备注',
},
is_notified: {
type: TINYINT(1),
allowNull: false,
defaultValue: 0,
comment: '是否已通知:0=未通知,1=已通知',
},
is_back: {
type: TINYINT(1),
allowNull: false,
defaultValue: 0,
comment: '是否退回:0=未退回,1=已退回',
},
created_at: { type: DATE, allowNull: false },
updated_at: { type: DATE, allowNull: false },
});
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'store_id', 'waybill_code' ], { name: 'idx_warehouse_store_waybill' });
await queryInterface.addIndex(TABLE_NAME, [ 'warehouse_id', 'store_id' ], { name: 'idx_warehouse_store' });
await queryInterface.addIndex(TABLE_NAME, [ 'waybill_code' ], { name: 'idx_waybill_code' });
},
// eslint-disable-next-line no-unused-vars
async down(queryInterface, Sequelize) {
await queryInterface.dropTable(TABLE_NAME);
},
};