| 12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- namespace App\Http\Controllers\agent;
- use App\Http\Controllers\AgentApiController;
- use App\Services\CompanyMonthlyReportService;
- use Illuminate\Http\Request;
- /** 入股代理查看、下载公司营业报表(总后台按月上传)。合营代理不可见。 */
- class CompanyReportController extends AgentApiController
- {
- private function onlyEquity(): void
- {
- if (!$this->currentAgent()->isEquity()) throw new \RuntimeException('仅入股代理可查看公司营业报表');
- }
- public function index(Request $request, CompanyMonthlyReportService $service)
- {
- return $this->execute(function () use ($request, $service) {
- $this->onlyEquity();
- $data = $request->validate([
- 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:100'],
- 'start_month' => ['nullable', 'date_format:Y-m'], 'end_month' => ['nullable', 'date_format:Y-m', 'after_or_equal:start_month'],
- ]);
- return $service->paginate($data, false);
- });
- }
- public function download(Request $request, CompanyMonthlyReportService $service)
- {
- return $this->executeFile(function () use ($request, $service) {
- $this->onlyEquity();
- $data = $request->validate(['id' => ['required', 'integer', 'min:1']]);
- return $service->download((int) $data['id']);
- });
- }
- }
|