feat: 补充结算批次财务汇总并返回投注与利润数据

This commit is contained in:
2026-05-19 17:07:07 +08:00
parent 057ddecaa1
commit 5742853c4c
4 changed files with 56 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ use App\Support\AdminApiList;
use App\Models\SettlementBatch;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Support\SettlementBatchFinancialSummary;
/**
* GET /api/v1/admin/settlement-batches 结算批次分页列表。
@@ -39,6 +40,8 @@ final class AdminSettlementBatchIndexController extends Controller
/** @return array<string, mixed> */
private function row(SettlementBatch $b): array
{
$financial = SettlementBatchFinancialSummary::forBatch($b);
return [
'id' => (int) $b->id,
'draw_id' => (int) $b->draw_id,
@@ -51,8 +54,11 @@ final class AdminSettlementBatchIndexController extends Controller
'paid_at' => $b->paid_at?->toIso8601String(),
'total_ticket_count' => (int) $b->total_ticket_count,
'total_win_count' => (int) $b->total_win_count,
'total_bet_amount' => $financial['total_bet_amount'],
'total_actual_deduct' => $financial['total_actual_deduct'],
'total_payout_amount' => (int) $b->total_payout_amount,
'total_jackpot_payout_amount' => (int) $b->total_jackpot_payout_amount,
'platform_profit' => $financial['platform_profit'],
'started_at' => $b->started_at?->toIso8601String(),
'finished_at' => $b->finished_at?->toIso8601String(),
'created_at' => $b->created_at?->toIso8601String(),

View File

@@ -6,6 +6,7 @@ use App\Support\ApiResponse;
use App\Models\SettlementBatch;
use Illuminate\Http\JsonResponse;
use App\Http\Controllers\Controller;
use App\Support\SettlementBatchFinancialSummary;
/**
* GET /api/v1/admin/settlement-batches/{batch} 单批次摘要。
@@ -15,6 +16,7 @@ final class AdminSettlementBatchShowController extends Controller
public function __invoke(SettlementBatch $batch): JsonResponse
{
$batch->load(['draw:id,draw_no,business_date,status', 'resultBatch:id,result_version,status']);
$financial = SettlementBatchFinancialSummary::forBatch($batch);
return ApiResponse::success([
'id' => (int) $batch->id,
@@ -33,8 +35,11 @@ final class AdminSettlementBatchShowController extends Controller
'paid_at' => $batch->paid_at?->toIso8601String(),
'total_ticket_count' => (int) $batch->total_ticket_count,
'total_win_count' => (int) $batch->total_win_count,
'total_bet_amount' => $financial['total_bet_amount'],
'total_actual_deduct' => $financial['total_actual_deduct'],
'total_payout_amount' => (int) $batch->total_payout_amount,
'total_jackpot_payout_amount' => (int) $batch->total_jackpot_payout_amount,
'platform_profit' => $financial['platform_profit'],
'started_at' => $batch->started_at?->toIso8601String(),
'finished_at' => $batch->finished_at?->toIso8601String(),
'created_at' => $batch->created_at?->toIso8601String(),