-- 业绩看板（fans/yeji）：把 3 个后端接口权限挂到现有菜单 id=293（name='数据统计', component='fans/yeji'）下
-- 已存在则跳过，幂等

-- 1) 标准化页面菜单本身：补 perms 占位（保持页面权限码与 component 对应，便于后续按页面授权）
UPDATE `zyt_system_menu`
SET `perms` = 'fans/yeji'
WHERE `id` = 293 AND (`perms` IS NULL OR `perms` = '');

-- 2) 接口：业绩看板单区间 overview
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩-单区间', '', 1,
    'stats.yejiStats/overview', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM dual
WHERE NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` m
    WHERE m.pid = 293 AND m.perms = 'stats.yejiStats/overview'
);

-- 3) 接口：业绩看板多区间 multi（默认 月/周/今日/昨日）
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩-多区间', '', 2,
    'stats.yejiStats/multi', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM dual
WHERE NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` m
    WHERE m.pid = 293 AND m.perms = 'stats.yejiStats/multi'
);

-- 4) 接口：业绩看板部门下拉
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩-部门下拉', '', 3,
    'stats.yejiStats/deptOptions', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM dual
WHERE NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` m
    WHERE m.pid = 293 AND m.perms = 'stats.yejiStats/deptOptions'
);

-- 5) 接口：业绩看板渠道下拉
INSERT INTO `zyt_system_menu`
(`pid`, `type`, `name`, `icon`, `sort`, `perms`, `paths`, `component`, `selected`, `params`, `is_show`, `is_disable`, `create_time`, `update_time`)
SELECT
    293, 'A', '业绩-渠道下拉', '', 4,
    'stats.yejiStats/channelOptions', '', '', '', '',
    1, 0, UNIX_TIMESTAMP(), UNIX_TIMESTAMP()
FROM dual
WHERE NOT EXISTS (
    SELECT 1 FROM `zyt_system_menu` m
    WHERE m.pid = 293 AND m.perms = 'stats.yejiStats/channelOptions'
);
