Files
lotteryLaravel/app/Http/Controllers/Api/V1/Admin/Settlement/AdminSettlementBatchPayoutController.php
kang 770fd8950d fix: 更新任务调度频率并增强错误处理逻辑
- 将 `lottery:draw-tick` 命令的调度频率从每分钟更新为每10秒,以提高抽奖数据处理的及时性。
- 在 `AdminSettlementBatchPayoutController` 中增强异常处理,提供更具体的错误信息,特别是针对未批准的结算批次。
- 在多语言文件中添加相应的错误信息翻译,确保用户友好的反馈。
2026-05-25 16:43:51 +08:00

37 lines
1.2 KiB
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 $e) {
$reason = $e->getMessage();
$msg = match ($reason) {
'settlement_not_approved' => trans('api.settlement_not_approved'),
default => trans('api.client_error'),
};
return ApiResponse::error($msg, ErrorCode::ClientHttpError->value, ['reason' => $reason], 409);
}
return ApiResponse::success([
'id' => (int) $updated->id,
'status' => $updated->status,
'paid_at' => $updated->paid_at?->toIso8601String(),
]);
}
}