|
|
@@ -0,0 +1,192 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace App\Module\Mex\Commands;
|
|
|
+
|
|
|
+use Illuminate\Console\Command;
|
|
|
+use Illuminate\Support\Facades\DB;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Mex模块后台菜单添加命令
|
|
|
+ *
|
|
|
+ * 为Mex模块添加完整的后台管理菜单
|
|
|
+ */
|
|
|
+class MexAddAdminMenuCommand extends Command
|
|
|
+{
|
|
|
+ /**
|
|
|
+ * 命令签名
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $signature = 'mex:add-admin-menu';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 命令描述
|
|
|
+ *
|
|
|
+ * @var string
|
|
|
+ */
|
|
|
+ protected $description = '为Mex模块添加后台管理菜单';
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行命令
|
|
|
+ *
|
|
|
+ * @return int
|
|
|
+ */
|
|
|
+ public function handle(): int
|
|
|
+ {
|
|
|
+ $this->info('开始添加Mex模块后台菜单...');
|
|
|
+
|
|
|
+ try {
|
|
|
+ DB::transaction(function () {
|
|
|
+ $this->addMexMenus();
|
|
|
+ });
|
|
|
+
|
|
|
+ $this->info('✅ Mex模块后台菜单添加成功!');
|
|
|
+ return Command::SUCCESS;
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ $this->error('❌ 添加菜单失败:' . $e->getMessage());
|
|
|
+ return Command::FAILURE;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加Mex模块菜单
|
|
|
+ */
|
|
|
+ private function addMexMenus(): void
|
|
|
+ {
|
|
|
+ // 1. 查找或创建"游戏运营管理"父菜单
|
|
|
+ $gameManageParent = DB::table('admin_menu')
|
|
|
+ ->where('title', '游戏运营管理')
|
|
|
+ ->where('parent_id', 0)
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if (!$gameManageParent) {
|
|
|
+ $this->info('创建"游戏运营管理"父菜单...');
|
|
|
+ $gameManageParentId = DB::table('admin_menu')->insertGetId([
|
|
|
+ 'parent_id' => 0,
|
|
|
+ 'order' => 400,
|
|
|
+ 'title' => '游戏运营管理',
|
|
|
+ 'icon' => 'fa-gamepad',
|
|
|
+ 'uri' => '',
|
|
|
+ 'show' => 1,
|
|
|
+ 'created_at' => now(),
|
|
|
+ 'updated_at' => now(),
|
|
|
+ ]);
|
|
|
+ } else {
|
|
|
+ $gameManageParentId = $gameManageParent->id;
|
|
|
+ $this->info('找到现有"游戏运营管理"父菜单 (ID: ' . $gameManageParentId . ')');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. 创建"农贸市场管理"子菜单
|
|
|
+ $mexParentExists = DB::table('admin_menu')
|
|
|
+ ->where('title', '农贸市场管理')
|
|
|
+ ->where('parent_id', $gameManageParentId)
|
|
|
+ ->exists();
|
|
|
+
|
|
|
+ if ($mexParentExists) {
|
|
|
+ $this->warn('⚠️ "农贸市场管理"菜单已存在,跳过创建');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->info('创建"农贸市场管理"子菜单...');
|
|
|
+ $mexParentId = DB::table('admin_menu')->insertGetId([
|
|
|
+ 'parent_id' => $gameManageParentId,
|
|
|
+ 'order' => 50,
|
|
|
+ 'title' => '农贸市场管理',
|
|
|
+ 'icon' => 'fa-store',
|
|
|
+ 'uri' => '',
|
|
|
+ 'show' => 1,
|
|
|
+ 'created_at' => now(),
|
|
|
+ 'updated_at' => now(),
|
|
|
+ ]);
|
|
|
+
|
|
|
+ // 3. 添加Mex模块的具体功能菜单
|
|
|
+ $mexMenus = [
|
|
|
+ [
|
|
|
+ 'title' => '📋 订单管理',
|
|
|
+ 'icon' => 'fa-list-alt',
|
|
|
+ 'uri' => 'mex-orders',
|
|
|
+ 'order' => 10,
|
|
|
+ 'description' => '管理用户买入和卖出订单'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'title' => '💰 价格配置',
|
|
|
+ 'icon' => 'fa-tags',
|
|
|
+ 'uri' => 'mex-price-configs',
|
|
|
+ 'order' => 20,
|
|
|
+ 'description' => '配置商品价格范围和保护阈值'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'title' => '📊 成交记录',
|
|
|
+ 'icon' => 'fa-chart-line',
|
|
|
+ 'uri' => 'mex-transactions',
|
|
|
+ 'order' => 30,
|
|
|
+ 'description' => '查看撮合成交记录'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'title' => '🏪 仓库管理',
|
|
|
+ 'icon' => 'fa-warehouse',
|
|
|
+ 'uri' => 'mex-warehouse',
|
|
|
+ 'order' => 40,
|
|
|
+ 'description' => '管理仓库库存和统计'
|
|
|
+ ],
|
|
|
+ [
|
|
|
+ 'title' => '👨💼 管理员操作',
|
|
|
+ 'icon' => 'fa-user-shield',
|
|
|
+ 'uri' => 'mex-admin-operations',
|
|
|
+ 'order' => 50,
|
|
|
+ 'description' => '查看管理员操作记录'
|
|
|
+ ],
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach ($mexMenus as $menu) {
|
|
|
+ $this->info("添加菜单:{$menu['title']}");
|
|
|
+ DB::table('admin_menu')->insert([
|
|
|
+ 'parent_id' => $mexParentId,
|
|
|
+ 'order' => $menu['order'],
|
|
|
+ 'title' => $menu['title'],
|
|
|
+ 'icon' => $menu['icon'],
|
|
|
+ 'uri' => $menu['uri'],
|
|
|
+ 'show' => 1,
|
|
|
+ 'created_at' => now(),
|
|
|
+ 'updated_at' => now(),
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->info('✅ 所有Mex模块菜单添加完成');
|
|
|
+
|
|
|
+ // 4. 显示菜单结构
|
|
|
+ $this->showMenuStructure($gameManageParentId, $mexParentId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示菜单结构
|
|
|
+ */
|
|
|
+ private function showMenuStructure(int $gameManageParentId, int $mexParentId): void
|
|
|
+ {
|
|
|
+ $this->info('');
|
|
|
+ $this->info('📋 菜单结构:');
|
|
|
+
|
|
|
+ $gameManageMenu = DB::table('admin_menu')->find($gameManageParentId);
|
|
|
+ $this->line("├── {$gameManageMenu->title} (ID: {$gameManageMenu->id})");
|
|
|
+
|
|
|
+ $mexParentMenu = DB::table('admin_menu')->find($mexParentId);
|
|
|
+ $this->line(" ├── {$mexParentMenu->title} (ID: {$mexParentMenu->id})");
|
|
|
+
|
|
|
+ $mexSubMenus = DB::table('admin_menu')
|
|
|
+ ->where('parent_id', $mexParentId)
|
|
|
+ ->orderBy('order')
|
|
|
+ ->get();
|
|
|
+
|
|
|
+ foreach ($mexSubMenus as $index => $menu) {
|
|
|
+ $isLast = $index === count($mexSubMenus) - 1;
|
|
|
+ $prefix = $isLast ? ' └──' : ' ├──';
|
|
|
+ $this->line("{$prefix} {$menu->title} (/{$menu->uri})");
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->info('');
|
|
|
+ $this->info('🔗 访问路径:');
|
|
|
+ foreach ($mexSubMenus as $menu) {
|
|
|
+ $this->line(" - {$menu->title}: /admin/{$menu->uri}");
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|