- functions.js: 拦截/取消拦截波次感知写订单日志 businessId 误用仓库 ID,改为订单 ID (生产订单 JY2026091813795 已发起拦截但订单详情查不到拦截日志的根因) - rules/v2/processor/config/functionSync: 新增 help 指令、create_work_order=0 时跳过 工单登记、系统级回复与无单号提示、白名单范围修正 - after_sale_reply 模型 + 6 个迁移: create_work_order 字段与相关配置种子 - return_unpack: 列表 count 统计修复、分页排序追加主键防重漏行、视频附加 camera_name - methods/system.json + changes + sync 脚本: 接口文档与权限同步
64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 修正系统级「取号失败引导语」范围(幂等,按子类型取号规则重算):
|
||
* - 子类型关联了 target='express_name' 取号规则(如 change_carrier)→ 快递指定提示;
|
||
* - 子类型关联了其他取号规则 → 默认运单号提示;
|
||
* - 子类型无任何取号规则(如 help 指令、无取号环节的类型)→ 清空(取号失败分支不会触发,展示空)。
|
||
*/
|
||
|
||
const REPLY_TABLE = 'wms_after_sale_reply';
|
||
const REL_TABLE = 'wms_after_sale_sub_type_rule';
|
||
const RULE_TABLE = 'wms_inbox_number_rule';
|
||
|
||
const HINT_EXPRESS = '请指定目标快递(圆通/中通/申通/顺丰/韵达/极兔/邮政/EMS/京东/德邦)';
|
||
const HINT_DEFAULT = '请提供运单号(发送:指令+运单号,多个单号用逗号或空格分隔)';
|
||
|
||
module.exports = {
|
||
up: async queryInterface => {
|
||
const { sequelize } = queryInterface;
|
||
const tables = await queryInterface.showAllTables();
|
||
const exists = t => tables.some(x => (typeof x === 'string' ? x : x.tableName) === t);
|
||
if (!exists(REPLY_TABLE)) return;
|
||
|
||
let expressIds = new Set();
|
||
let ruleIds = new Set();
|
||
if (exists(REL_TABLE) && exists(RULE_TABLE)) {
|
||
const [ exRows ] = await sequelize.query(
|
||
'SELECT DISTINCT rel.sub_type_id FROM `' + REL_TABLE + '` rel ' +
|
||
'JOIN `' + RULE_TABLE + '` r ON r.id = rel.number_rule_id WHERE r.target = :t',
|
||
{ replacements: { t: 'express_name' } }
|
||
);
|
||
expressIds = new Set(exRows.map(r => Number(r.sub_type_id)));
|
||
const [ anyRows ] = await sequelize.query(
|
||
'SELECT DISTINCT sub_type_id FROM `' + REL_TABLE + '`'
|
||
);
|
||
ruleIds = new Set(anyRows.map(r => Number(r.sub_type_id)));
|
||
}
|
||
|
||
const [ rows ] = await sequelize.query(
|
||
'SELECT id, sub_type_id FROM `' + REPLY_TABLE + '` WHERE warehouse_id IS NULL'
|
||
);
|
||
|
||
let updated = 0;
|
||
let cleared = 0;
|
||
for (const row of rows) {
|
||
const sid = Number(row.sub_type_id);
|
||
let hint = null;
|
||
if (expressIds.has(sid)) hint = HINT_EXPRESS;
|
||
else if (ruleIds.has(sid)) hint = HINT_DEFAULT;
|
||
if (hint === null) cleared += 1;
|
||
await sequelize.query(
|
||
'UPDATE `' + REPLY_TABLE + '` SET no_number_hint = :hint WHERE id = :id',
|
||
{ replacements: { hint, id: row.id } }
|
||
);
|
||
updated += 1;
|
||
}
|
||
console.log(`[fix-no-number-hint-scope] updated=${updated} cleared=${cleared}`);
|
||
},
|
||
|
||
down: async () => {
|
||
// 不回退(数据修正)
|
||
},
|
||
};
|