# 代理管理菜单路由配置清单

本文档列出了重构后的代理管理菜单路由配置，用于配置到数据库的 `admin_menu` 表中。

## 菜单结构

```
代理管理 (父菜单)
├── 代理列表
├── 推广链接
├── 佣金记录
├── 返佣记录 (新增)
├── 升级记录 (新增)
├── 订单记录 (新增)
├── 提现记录
├── 邀请码管理 (新增)
├── 系统配置 (新增)
├── 实名认证 (新增)
└── 产品配置
```

## 数据库配置说明

**表名**: `admin_menu`

**字段说明**:
- `pid`: 父菜单ID（0表示顶级菜单）
- `name`: 路由名称（Route Name）
- `path`: 路由路径
- `component`: 组件路径（前端视图组件路径）
- `redirect`: 重定向路径（可选）
- `meta`: 元数据JSON字符串，包含 `title`（标题）、`icon`（图标）、`order`（排序）
- `status`: 状态（1=启用，0=禁用）
- `type`: 菜单类型（catalog=目录，menu=菜单）
- `sort`: 排序号

---

## 1. 父菜单：代理管理

```json
{
  "pid": 0,
  "name": "Agent",
  "path": "/agent",
  "component": "",
  "redirect": "",
  "meta": "{\"title\":\"代理管理\",\"icon\":\"mdi:account-group\",\"order\":2000}",
  "status": 1,
  "type": "catalog",
  "sort": 2000
}
```

**说明**: 
- 父菜单ID设为 `0` 或插入后获取的实际ID
- `type` 使用字典值 `catalog`（目录类型）
- `component` 留空（因为这是父菜单，不直接渲染组件）

---

## 2. 子菜单配置

### 2.1 代理列表

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentList",
  "path": "/agent/list",
  "component": "/views/agent/agent-list/list",
  "redirect": "",
  "meta": "{\"title\":\"代理列表\",\"icon\":\"mdi:account-multiple\",\"order\":2001}",
  "status": 1,
  "type": "menu",
  "sort": 2001
}
```

### 2.2 推广链接

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentLinks",
  "path": "/agent/links",
  "component": "/views/agent/agent-links/list",
  "redirect": "",
  "meta": "{\"title\":\"推广链接\",\"icon\":\"mdi:link-variant\",\"order\":2002}",
  "status": 1,
  "type": "menu",
  "sort": 2002
}
```

### 2.3 佣金记录

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentCommission",
  "path": "/agent/commission",
  "component": "/views/agent/agent-commission/list",
  "redirect": "",
  "meta": "{\"title\":\"佣金记录\",\"icon\":\"mdi:cash-multiple\",\"order\":2003}",
  "status": 1,
  "type": "menu",
  "sort": 2003
}
```

### 2.4 返佣记录 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentRebate",
  "path": "/agent/rebate",
  "component": "/views/agent/agent-rebate/list",
  "redirect": "",
  "meta": "{\"title\":\"返佣记录\",\"icon\":\"mdi:currency-usd\",\"order\":2004}",
  "status": 1,
  "type": "menu",
  "sort": 2004
}
```

### 2.5 升级记录 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentUpgrade",
  "path": "/agent/upgrade",
  "component": "/views/agent/agent-upgrade/list",
  "redirect": "",
  "meta": "{\"title\":\"升级记录\",\"icon\":\"mdi:arrow-up-circle\",\"order\":2005}",
  "status": 1,
  "type": "menu",
  "sort": 2005
}
```

### 2.6 订单记录 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentOrder",
  "path": "/agent/order",
  "component": "/views/agent/agent-order/list",
  "redirect": "",
  "meta": "{\"title\":\"订单记录\",\"icon\":\"mdi:package-variant\",\"order\":2006}",
  "status": 1,
  "type": "menu",
  "sort": 2006
}
```

