feat: 添加待审核开奖批次统计功能至管理员仪表板
- 在 AdminDashboardSnapshotBuilder 中新增 resultBatchQueue 方法,统计全站待审核的开奖批次信息。 - 更新仪表板数据结构,包含待审核开奖批次的总数、待开奖次数及首个待审核开奖的 ID。 - 在 AdminDashboardApiTest 中新增测试用例,验证仪表板返回的待审核开奖批次统计数据的准确性。
This commit is contained in:
@@ -10,6 +10,7 @@ use App\Models\TicketItem;
|
||||
use App\Models\TicketOrder;
|
||||
use App\Models\TransferOrder;
|
||||
use App\Models\SettlementBatch;
|
||||
use App\Models\DrawResultBatch;
|
||||
use App\Lottery\DrawResultBatchStatus;
|
||||
use App\Services\Draw\DrawHallSnapshotBuilder;
|
||||
|
||||
@@ -40,6 +41,7 @@ final class AdminDashboardSnapshotBuilder
|
||||
'finance' => null,
|
||||
'draw' => null,
|
||||
'risk' => null,
|
||||
'result_batch_queue' => null,
|
||||
'abnormal_transfer_total' => null,
|
||||
'warnings' => [],
|
||||
'capabilities' => [
|
||||
@@ -75,6 +77,7 @@ final class AdminDashboardSnapshotBuilder
|
||||
$out['finance'] = $this->financeSummary($draw);
|
||||
$out['draw'] = $this->drawPanel($draw);
|
||||
$out['risk'] = $this->riskPanel($draw);
|
||||
$out['result_batch_queue'] = $this->resultBatchQueue();
|
||||
}
|
||||
|
||||
if ($canWallet) {
|
||||
@@ -189,6 +192,34 @@ final class AdminDashboardSnapshotBuilder
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 全站待审核开奖批次(首页「待审核开奖」卡片用,不限于大厅当前期)。
|
||||
*
|
||||
* @return array{pending_review_total: int, pending_draw_count: int, first_pending_draw_id: int|null, first_pending_batch_id: int|null}
|
||||
*/
|
||||
private function resultBatchQueue(): array
|
||||
{
|
||||
$pendingQuery = DrawResultBatch::query()
|
||||
->where('status', DrawResultBatchStatus::PendingReview->value);
|
||||
|
||||
$pendingTotal = (int) (clone $pendingQuery)->count();
|
||||
|
||||
$pendingDrawCount = $pendingTotal > 0
|
||||
? (int) (clone $pendingQuery)->distinct('draw_id')->count('draw_id')
|
||||
: 0;
|
||||
|
||||
$firstPending = $pendingTotal > 0
|
||||
? (clone $pendingQuery)->orderBy('id')->first(['id', 'draw_id'])
|
||||
: null;
|
||||
|
||||
return [
|
||||
'pending_review_total' => $pendingTotal,
|
||||
'pending_draw_count' => $pendingDrawCount,
|
||||
'first_pending_draw_id' => $firstPending !== null ? (int) $firstPending->draw_id : null,
|
||||
'first_pending_batch_id' => $firstPending !== null ? (int) $firstPending->id : null,
|
||||
];
|
||||
}
|
||||
|
||||
/** @return array<string, mixed> */
|
||||
private function drawPanel(Draw $draw): array
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user