WMS_MAIN/database/migrations/20260718170000-fix-supervisor-cs-permissions.js
liufumingren 81350c0d6b fix: 定时任务同步日志 + 基础设施修复 + 权限迁移(收尾)
【定时任务】sync_outbound_orders_to_delivery: 执行日志写缓存 + 错误详情提取(parent/validation)

【基础设施】system.js: snake_case→camelCase 服务路由转换(兼容 express_interface 等)

【看板】dashboard: queryWarehouseStats 支持 storeId 货主维度过滤

【订单基类】order/base: getOrderModel 兼容无上下文时传入 warehouseId(货主侧场景)

【库存】inventory: 全量移库软删除→硬删除(force destroy)释放唯一键 + 唯一约束/校验错误友好提示

【快递平台】express_platform: KS(快手)平台 receiver.phone 不传(平台要求)

【迁移】delivery 自增起点 + supervisor CS 权限修复
2026-07-27 03:49:27 +08:00

58 lines
3.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 修复:客服组-主管 补充缺失权限,使其不低于下属(客服组-员工)
*
* 背景:
* 迁移 20260608033847 的设计意图是「客服组-主管」与「客服组-员工」权限一致。
* 但后续新增权限时,主管遗漏了 5 个权限,导致员工(162个) > 主管(159个) 的越级现象。
*
* 变更:
* - 客服组-主管 (id=28) 补充 [62, 63, 363, 396, 397] 共 5 个权限
* - 补后:主管 164 个权限 > 员工 162 个权限(主管额外保留 309, 392)
*
* 补充权限明细:
* | ID | 路径 | 名称 | 类型 |
* |-----|-----------------------------------------------|-------------|-----------|
* | 62 | stock.saveWarehouseStock | 保存商品资料 | api |
* | 63 | stock.saveWarehouseStockBarcode | 修改商品条码 | api |
* | 363 | storeWarehouse.store.queryPrintQuantityLogs | 货主面单余额 | api |
* | 396 | shipperSigning | 外部仓库 | web_pages |
* | 397 | storeWarehouse.store.confirmSign | 签约确定 | api |
*/
const TABLE = 'wms_role';
const ROLE_ID = 28;
const NEW_PERMISSIONS = '[1,4,8,9,11,12,13,14,15,17,18,19,20,21,22,24,25,26,27,29,30,38,39,40,41,43,44,45,46,47,48,49,50,54,62,63,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,244,254,255,256,278,281,283,290,291,292,293,294,295,296,297,298,299,300,303,304,305,306,307,308,309,333,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,356,357,361,363,367,368,369,370,371,372,373,374,375,376,377,379,380,381,382,383,384,386,387,388,389,390,391,392,396,397,416,417,418,420,421,422,424,425,426,427,428,429,430,431,432]';
const OLD_PERMISSIONS = '[1,4,8,9,11,12,13,14,15,17,18,19,20,21,22,24,25,26,27,29,30,38,39,40,41,43,44,45,46,47,48,49,50,54,72,73,74,75,76,77,78,79,80,81,82,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,244,254,255,256,278,281,283,290,291,292,293,294,295,296,297,298,299,300,303,304,305,306,307,308,309,333,335,336,337,338,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353,354,356,357,361,367,368,369,370,371,372,373,374,375,376,377,379,380,381,382,383,384,386,387,388,389,390,391,392,416,417,418,420,421,422,424,425,426,427,428,429,430,431,432]';
/**
* @param {import('sequelize').QueryInterface} queryInterface
*/
module.exports.up = async queryInterface => {
const [result] = await queryInterface.sequelize.query(
`UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW()
WHERE id = :id AND is_system = 1`,
{ replacements: { id: ROLE_ID, permissions: NEW_PERMISSIONS } }
);
const affected = result?.affectedRows ?? result?.rowCount ?? result?.changedRows ?? 0;
console.log(`[Migration] 客服组-主管(id=${ROLE_ID}) 权限补充:补充 5 个权限,实际更新 ${affected} 行`);
};
/**
* @param {import('sequelize').QueryInterface} queryInterface
*/
module.exports.down = async queryInterface => {
const [result] = await queryInterface.sequelize.query(
`UPDATE \`${TABLE}\` SET permissions = :permissions, updated_at = NOW()
WHERE id = :id AND is_system = 1`,
{ replacements: { id: ROLE_ID, permissions: OLD_PERMISSIONS } }
);
const affected = result?.affectedRows ?? result?.rowCount ?? result?.changedRows ?? 0;
console.log(`[Migration] 客服组-主管(id=${ROLE_ID}) 权限回滚:实际回滚 ${affected} 行`);
};