### 2.7 提现记录

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentWithdrawal",
  "path": "/agent/withdrawal",
  "component": "/views/agent/agent-withdrawal/list",
  "redirect": "",
  "meta": "{\"title\":\"提现记录\",\"icon\":\"mdi:bank-transfer-out\",\"order\":2007}",
  "status": 1,
  "type": "menu",
  "sort": 2007
}
```

### 2.8 邀请码管理 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentInviteCode",
  "path": "/agent/invite-code",
  "component": "/views/agent/agent-invite-code/list",
  "redirect": "",
  "meta": "{\"title\":\"邀请码管理\",\"icon\":\"mdi:ticket-confirmation\",\"order\":2008}",
  "status": 1,
  "type": "menu",
  "sort": 2008
}
```

### 2.9 系统配置 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentConfig",
  "path": "/agent/config",
  "component": "/views/agent/agent-config/list",
  "redirect": "",
  "meta": "{\"title\":\"系统配置\",\"icon\":\"mdi:cog\",\"order\":2009}",
  "status": 1,
  "type": "menu",
  "sort": 2009
}
```

### 2.10 实名认证 (新增)

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentRealName",
  "path": "/agent/real-name",
  "component": "/views/agent/agent-real-name/list",
  "redirect": "",
  "meta": "{\"title\":\"实名认证\",\"icon\":\"mdi:account-check\",\"order\":2010}",
  "status": 1,
  "type": "menu",
  "sort": 2010
}
```

### 2.11 产品配置

```json
{
  "pid": "[父菜单ID - Agent的ID]",
  "name": "AgentProductConfig",
  "path": "/agent/product-config",
  "component": "/views/agent/agent-product-config/list",
  "redirect": "",
  "meta": "{\"title\":\"产品配置\",\"icon\":\"mdi:package-variant-closed\",\"order\":2011}",
  "status": 1,
  "type": "menu",
  "sort": 2011
}
```

---

## 3. 需要删除的旧菜单 (如果存在)

以下菜单应该从数据库中删除（已移除的功能）：

1. **上级抽佣记录** - `AgentCommissionDeduction`
   - 路径: `/agent/commission-deduction` 或类似路径
   
2. **平台抽佣记录** - `AgentPlatformDeduction`
   - 路径: `/agent/platform-deduction` 或类似路径
   
3. **会员充值订单** - `MembershipRechargeOrder`
   - 路径: `/agent/membership-recharge-order` 或类似路径
   
4. **会员配置** - `AgentMembershipConfig`
   - 路径: `/agent/membership-config` 或类似路径
   
5. **奖励记录** - `AgentReward` (如果存在独立菜单)
   - 路径: `/agent/reward` 或类似路径
   - **注意**: 已被"返佣记录"替代

---

## 4. SQL 插入示例 (MySQL)

假设父菜单ID为 `100`（请根据实际情况替换）：

