oms/backend/database/migrations/20261104010000-create-custom-express-codes.js
liufumingren eaf957ed14 feat(express): 外部打单快递接口、自定义快递编码与回 OMS 取号
- 外部打单平台快递接口:按账号同步平台模板、绑定快递编码、查看模板明细;打开列表只读库,仅「从平台同步数据」时拉取
- 系统管理新增自定义快递编码字典,订单改快递 / 物流下拉合并系统与自定义编码,推送奇门沿用订单上的编码
- 新增 OpenAPI deliveryorder.getwaybill:WMS 批量回取号(单次≤100、并发4、逐单结果),快递编码只取 WMS 报文,取消/作废/归档返回失败,已取号直接复用
- 新增 openapi_request_idempotency 请求级幂等:request_id 回放、报文摘要校验、30 分钟 stale 接管、7 天定时清理
- 外部打单平台订单按平台 fetch_waybill_no 下发 need_oms_waybill,推送时实时判定并回写单据
- 店铺、打单账号平台配置与「平台+编码→模板」绑定走 Redis 缓存,绑定/账号变更主动失效,避免批量推送与取号逐单查库

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-04 04:10:37 +08:00

74 lines
2.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';
/**
* 自定义快递编码字典。
*
* 由「系统管理 → 自定义快递编码」维护(全局字典,不区分主体):
* - code:自定义编码(订单 logistics_code 直接写这个值,推送奇门时原样下发)
* - name:自定义名称(订单 logistics_name 直接写这个值)
* - express_code:对应的系统快递编码(express_companies.code,便于对账与映射)
*
* 订单选择自定义快递后,logistics_code / logistics_name 保存自定义值,
* 推送 WMS(奇门 deliveryOrder.logisticsCode / logisticsName)时保持自定义值不变。
*/
module.exports = {
async up(queryInterface, Sequelize) {
await queryInterface.createTable('custom_express_codes', {
id: {
type: Sequelize.BIGINT.UNSIGNED,
primaryKey: true,
autoIncrement: true,
comment: '主键',
},
code: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '自定义快递编码(订单 logistics_code)',
},
name: {
type: Sequelize.STRING(100),
allowNull: false,
comment: '自定义快递名称(订单 logistics_name)',
},
express_code: {
type: Sequelize.STRING(50),
allowNull: false,
comment: '对应的系统快递编码(express_companies.code)',
},
sort: {
type: Sequelize.INTEGER,
allowNull: false,
defaultValue: 0,
comment: '排序(下拉展示顺序,越小越靠前)',
},
status: {
type: Sequelize.TINYINT,
allowNull: false,
defaultValue: 1,
comment: '状态:1启用 0禁用',
},
remark: {
type: Sequelize.STRING(255),
allowNull: true,
comment: '备注',
},
created_at: { type: Sequelize.DATE, allowNull: true, comment: '创建时间' },
updated_at: { type: Sequelize.DATE, allowNull: true, comment: '更新时间' },
});
await queryInterface.addIndex('custom_express_codes', [ 'code' ], {
name: 'uk_custom_express_codes_code',
unique: true,
});
await queryInterface.addIndex('custom_express_codes', [ 'express_code' ], {
name: 'idx_custom_express_codes_express_code',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('custom_express_codes', 'idx_custom_express_codes_express_code');
await queryInterface.removeIndex('custom_express_codes', 'uk_custom_express_codes_code');
await queryInterface.dropTable('custom_express_codes');
},
};