54 lines
2.0 KiB
PHP
54 lines
2.0 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Jackpot;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Models\JackpotPayoutLog;
|
|
use App\Support\ApiResponse;
|
|
use Illuminate\Http\JsonResponse;
|
|
use Illuminate\Http\Request;
|
|
|
|
/**
|
|
* GET /api/v1/admin/jackpot/payout-logs — Jackpot 派彩(爆池)记录。
|
|
*/
|
|
final class AdminJackpotPayoutLogIndexController extends Controller
|
|
{
|
|
public function __invoke(Request $request): JsonResponse
|
|
{
|
|
$perPage = min(max((int) $request->integer('per_page', 25), 1), 100);
|
|
$page = max((int) $request->integer('page', 1), 1);
|
|
$drawNo = trim((string) $request->query('draw_no', ''));
|
|
|
|
$q = JackpotPayoutLog::query()
|
|
->with(['draw:id,draw_no', 'pool:id,currency_code'])
|
|
->orderByDesc('id');
|
|
|
|
if ($drawNo !== '') {
|
|
$q->whereHas('draw', fn ($d) => $d->where('draw_no', 'like', '%'.$drawNo.'%'));
|
|
}
|
|
|
|
$paginator = $q->paginate($perPage, ['*'], 'page', $page);
|
|
|
|
return ApiResponse::success([
|
|
'items' => collect($paginator->items())->map(fn (JackpotPayoutLog $r) => [
|
|
'id' => (int) $r->id,
|
|
'draw_id' => (int) $r->draw_id,
|
|
'draw_no' => $r->draw?->draw_no,
|
|
'jackpot_pool_id' => (int) $r->jackpot_pool_id,
|
|
'currency_code' => $r->pool?->currency_code,
|
|
'trigger_type' => $r->trigger_type,
|
|
'total_payout_amount' => (int) $r->total_payout_amount,
|
|
'winner_count' => (int) $r->winner_count,
|
|
'trigger_snapshot_json' => $r->trigger_snapshot_json,
|
|
'created_at' => $r->created_at?->toIso8601String(),
|
|
])->all(),
|
|
'meta' => [
|
|
'current_page' => $paginator->currentPage(),
|
|
'per_page' => $paginator->perPage(),
|
|
'total' => $paginator->total(),
|
|
'last_page' => $paginator->lastPage(),
|
|
],
|
|
]);
|
|
}
|
|
}
|