feat: 添加待审核开奖批次统计功能至管理员仪表板
- 在 AdminDashboardSnapshotBuilder 中新增 resultBatchQueue 方法,统计全站待审核的开奖批次信息。 - 更新仪表板数据结构,包含待审核开奖批次的总数、待开奖次数及首个待审核开奖的 ID。 - 在 AdminDashboardApiTest 中新增测试用例,验证仪表板返回的待审核开奖批次统计数据的准确性。
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
use App\Models\Draw;
|
||||
use App\Models\RiskPool;
|
||||
use App\Models\AdminUser;
|
||||
use App\Models\DrawResultBatch;
|
||||
use App\Lottery\DrawStatus;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use App\Lottery\DrawResultSourceType;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
|
||||
@@ -70,6 +74,69 @@ test('admin dashboard aggregates hall finance and risk for super admin', functio
|
||||
->assertJsonPath('data.risk.sold_out_buckets.d4', 1);
|
||||
});
|
||||
|
||||
test('admin dashboard counts pending result batches site wide not only current draw', function (): void {
|
||||
$hallDraw = Draw::query()->create([
|
||||
'draw_no' => '20260512-020',
|
||||
'business_date' => '2026-05-12',
|
||||
'sequence_no' => 20,
|
||||
'status' => 'open',
|
||||
'start_time' => now()->subHour(),
|
||||
'close_time' => now()->addHour(),
|
||||
'draw_time' => now()->addHours(2),
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => null,
|
||||
'current_result_version' => 0,
|
||||
'settle_version' => 0,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
$reviewDraw = Draw::query()->create([
|
||||
'draw_no' => '20260512-019',
|
||||
'business_date' => '2026-05-12',
|
||||
'sequence_no' => 19,
|
||||
'status' => DrawStatus::Review->value,
|
||||
'start_time' => now()->subHours(3),
|
||||
'close_time' => now()->subHour(),
|
||||
'draw_time' => now()->subMinutes(30),
|
||||
'cooling_end_time' => null,
|
||||
'result_source' => DrawResultSourceType::Manual->value,
|
||||
'current_result_version' => 0,
|
||||
'settle_version' => 0,
|
||||
'is_reopened' => false,
|
||||
]);
|
||||
|
||||
DrawResultBatch::query()->create([
|
||||
'draw_id' => $reviewDraw->id,
|
||||
'result_version' => 1,
|
||||
'source_type' => DrawResultSourceType::Manual->value,
|
||||
'rng_seed_hash' => null,
|
||||
'raw_seed_encrypted' => null,
|
||||
'status' => DrawResultBatchStatus::PendingReview->value,
|
||||
'created_by' => null,
|
||||
'confirmed_by' => null,
|
||||
'confirmed_at' => null,
|
||||
]);
|
||||
|
||||
$admin = AdminUser::query()->create([
|
||||
'username' => 'dash_queue_admin',
|
||||
'name' => 'Dash Queue QA',
|
||||
'email' => null,
|
||||
'password' => Hash::make('secret-strong'),
|
||||
'status' => 0,
|
||||
]);
|
||||
grantSuperAdminRole($admin);
|
||||
$token = $admin->createToken('test', ['*'], now()->addDay())->plainTextToken;
|
||||
|
||||
$this->withHeader('Authorization', 'Bearer '.$token)
|
||||
->getJson('/api/v1/admin/dashboard')
|
||||
->assertOk()
|
||||
->assertJsonPath('data.resolved_draw.id', $hallDraw->id)
|
||||
->assertJsonPath('data.draw.result_batch_counts.pending_review', 0)
|
||||
->assertJsonPath('data.result_batch_queue.pending_review_total', 1)
|
||||
->assertJsonPath('data.result_batch_queue.pending_draw_count', 1)
|
||||
->assertJsonPath('data.result_batch_queue.first_pending_draw_id', $reviewDraw->id);
|
||||
});
|
||||
|
||||
test('admin dashboard returns 401 without token', function (): void {
|
||||
$this->getJson('/api/v1/admin/dashboard')->assertStatus(401);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user