39 lines
2.5 KiB
Markdown
39 lines
2.5 KiB
Markdown
---
|
||
name: console返水过期兜底
|
||
overview: 在 C 端返水信息接口增加“近7天过期兜底”逻辑:若存在未领取且已过期记录,进入接口时自动标记为 expired,避免依赖定时脚本。
|
||
todos:
|
||
- id: locate-info-hook
|
||
content: 在 DailyRebateLogic::info() 增加近7天过期兜底调用点(查询记录前)
|
||
status: pending
|
||
- id: add-scope-expire-method
|
||
content: 新增用户+近7天范围的过期更新方法,仅更新 claimable 且已过期记录
|
||
status: pending
|
||
- id: verify-behavior
|
||
content: 按过期/未过期/超范围三类样例验证 info 返回状态符合预期
|
||
status: pending
|
||
isProject: false
|
||
---
|
||
|
||
# Console返水信息过期兜底改造
|
||
|
||
## 目标
|
||
在用户访问返水信息接口时,对该用户“近7天”记录执行一次轻量过期兜底:把 `status=claimable` 且 `expire_at<=当前时间` 的记录更新为 `expired`,避免脚本漏跑导致前端状态不一致。
|
||
|
||
## 改动方案
|
||
- 在 [`/Users/ray/Documents/project/www/slot/slot_console/app/api/logic/DailyRebateLogic.php`](/Users/ray/Documents/project/www/slot/slot_console/app/api/logic/DailyRebateLogic.php) 的 `info()` 开头(`$unlocked` 判定后、组装 records 前)新增一步:
|
||
- 仅针对当前 `uid`、统计日期范围“今天往前 6 天到今天”(即接口展示的近7天)执行过期更新。
|
||
- 更新条件:`status = STATUS_CLAIMABLE` 且 `expire_at <= now()`。
|
||
- 更新结果无需抛错,作为兜底处理(可选记录 debug/info 日志)。
|
||
- 在同文件新增受保护方法(例如 `expireRecentClaimableForInfo(int $uid): int`)承载该逻辑,保持 `info()` 主流程清晰,符合 Logic 分层。
|
||
- 保留现有 `expireDueRecords()`(全量定时任务用),新方法仅用于 C 端接口的“用户级小范围补偿”,两者职责互补,不互相替代。
|
||
|
||
## 细节约束
|
||
- 范围严格限定为近7天,避免接口触发全表更新。
|
||
- 仅改 `claimable -> expired`,不触碰 `claimed` / `pending`。
|
||
- 执行顺序放在读取记录前,保证本次 `records` 返回的状态已是最新。
|
||
|
||
## 验证计划
|
||
- 构造 1 条近7天内 `claimable + expire_at 已过期` 数据,调用 `info` 后应返回 `expired`。
|
||
- 构造 1 条近7天内 `claimable + expire_at 未到期` 数据,调用 `info` 后仍为 `claimable`。
|
||
- 构造 1 条 7 天外过期 `claimable` 数据,调用 `info` 后不应被本接口更新(仍由定时任务处理)。
|
||
- 回归 `claim` 接口:已过期记录仍不可领取(现有保护逻辑保持不变)。 |