<?php

namespace App\Http\Controllers\Api\V1\Admin\AgentSettlement;

use App\Http\Controllers\Controller;
use App\Services\AgentSettlement\AgentSettlementReportQueryService;
use App\Support\ApiResponse;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;

/** @deprecated 请用 AgentSettlementReportShowController?type=summary */
final class AgentSettlementReportIndexController extends Controller
{
    public function __invoke(Request $request, AgentSettlementReportQueryService $reports): JsonResponse
    {
        $admin = $request->lotteryAdmin();
        abort_if($admin === null, 401);

        $periodId = (int) $request->query('settlement_period_id', 0);

        return ApiResponse::success($reports->summary($admin, $periodId));
    }
}
