【新增模块】 - app/model/store_express_binding_policy.js: 策略数据模型(17字段,JSON数组) - app/service/systems/store_express_binding_policy.js: CRUD+列表(含名称批量解析) - app/service/systems/express_policy.js: 缓存优先策略查询 + 6维漏斗匹配引擎 - app/service/systemMethods/store_express_binding_policy.js: method路由层 - database/designs/store-express-binding-policy-design.md: 设计文档 【策略漏斗匹配逻辑】 - 按priority DESC逐条匹配: store_ids→shop_name→prohibited→regions→exclude→weight - NULL/空数组=不限, 未命中自动continue到下一条 - 地区/店铺匹配使用子串包含(省/市/区/详细地址均生效) - 违禁品匹配使用数组交集 - 输出快递编码+重量类型, 未命中返回null 【订单创建链路集成】 - addOrder→addOrderLines后触发matchPolicy(weight可用) - 命中: 写入logistics/sys_logistics 4字段+weight_type+操作日志 - 未命中: 降级到resolveExpressSnapshot默认值+兜底DEFAULT_STORE_SUBJECT_CONFIG(STO) - 系统快递4字段一致, 自定义映射(express_setting)分流写入 【运单号分配优化】 - pickWaybillExpressInterface两步兜底: Step1: logistics_code仅匹配express_code(自定义编码精确) Step2: sys_logistics_code匹配全候选码(系统编码兜底) - 新增weight_type过滤器(接口NULL=通配, 设限须精确匹配) - groupedOrder.options新增sys_logistics_code/weight_type传递 【操作码翻译】 - ORDER_EXPRESS_POLICY_MATCH: '策略命中' - ORDER_EXPRESS_FALLBACK: '快递降级' - 无策略命中时写入快递降级日志 【API文档】 - methods/system.json: 策略模块4接口+响应字段(express_name/数组类型等) 【数据库迁移】 - 13个migration: 建表→字段迭代→TEXT改JSON→prohibited改数组(dev+prod均执行)
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
'use strict';
|
||
|
||
const TABLE_NAME = 'wms_store_express_binding_policy';
|
||
|
||
module.exports = {
|
||
up: async (queryInterface, Sequelize) => {
|
||
await queryInterface.removeColumn(TABLE_NAME, 'match_condition');
|
||
await queryInterface.addColumn(TABLE_NAME, 'provinces', {
|
||
type: Sequelize.TEXT,
|
||
allowNull: true,
|
||
comment: '限定省份,逗号分隔,如"广东省,浙江省",NULL=不限制',
|
||
after: 'is_enabled',
|
||
});
|
||
await queryInterface.addColumn(TABLE_NAME, 'cities', {
|
||
type: Sequelize.TEXT,
|
||
allowNull: true,
|
||
comment: '限定城市,逗号分隔,如"广州市,杭州市",NULL=不限制',
|
||
after: 'provinces',
|
||
});
|
||
},
|
||
|
||
down: async (queryInterface, Sequelize) => {
|
||
await queryInterface.removeColumn(TABLE_NAME, 'cities');
|
||
await queryInterface.removeColumn(TABLE_NAME, 'provinces');
|
||
await queryInterface.addColumn(TABLE_NAME, 'match_condition', {
|
||
type: Sequelize.JSON,
|
||
allowNull: true,
|
||
comment: '附加匹配条件(JSON)',
|
||
});
|
||
},
|
||
};
|