refactor: 优化 DrawHallSnapshotBuilder 和权限管理逻辑
- 在 DrawHallSnapshotBuilder 中简化数据获取逻辑,仅保留必要字段,更新状态表示方式。 - 在 AdminAuthorizationRegistry 中整合接入站点权限定义,提升权限管理的灵活性与可维护性。 - 更新调度任务配置,确保任务在单一服务器上运行,避免重叠执行,提高系统稳定性。 - 增强测试用例,确保新逻辑的正确性与稳定性。
This commit is contained in:
@@ -5,6 +5,7 @@ use App\Models\Draw;
|
||||
use App\Models\Player;
|
||||
use App\Models\AdminRole;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\RiskPool;
|
||||
use App\Models\TicketItem;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Models\PlayerWallet;
|
||||
@@ -895,6 +896,58 @@ test('GET draw current returns open draw with seconds to close', function (): vo
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
test('GET draw current only exposes coarse risk alert status', function (): void {
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 15:00:00', 'UTC'));
|
||||
|
||||
$draw = Draw::query()->create([
|
||||
'draw_no' => '20260509-301',
|
||||
'business_date' => '2026-05-09',
|
||||
'sequence_no' => 301,
|
||||
'status' => DrawStatus::Open->value,
|
||||
'start_time' => now()->copy()->subMinutes(5),
|
||||
'close_time' => now()->copy()->addMinutes(30),
|
||||
'draw_time' => now()->copy()->addHour(),
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => null,
|
||||
'current_result_version' => 0,
|
||||
'settle_version' => 0,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
RiskPool::query()->create([
|
||||
'draw_id' => $draw->id,
|
||||
'normalized_number' => '1234',
|
||||
'total_cap_amount' => 1_000,
|
||||
'locked_amount' => 850,
|
||||
'remaining_amount' => 150,
|
||||
'sold_out_status' => 0,
|
||||
]);
|
||||
|
||||
RiskPool::query()->create([
|
||||
'draw_id' => $draw->id,
|
||||
'normalized_number' => '5678',
|
||||
'total_cap_amount' => 100,
|
||||
'locked_amount' => 100,
|
||||
'remaining_amount' => 0,
|
||||
'sold_out_status' => 1,
|
||||
]);
|
||||
|
||||
$this->getJson('/api/v1/draw/current')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.data.draw_no', '20260509-301')
|
||||
->assertJsonPath('data.data.risk_pool_alerts.0.normalized_number', '5678')
|
||||
->assertJsonPath('data.data.risk_pool_alerts.0.status', 'sold_out')
|
||||
->assertJsonPath('data.data.risk_pool_alerts.1.normalized_number', '1234')
|
||||
->assertJsonPath('data.data.risk_pool_alerts.1.status', 'warning')
|
||||
->assertJsonMissingPath('data.data.risk_pool_alerts.0.total_cap_amount')
|
||||
->assertJsonMissingPath('data.data.risk_pool_alerts.0.locked_amount')
|
||||
->assertJsonMissingPath('data.data.risk_pool_alerts.0.remaining_amount')
|
||||
->assertJsonMissingPath('data.data.risk_pool_alerts.0.sold_out_status')
|
||||
->assertJsonMissingPath('data.data.risk_pool_alerts.0.usage_ratio');
|
||||
|
||||
Carbon::setTestNow();
|
||||
});
|
||||
|
||||
test('GET draw current exposes closing when row is open in DB but close_time has passed', function (): void {
|
||||
Carbon::setTestNow(Carbon::parse('2026-05-09 16:30:20', 'UTC'));
|
||||
$drawTime = Carbon::parse('2026-05-09 16:30:40', 'UTC');
|
||||
|
||||
Reference in New Issue
Block a user