- 将 `lottery:draw-tick` 命令的调度频率从每分钟更新为每10秒,以提高抽奖数据处理的及时性。 - 在 `AdminSettlementBatchPayoutController` 中增强异常处理,提供更具体的错误信息,特别是针对未批准的结算批次。 - 在多语言文件中添加相应的错误信息翻译,确保用户友好的反馈。
37 lines
1.2 KiB
PHP
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(),
|
|
]);
|
|
}
|
|
}
|