oms/backend/database/migrations/20260915000700-create-express-companies.js
liufumingren 11e7b26ced feat(backend): 发货单模块与 WMS 定时推送队列
- 发货单主表/明细表(order_deliveries / order_delivery_items)控制器与模型
- 表头金额与明细派生字段重算(utils/recalcOrderDelivery.js)
- 状态流转:审核/驳回/取消/恢复/作废、批量审核、批量切换仓库
- 审核入队 + 定时推送:service/orderDeliveryPush.js(乐观锁 CAS 防重、失败重试上限 3 次、业务失败退回待审核)+ schedule/orderDeliveryPush.js
- 收件人 AI 智能识别(service/ai.js,DeepSeek)
- 相关迁移:建表、站内字段、明细表、订单类型默认值、快递字典、菜单种子、历史数据搬迁
2026-09-13 02:23:47 +08:00

56 lines
2.3 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';
/**
* 快递公司字典表:express_companies
*
* 定位:通用字典(**不区分主体**,与 menus / warehouse-api-fields 同类),
* 供发货单等单据选择「物流公司」,避免手输编码。
*
* 编码口径:`code` 使用行业通用/WMS `express_code` 标准编码(如 SF/YTO/ZTO),
* WMS 侧 `wms_order_delivery.logistics_code` 接收同口径编码,再由其策略漏斗解析快递接口。
*
* 注:WMS 侧字典表为 `wms_express`(字段含各平台编码 KS/PDD/DY/CAINIAO...),
* 当前本地 WMS 库未建该表,故 OMS 侧先以常用快递种子维护,后续如需可与 WMS 对齐/同步。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable(
'express_companies',
{
id: { type: Sequelize.BIGINT.UNSIGNED, allowNull: false, autoIncrement: true, primaryKey: true },
code: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '快递公司编码(行业/WMS 标准编码,如 SF/YTO/ZTO)',
},
name: { type: Sequelize.STRING(100), allowNull: false, comment: '快递公司名称(如 顺丰速运)' },
status: { type: Sequelize.TINYINT, allowNull: false, defaultValue: 1, comment: '状态:1启用 0禁用' },
sort: { type: Sequelize.INTEGER, allowNull: false, defaultValue: 0, comment: '排序(下拉展示顺序,越小越靠前)' },
remark: { type: Sequelize.STRING(255), allowNull: true, comment: '备注' },
created_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP'),
},
updated_at: {
type: Sequelize.DATE,
allowNull: false,
defaultValue: Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'),
},
},
{ charset: 'utf8mb4', collate: 'utf8mb4_unicode_ci', comment: '快递公司字典' }
);
await queryInterface.addIndex('express_companies', {
fields: [ 'code' ],
unique: true,
name: 'uk_express_companies_code',
});
await queryInterface.addIndex('express_companies', { fields: [ 'status', 'sort' ], name: 'idx_express_companies_status_sort' });
},
async down(queryInterface) {
await queryInterface.dropTable('express_companies');
},
};