```sql
-- 插入代理列表
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentList',
  '/agent/list',
  '/views/agent/agent-list/list',
  '',
  '{"title":"代理列表","icon":"mdi:account-multiple","order":2001}',
  1,
  'menu',
  2001,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入推广链接
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentLinks',
  '/agent/links',
  '/views/agent/agent-links/list',
  '',
  '{"title":"推广链接","icon":"mdi:link-variant","order":2002}',
  1,
  'menu',
  2002,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入佣金记录
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentCommission',
  '/agent/commission',
  '/views/agent/agent-commission/list',
  '',
  '{"title":"佣金记录","icon":"mdi:cash-multiple","order":2003}',
  1,
  'menu',
  2003,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入返佣记录 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentRebate',
  '/agent/rebate',
  '/views/agent/agent-rebate/list',
  '',
  '{"title":"返佣记录","icon":"mdi:currency-usd","order":2004}',
  1,
  'menu',
  2004,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入升级记录 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentUpgrade',
  '/agent/upgrade',
  '/views/agent/agent-upgrade/list',
  '',
  '{"title":"升级记录","icon":"mdi:arrow-up-circle","order":2005}',
  1,
  'menu',
  2005,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入订单记录 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentOrder',
  '/agent/order',
  '/views/agent/agent-order/list',
  '',
  '{"title":"订单记录","icon":"mdi:package-variant","order":2006}',
  1,
  'menu',
  2006,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入提现记录
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentWithdrawal',
  '/agent/withdrawal',
  '/views/agent/agent-withdrawal/list',
  '',
  '{"title":"提现记录","icon":"mdi:bank-transfer-out","order":2007}',
  1,
  'menu',
  2007,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入邀请码管理 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentInviteCode',
  '/agent/invite-code',
  '/views/agent/agent-invite-code/list',
  '',
  '{"title":"邀请码管理","icon":"mdi:ticket-confirmation","order":2008}',
  1,
  'menu',
  2008,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入系统配置 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentConfig',
  '/agent/config',
  '/views/agent/agent-config/list',
  '',
  '{"title":"系统配置","icon":"mdi:cog","order":2009}',
  1,
  'menu',
  2009,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入实名认证 (新增)
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentRealName',
  '/agent/real-name',
  '/views/agent/agent-real-name/list',
  '',
  '{"title":"实名认证","icon":"mdi:account-check","order":2010}',
  1,
  'menu',
  2010,
  NOW(),
  NOW(),
  0,
  1
);

-- 插入产品配置
INSERT INTO `admin_menu` (`pid`, `name`, `path`, `component`, `redirect`, `meta`, `status`, `type`, `sort`, `create_time`, `update_time`, `del_state`, `version`)
VALUES (
  100,
  'AgentProductConfig',
  '/agent/product-config',
  '/views/agent/agent-product-config/list',
  '',
  '{"title":"产品配置","icon":"mdi:package-variant-closed","order":2011}',
  1,
  'menu',
  2011,
  NOW(),
  NOW(),
  0,
  1
);
```

---

## 5. 配置步骤

1. **查找或创建父菜单**:
   - 查询数据库中是否已存在 `name = 'Agent'` 且 `path = '/agent'` 的菜单
   - 如果不存在，先插入父菜单（`pid = 0`，`type = 'catalog'`）
   - 记录父菜单的ID，后续子菜单会使用

2. **删除旧菜单** (如果存在):
   - 删除"上级抽佣记录"、"平台抽佣记录"、"会员充值订单"、"会员配置"等旧菜单
   - 如果存在"奖励记录"独立菜单，也删除（已改为"返佣记录"）

3. **更新现有菜单**:
   - 检查并更新现有菜单的路径、组件路径等信息（如有变化）

4. **插入新菜单**:
   - 按照上面的SQL示例插入新的菜单项
   - 确保 `pid` 使用正确的父菜单ID
   - 确保 `sort` 和 `meta.order` 保持一致的排序

5. **验证**:
   - 登录后台管理系统，检查菜单是否正常显示
   - 点击每个菜单项，确认路由跳转正常

---

## 6. 注意事项

1. **菜单类型 (type)**:
   - 父菜单使用 `catalog`（目录类型）
   - 子菜单使用 `menu`（菜单类型）
   - 需要确保这些类型值在系统的字典表 `admin_menu_type` 中存在

2. **组件路径 (component)**:
   - 路径格式为：`/views/agent/xxx/list`
   - 前端会自动添加 `.vue` 后缀

3. **Meta字段格式**:
   - 必须是有效的JSON字符串
   - 包含 `title`（标题）、`icon`（图标）、`order`（排序）

4. **排序号 (sort)**:
   - 建议与 `meta.order` 保持一致
   - 数值越小，排序越靠前

5. **状态 (status)**:
   - `1` = 启用
   - `0` = 禁用

---

## 7. 快速检查清单

- [ ] 父菜单"代理管理"已存在或已创建
- [ ] 已删除旧的菜单项（上级抽佣、平台抽佣、会员充值订单、会员配置）
- [ ] 所有新菜单项已插入数据库
- [ ] 所有菜单项的 `pid` 正确指向父菜单ID
- [ ] 所有菜单项的 `component` 路径正确
- [ ] 所有菜单项的 `meta` JSON格式正确
- [ ] 菜单排序号（sort）设置合理
- [ ] 菜单状态（status）为启用（1）

---

**配置完成后，刷新后台管理系统页面，新的菜单结构就会生效。**

