-- 奖励配置：档位结算推荐配置（T1-T5 推荐金额、按规则生成）按钮权限
-- 挂载在「奖励配置」菜单（type=2）下；slug 与 DiceRewardConfigController Permission 一致

SET @now = NOW();

SET @reward_menu_id = (
  SELECT `id` FROM `sa_system_menu`
  WHERE `type` = 2
    AND (
      `path` = 'reward_config'
      OR `component` LIKE '%reward_config%'
    )
  ORDER BY `id` ASC
  LIMIT 1
);

INSERT INTO `sa_system_menu`
(`parent_id`,`name`,`code`,`slug`,`type`,`path`,`component`,`method`,`sort`,`is_iframe`,`is_keep_alive`,`is_hidden`,`is_fixed_tab`,`is_full_page`,`generate_id`,`generate_key`,`status`,`create_time`,`update_time`)
SELECT @reward_menu_id, '档位结算推荐配置', '', 'dice:reward_config:index:tierRecommend', 3, '', '', '', 95, 2, 2, 2, 2, 2, 0, NULL, 1, @now, @now
WHERE @reward_menu_id IS NOT NULL
  AND NOT EXISTS (
    SELECT 1 FROM `sa_system_menu` WHERE `slug` = 'dice:reward_config:index:tierRecommend' AND `type` = 3
  );
