ReportController.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace App\Http\Controllers\agent;
  3. use App\Http\Controllers\AgentApiController;
  4. use App\Services\Agent\AgentPeriodReportService;
  5. use App\Services\Agent\AgentReportService;
  6. use Illuminate\Http\Request;
  7. class ReportController extends AgentApiController
  8. {
  9. public function index(Request $request, AgentReportService $reports)
  10. {
  11. return $this->execute(function () use ($request, $reports) {
  12. $data = $request->validate([
  13. 'page' => ['nullable', 'integer', 'min:1'], 'limit' => ['nullable', 'integer', 'min:1', 'max:20'],
  14. 'username' => ['nullable', 'string', 'max:64'], 'start_date' => ['required', 'date_format:Y-m-d'],
  15. 'end_date' => ['required', 'date_format:Y-m-d', 'after_or_equal:start_date'],
  16. ]);
  17. return $reports->reportRows($this->currentAgent(), $data);
  18. });
  19. }
  20. /** 周期报表:按日 / 周 / 月汇总。合营:名下会员;入股:全平台。只有汇总,没有会员明细。 */
  21. public function period(Request $request, AgentPeriodReportService $reports)
  22. {
  23. return $this->execute(function () use ($request, $reports) {
  24. $data = $request->validate([
  25. 'period' => ['nullable', 'in:day,week,month'],
  26. 'start_date' => ['nullable', 'date_format:Y-m-d'], 'end_date' => ['nullable', 'date_format:Y-m-d', 'after_or_equal:start_date'],
  27. ]);
  28. return $reports->report($this->currentAgent(), $data);
  29. });
  30. }
  31. }