Files
cursor/plans/channel auto transparent-0ecc7d51.plan.md
ray zhou 2dd9f17da9 ok
2026-06-29 14:51:55 +08:00

58 lines
3.8 KiB
Markdown
Raw 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.

<!-- 0ecc7d51-c1e6-4993-8d68-d7293c40524d -->
---
todos:
- id: "const"
content: "GameServerModel 增加 WAGERING_MODEL_TRANSPARENT=2 常量(中文注释)"
status: pending
- id: "logic-switch"
content: "GameServerLogic 增加 batchSwitchToTransparent() 批量刷透明并返回改动 source 列表"
status: pending
- id: "logic-reset"
content: "GameServerLogic 增加 resetUsersWagerTaskBySource() 按渠道分批跑用户 offTask 整理"
status: pending
- id: "command"
content: "新建 ChannelTransparent 命令,支持 --source/--dry-run编排上面两步"
status: pending
- id: "register"
content: "确认/登记 config/command.php 命令注册"
status: pending
- id: "gate"
content: "跑后端门禁脚本并附检测结果"
status: pending
isProject: false
---
# 渠道自动转透明 + 用户数据整理
## 背景结论
- 透明模式判定全系统统一为 `extend_data.wagering_model == 2``1` 或未设置 = 非透明(见 [ShareConfigService.php](slot_wallet/app/service/ShareConfigService.php) L113-118、[GameServerService.php](slot_console/app/service/GameServerService.php) L46-52
- 渠道数据在 `s_common.game_server`,由 [GameServerLogic](backend/slot_admin/app/game/logic/GameServerLogic.php) 维护,保存后 `sync()` 刷新缓存。
- 原数据整理slot_admin [Test.php](backend/slot_admin/app/command/Test.php) L39-66 按 `source` 分批捞 [UserModel](backend/slot_admin/app/model/UserModel.php),逐用户 `WalletService::offTask($uid,$currency)` → slot_wallet [SiteController::offTask](slot_wallet/app/api/controller/SiteController.php) L44-129 重算提现要求/失效历史打码任务/补建恢复任务。
## 方案(按用户确认:新建 CLI 命令;改完渠道后只对本次切换的渠道用户跑整理)
### 1. 渠道侧常量
在 [GameServerModel.php](backend/slot_admin/app/model/GameServerModel.php) 增加:
- `/** 打码模式-透明(version2) */ const WAGERING_MODEL_TRANSPARENT = 2;`
### 2. GameServerLogic 编排(两个新 public 方法,含中文 PHPDoc
- `batchSwitchToTransparent(): array`:查 `status > 0` 的全部渠道,遍历 decode `extend_data`,对 `wagering_model != 2` 的设为 2、`json_encode` 回写、调用 `sync($source)` 刷缓存;返回本次实际改动的 `source` 列表(已是 2 的跳过,天然幂等)。
- `resetUsersWagerTaskBySource(string $source): int`:复用 Test::offTask 的分批逻辑——按 `source``id > $lastId` 游标分页(1000/批)捞 `UserModel(id,currency,source)`,逐个 `WalletService::offTask($uid,$currency)`,返回处理用户数;关键节点写日志。
### 3. 新建命令 [backend/slot_admin/app/command/ChannelTransparent.php]
- `protected static $defaultName = 'channelTransparent';`
- 可选参数 `--source`(只处理指定渠道,便于灰度/测试)、`--dry-run`(只列出将变更的渠道,不写库不整理)。
- execute 流程:调用 `batchSwitchToTransparent()` 拿到改动 source 列表 → 输出列表 → 对每个 source 调 `resetUsersWagerTaskBySource()` → 输出每渠道处理用户数与总计。
- 命令为薄编排,业务逻辑全部落在 GameServerLogic。
### 4. 命令注册
确认 `config/command.php` 是否需手动登记(参照现有 `test` 命令注册方式),若需要则追加 `ChannelTransparent::class`
## 执行方式
```bash
docker exec -w /app/www/slot/backend/slot_admin php82 php webman channelTransparent --dry-run # 先预览
docker exec -w /app/www/slot/backend/slot_admin php82 php webman channelTransparent # 正式执行
```
## 注意
- 数据整理对 wallet 是逐用户同步 HTTP渠道用户多时耗时较长与现有 Test 脚本一致);保留 `--source` 可分渠道执行。
- 收尾前按门禁跑 `~/.cursor/skills/slot-backend-completion-report/scripts/report.sh` 并附检测结果。