info('开始更新宝箱系统后台菜单...'); // 1. 在游戏物品管理(215)下添加宝箱配置管理菜单 $this->addChestConfigMenu(); // 2. 更新已废弃菜单的状态 $this->updateDeprecatedMenus(); // 3. 添加保底机制相关菜单 $this->addPityMenus(); $this->info('宝箱系统后台菜单更新完成!'); return 0; } /** * 添加宝箱配置管理菜单 */ private function addChestConfigMenu() { // 获取游戏物品管理菜单ID $gameItemsMenu = AdminMenu::where('title', '游戏物品管理') ->where('parent_id', 259) ->first(); if (!$gameItemsMenu) { $this->error('未找到游戏物品管理菜单'); return; } // 获取当前最大order值 $maxOrder = AdminMenu::where('parent_id', $gameItemsMenu->id)->max('order'); $nextOrder = $maxOrder ? $maxOrder + 1 : 35; // 创建宝箱配置管理菜单 $chestConfigMenu = AdminMenu::firstOrCreate( [ 'title' => '宝箱配置管理', 'parent_id' => $gameItemsMenu->id ], [ 'uri' => 'game-items/chest-configs', 'icon' => 'fa-treasure-chest', 'order' => $nextOrder, 'show' => 1 ] ); $this->info("✓ 添加宝箱配置管理菜单: {$chestConfigMenu->title}, ID: {$chestConfigMenu->id}"); } /** * 更新已废弃菜单的状态 */ private function updateDeprecatedMenus() { // 标记已废弃的菜单项(不删除,只是标记为不显示或添加说明) $deprecatedMenus = [ '宝箱消耗配置' => 'game-items-chest-costs', '宝箱内容' => 'game-items-chest-contents' ]; foreach ($deprecatedMenus as $title => $uri) { $menu = AdminMenu::where('title', $title)->where('uri', $uri)->first(); if ($menu) { // 更新标题,添加废弃标记 $newTitle = $title . ' (已废弃)'; $menu->update([ 'title' => $newTitle, 'show' => 0 // 隐藏菜单 ]); $this->info("✓ 标记废弃菜单: {$title} -> {$newTitle}"); } } } /** * 添加保底机制相关菜单 */ private function addPityMenus() { // 在游戏运营管理 -> 游戏物品管理(423)下添加保底相关菜单 $gameItemsManageMenu = AdminMenu::where('id', 423)->first(); if (!$gameItemsManageMenu) { $this->error('未找到游戏运营管理下的游戏物品管理菜单'); return; } // 获取当前最大order值 $maxOrder = AdminMenu::where('parent_id', $gameItemsManageMenu->id)->max('order'); $nextOrder = $maxOrder ? $maxOrder + 1 : 73; // 创建奖励组保底计数菜单 $pityCountMenu = AdminMenu::firstOrCreate( [ 'title' => '奖励组保底计数', 'parent_id' => $gameItemsManageMenu->id ], [ 'uri' => 'game/reward-group-pity-counts', 'icon' => 'fa-chart-line', 'order' => $nextOrder, 'show' => 1 ] ); $this->info("✓ 添加奖励组保底计数菜单: {$pityCountMenu->title}, ID: {$pityCountMenu->id}"); // 更新原有的"用户宝箱保底计数"菜单标题 $oldPityMenu = AdminMenu::where('title', '用户宝箱保底计数')->first(); if ($oldPityMenu) { $oldPityMenu->update([ 'title' => '用户宝箱保底计数 (旧系统)', 'show' => 0 // 隐藏旧系统菜单 ]); $this->info("✓ 更新旧保底菜单: 用户宝箱保底计数 -> 用户宝箱保底计数 (旧系统)"); } } }