'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'); }, };