- 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 脚本: 接口文档与权限同步
60 lines
2.3 KiB
JavaScript
60 lines
2.3 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 补齐系统级回复配置的「取号失败引导语」基础配置(幂等,只填空值行)。
|
||
*
|
||
* 现状:系统级回复行 no_number_hint 全部为 NULL,取号失败时依赖代码内置默认值。
|
||
* 本次把基础引导语写入系统级配置:
|
||
* - 子类型关联了 target='express_name' 取号规则(如 change_carrier 改快递)→ 快递指定提示;
|
||
* - 其余子类型 → 默认运单号提示。
|
||
* 仓库级行不处理(留空时仍走代码兜底)。
|
||
*/
|
||
|
||
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;
|
||
|
||
// 关联 express_name 取号规则的子类型集合
|
||
let expressIds = new Set();
|
||
if (exists(REL_TABLE) && exists(RULE_TABLE)) {
|
||
const [ relRows ] = 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(relRows.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 AND (no_number_hint IS NULL OR no_number_hint = :empty)',
|
||
{ replacements: { empty: '' } }
|
||
);
|
||
|
||
let updated = 0;
|
||
for (const row of rows) {
|
||
const hint = expressIds.has(Number(row.sub_type_id)) ? HINT_EXPRESS : HINT_DEFAULT;
|
||
await sequelize.query(
|
||
'UPDATE `' + REPLY_TABLE + '` SET no_number_hint = :hint WHERE id = :id',
|
||
{ replacements: { hint, id: row.id } }
|
||
);
|
||
updated += 1;
|
||
}
|
||
console.log(`[seed-system-no-number-hint] updated=${updated}`);
|
||
},
|
||
|
||
down: async () => {
|
||
// 不回退(系统预设种子)
|
||
},
|
||
};
|