52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Settlement;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\SettlementBatch;
|
|
use App\Models\TicketSettlementDetail;
|
|
use App\Support\AdminApiList;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* GET /api/v1/admin/settlement-batches/{batch}/details — 该批次下注单结算明细分页。
|
|
*/
|
|
final class AdminSettlementBatchDetailsController extends Controller
|
|
{
|
|
public function __invoke(Request $request, SettlementBatch $batch): JsonResponse
|
|
{
|
|
$p = AdminApiList::readPaging($request);
|
|
|
|
$paginator = TicketSettlementDetail::query()
|
|
->where('settlement_batch_id', $batch->id)
|
|
->with([
|
|
'ticketItem:id,ticket_no,play_code,player_id',
|
|
'ticketItem.player:id,username,site_player_id',
|
|
])
|
|
->orderBy('id')
|
|
->paginate($p['perPage'], ['*'], 'page', $p['page']);
|
|
|
|
return AdminApiList::jsonWith($paginator, function ($row) {
|
|
/** @var TicketSettlementDetail $row */
|
|
$item = $row->ticketItem;
|
|
$player = $item?->player;
|
|
|
|
return [
|
|
'id' => (int) $row->id,
|
|
'ticket_item_id' => (int) $row->ticket_item_id,
|
|
'ticket_no' => $item?->ticket_no,
|
|
'play_code' => $item?->play_code,
|
|
'player_id' => $item?->player_id,
|
|
'player_username' => $player?->username,
|
|
'site_player_id' => $player?->site_player_id,
|
|
'matched_prize_tier' => $row->matched_prize_tier,
|
|
'win_amount' => (int) $row->win_amount,
|
|
'jackpot_allocation_amount' => (int) $row->jackpot_allocation_amount,
|
|
'match_detail_json' => $row->match_detail_json,
|
|
'created_at' => $row->created_at?->toIso8601String(),
|
|
];
|
|
}, ['batch_id' => (int) $batch->id]);
|
|
}
|
|
}
|