31 lines
955 B
PHP
31 lines
955 B
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Api\V1\Admin\Settlement;
|
|
|
|
use App\Lottery\ErrorCode;
|
|
use App\Support\ApiResponse;
|
|
use App\Models\SettlementBatch;
|
|
use Illuminate\Http\JsonResponse;
|
|
use App\Http\Controllers\Controller;
|
|
use App\Services\Settlement\SettlementBatchWorkflowService;
|
|
|
|
final class AdminSettlementBatchPayoutController extends Controller
|
|
{
|
|
public function __construct(private readonly SettlementBatchWorkflowService $service) {}
|
|
|
|
public function __invoke(SettlementBatch $batch): JsonResponse
|
|
{
|
|
try {
|
|
$updated = $this->service->payout($batch);
|
|
} catch (\RuntimeException) {
|
|
return ApiResponse::error(trans('api.client_error'), ErrorCode::ClientHttpError->value, null, 409);
|
|
}
|
|
|
|
return ApiResponse::success([
|
|
'id' => (int) $updated->id,
|
|
'status' => $updated->status,
|
|
'paid_at' => $updated->paid_at?->toIso8601String(),
|
|
]);
|
|
}
|
|
}
|