| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
- namespace App\Console\Commands;
- use App\Module\System\Models\AdminMenu;
- use Illuminate\Console\Command;
- class UpdateChestAdminMenu extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'admin:update-chest-menu';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '更新宝箱系统的后台管理菜单';
- /**
- * Execute the console command.
- *
- * @return int
- */
- public function handle()
- {
- $this->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("✓ 更新旧保底菜单: 用户宝箱保底计数 -> 用户宝箱保底计数 (旧系统)");
- }
- }
- }
|