Files
cursor/plans/Plan-8f4c095a.plan.md
ray zhou 2dd9f17da9 ok
2026-06-29 14:51:55 +08:00

123 lines
5.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- 8f4c095a-8532-442e-9af9-213dc997b6aa -->
# 新增平台后,游戏列表在哪里?
## 直接回答
**新增一个平台后,这个平台自己的游戏列表在 `g_game_platform_mapping`管理端「映射列表」Tab不在 `g_platform` 或 `g_game` 里。**
刚建完平台时,这个列表是**空的**——`g_platform` 只存平台元数据code / name / config**不会自动带出上游游戏**。需要后续:
1. **手动新增映射**(映射列表 → 新增映射 → 选该平台)
2.**跑平台游戏导入/同步**slot-pwa 有 POP 导入命令saas6.x 尚未接入)
所以不是缺 `g_game_platform` 表,而是:**平台实体与平台游戏池是两张逻辑表,且 UI 没有把两者串起来。**
---
## 三张表各自管什么
```mermaid
flowchart LR
subgraph platformMeta [平台主数据]
g_platform["g_platform\n平台代码/配置"]
end
subgraph platformGames [平台游戏池]
mapping["g_game_platform_mapping\n该平台上的上游游戏\n含 game_id=0 待关联"]
end
subgraph lobbyGames [大厅游戏]
g_game["g_game\n大厅展示游戏\nactive_platform_id"]
end
g_platform -->|"platform_id"| mapping
g_game -->|"game_id 绑定后"| mapping
g_platform -->|"active_platform_id"| g_game
```
| 你想看的 | 存在哪 | 管理端入口 | 新建平台后 |
|---|---|---|---|
| **这个平台有哪些上游游戏**(含待绑定) | `g_game_platform_mapping` where `platform_id = X` | 游戏库 → **映射列表** → 筛「平台」 | **空**,需导入或手建 |
| **大厅里哪些游戏走这个平台** | `g_game` where `active_platform_id = X` | 游戏库 → **游戏列表** → 筛「当前生效平台」 | **空**,需先有大厅游戏并指定平台 |
| **平台本身配置** | `g_platform` | 游戏库 → **平台列表** | 只有这一条平台记录 |
### `game_id = 0` 就是「平台游戏池」
`g_game_platform_mapping``game_id = 0` 的记录,表示**上游已导入、尚未绑定大厅游戏**的条目POP 导入后的默认状态)。
因此 **`g_game_platform_mapping` 同时承担「平台游戏目录 + 绑定关系」**,不需要再建 `g_game_platform`
slot-pwa 导入逻辑见 [`PopGameImportService`](../../ray/slot-pwa/app/service/game/PopGameImportService.php)
> 从 pop_provider.php 导入 POP 游戏至 **g_game_platform_mapping**(不自动新建 g_game
---
## 为什么你会觉得「没地方看」
当前 saas6.x 游戏库是 4 个平级 Tab[`gameLibrary/index.vue`](admin-vue/src/views/admin/gameAccess/gameLibrary/index.vue)
- 游戏列表
- 分类列表
- **映射列表** ← 平台游戏实际在这里
- **平台列表** ← 只有平台配置,无游戏子列表、无跳转
缺口是 **UX / 流程**,不是表结构:
1. 平台 Tab 没有「查看该平台游戏」入口
2. 平台 Tab 没有显示映射数量
3. saas6.x **没有**平台游戏导入/同步能力(老项目靠 slot-pwa 命令写入 mapping
4. 「映射列表」命名不直观,不像「平台游戏池」
---
## 推荐改进(若要做)
### 方案 A最小改动只改 UI不动表
在 [`platform-tab.vue`](admin-vue/src/views/admin/gameAccess/gameLibrary/modules/platform-tab.vue)
- 增加列:`映射总数` / `待关联数` / `已绑定数`(聚合 `g_game_platform_mapping`
- 操作列增加 **「查看游戏」**:切到映射 Tab 并带上 `platform_id` 筛选(可用 `usePageTabs` 跨 Tab 传参或 query
后端:在 [`GPlatformController::index`](server/app/controller/game/GPlatformController.php) 列表响应里批量附加统计字段(一次 `GROUP BY platform_id` 查询,避免 N+1
### 方案 B补导入流程与老项目对齐
- 移植或封装 slot-pwa 的 `PopGameImportService` / `PopGameCatalogSyncService`
- 管理端平台行增加 **「同步上游游戏」** 按钮(或独立命令行入口)
- 同步结果写入 `g_game_platform_mapping``game_id` 先为 0运营再在映射里绑定 `g_game`
### 方案 C不推荐 — 新建 `g_game_platform` 表
会把「平台游戏目录」与「绑定关系」拆成两张表,与 slot 全链路admin / pwa / console不一致`g_game_platform_mapping` 已覆盖该职责。除非有**租户级平台开通实例**等新需求,否则不建议。
---
## 运营侧标准流程(现有模型下)
```mermaid
sequenceDiagram
participant Op as 运营
participant Platform as g_platform
participant Mapping as g_game_platform_mapping
participant Game as g_game
Op->>Platform: 1. 新增平台 code/config
Note over Mapping: 此时为空
Op->>Mapping: 2a. 手动新增映射 或 2b. 跑导入同步
Note over Mapping: game_id=0 待关联
Op->>Game: 3. 新建/选择大厅游戏
Op->>Mapping: 4. 编辑映射绑定 game_id
Op->>Game: 5. 设置 active_platform_id
Note over Game: 大厅可走该平台启动
```
---
## 结论
| 问题 | 答案 |
|---|---|
| 新平台的游戏列表在哪? | **`g_game_platform_mapping`**,管理端 **映射列表** 按平台筛选 |
| 为什么新建后是空的? | 平台创建 ≠ 游戏导入;需映射或同步 |
| 需要 `g_game_platform` 吗? | **不需要**mapping 表就是平台游戏池 |
| 真正缺什么? | **平台页与映射页的串联** + **(可选)上游游戏导入** |