feat: 添加结算功能,更新 TicketItem 模型以支持最新结算详情,增强 DrawTickService 以自动处理结算,更新 TicketWalletService 以支持派彩入账,扩展 API 路由以管理结算批次和奖池

This commit is contained in:
2026-05-11 15:34:34 +08:00
parent 6a55fa9592
commit 19003f5041
50 changed files with 3604 additions and 3 deletions

View File

@@ -0,0 +1,53 @@
<?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(),
],
]);
}
}