优化 你玩游戏我买单 页面

This commit is contained in:
2026-04-13 17:55:00 +08:00
parent 2eb732642b
commit 596c7f357f
3 changed files with 55 additions and 3 deletions
@@ -30,8 +30,8 @@ class BaccaratLossCoverController extends Controller
{
$event = BaccaratLossCoverEvent::query()
->with(['creator:id,username'])
->whereIn('status', ['active', 'settlement_pending', 'claimable', 'scheduled'])
->orderByRaw("CASE status WHEN 'active' THEN 0 WHEN 'settlement_pending' THEN 1 WHEN 'claimable' THEN 2 WHEN 'scheduled' THEN 3 ELSE 4 END")
->whereIn('status', $this->summaryStatuses($request))
->orderByRaw($this->summaryStatusOrder($request))
->orderByDesc('starts_at')
->first();
@@ -109,4 +109,33 @@ class BaccaratLossCoverController extends Controller
] : null,
];
}
/**
* 按调用场景返回活动摘要允许出现的状态集合。
*
* “当前活动”页签只展示未开始、进行中或结算中的活动,
* 避免把已结束但仍可领取的历史活动误显示在当前页签里。
*
* @return list<string>
*/
private function summaryStatuses(Request $request): array
{
if ($request->string('scene')->toString() === 'overview') {
return ['active', 'settlement_pending', 'scheduled'];
}
return ['active', 'settlement_pending', 'claimable', 'scheduled'];
}
/**
* 按调用场景生成活动状态排序规则。
*/
private function summaryStatusOrder(Request $request): string
{
if ($request->string('scene')->toString() === 'overview') {
return "CASE status WHEN 'active' THEN 0 WHEN 'settlement_pending' THEN 1 WHEN 'scheduled' THEN 2 ELSE 3 END";
}
return "CASE status WHEN 'active' THEN 0 WHEN 'settlement_pending' THEN 1 WHEN 'claimable' THEN 2 WHEN 'scheduled' THEN 3 ELSE 4 END";
}
}