- 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 脚本: 接口文档与权限同步
57 lines
2.1 KiB
JavaScript
57 lines
2.1 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* help(指令)子类型群白名单改为通配:所有群都支持(幂等)。
|
||
*
|
||
* 原播种为 store.after_sales / warehouse.customer_service / express.after_sales 三条精确白名单,
|
||
* 其他群子类型(如 store.receiving)无法触发指令。改为 group_type='*' 通配行,
|
||
* 引擎 _groupAllowed 对 '*' 直接放行;help 函数 groups=[COMMON] 本身所有群可用。
|
||
*/
|
||
|
||
const SUB_TYPE_TABLE = 'wms_after_sale_sub_type';
|
||
const REL_GROUP_TABLE = 'wms_after_sale_sub_type_group';
|
||
|
||
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(SUB_TYPE_TABLE) || !exists(REL_GROUP_TABLE)) return;
|
||
|
||
const q1 = async (sql, replacements) => {
|
||
const [ rows ] = await sequelize.query(sql, { replacements });
|
||
return rows && rows.length > 0 ? rows[0] : null;
|
||
};
|
||
|
||
const sub = await q1(
|
||
'SELECT id FROM `' + SUB_TYPE_TABLE + '` WHERE type = :t AND sub_type = :s AND warehouse_id IS NULL LIMIT 1',
|
||
{ t: 'help', s: 'instruction' }
|
||
);
|
||
if (!sub) return;
|
||
const sid = sub.id;
|
||
|
||
const wildcard = await q1(
|
||
'SELECT id FROM `' + REL_GROUP_TABLE + '` WHERE sub_type_id = :s AND group_type = :g LIMIT 1',
|
||
{ s: sid, g: '*' }
|
||
);
|
||
if (wildcard) {
|
||
console.log('[help-whitelist-all-groups] 已存在通配白名单,跳过');
|
||
return;
|
||
}
|
||
|
||
const [ del ] = await sequelize.query(
|
||
'DELETE FROM `' + REL_GROUP_TABLE + '` WHERE sub_type_id = :s',
|
||
{ replacements: { s: sid } }
|
||
);
|
||
await sequelize.query(
|
||
'INSERT INTO `' + REL_GROUP_TABLE + '` (sub_type_id, group_type, sub_group, is_system, sort_order, created_at, updated_at) VALUES (:s, :g, :sg, 1, 0, NOW(), NOW())',
|
||
{ replacements: { s: sid, g: '*', sg: '' } }
|
||
);
|
||
console.log(`[help-whitelist-all-groups] deleted=${del.affectedRows || 0} inserted-wildcard=1`);
|
||
},
|
||
|
||
down: async () => {
|
||
// 不回退(语义修正)
|
||
},
|
||
};
|