- 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 脚本: 接口文档与权限同步
48 lines
1.8 KiB
JavaScript
48 lines
1.8 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 补齐全部系统级子类型的系统级回复配置(幂等,先查后插)。
|
||
*
|
||
* - 对每个系统级子类型(warehouse_id IS NULL)补一条系统级回复:
|
||
* reply='{back_text}'(默认走函数返回内容兜底,help 类占位渲染),
|
||
* is_reply=1(是否回复统一由回复配置控制)、create_work_order=1、is_enabled=1;
|
||
* - 已存在回复配置的子类型跳过;
|
||
* - 仓库自定义子类型不播种(由仓库自行创建仓库级回复)。
|
||
*/
|
||
|
||
const SUB_TYPE_TABLE = 'wms_after_sale_sub_type';
|
||
const REPLY_TABLE = 'wms_after_sale_reply';
|
||
|
||
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(REPLY_TABLE)) return;
|
||
|
||
const [ subRows ] = await sequelize.query(
|
||
'SELECT id FROM `' + SUB_TYPE_TABLE + '` WHERE warehouse_id IS NULL'
|
||
);
|
||
const [ replyRows ] = await sequelize.query(
|
||
'SELECT sub_type_id FROM `' + REPLY_TABLE + '` WHERE warehouse_id IS NULL'
|
||
);
|
||
const hasReply = new Set(replyRows.map(r => Number(r.sub_type_id)));
|
||
|
||
let inserted = 0;
|
||
for (const row of subRows) {
|
||
const sid = Number(row.id);
|
||
if (hasReply.has(sid)) continue;
|
||
await sequelize.query(
|
||
'INSERT INTO `' + REPLY_TABLE + '` (warehouse_id, sub_type_id, reply, is_reply, create_work_order, no_number_hint, is_enabled, created_at, updated_at) VALUES (NULL, :sid, :reply, 1, 1, NULL, 1, NOW(), NOW())',
|
||
{ replacements: { sid, reply: '{back_text}' } }
|
||
);
|
||
inserted += 1;
|
||
}
|
||
console.log(`[seed-system-reply-all] inserted=${inserted}`);
|
||
},
|
||
|
||
down: async () => {
|
||
// 不回退(系统预设种子)
|
||
},
|
||
};
|