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,61 @@
<?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\ApiResponse;
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
{
$perPage = min(max((int) $request->integer('per_page', 25), 1), 100);
$page = max((int) $request->integer('page', 1), 1);
$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($perPage, ['*'], 'page', $page);
return ApiResponse::success([
'batch_id' => (int) $batch->id,
'items' => collect($paginator->items())->map(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(),
];
})->all(),
'meta' => [
'current_page' => $paginator->currentPage(),
'per_page' => $paginator->perPage(),
'total' => $paginator->total(),
'last_page' => $paginator->lastPage(),
],
]);
}
}