run(fn () => $service->options()); } public function leaderboard(ReportReader $service) { return $this->run(fn () => $service->details(request()->all(), true)); } public function funds(ReportReader $service) { return $this->run(fn () => $service->funds(request()->all())); } public function summary(ReportReader $service) { return $this->run(fn () => $service->summary(request()->all())); } public function details(ReportReader $service) { return $this->run(fn () => $service->details(request()->all())); } public function orders(ReportReader $service) { return $this->run(fn () => $service->orders(request()->all())); } public function events(ReportReader $service) { return $this->run(fn () => $service->events(request()->all())); } public function settings(ReportAdmin $service) { return $this->run(fn () => $service->settings(request()->isMethod('POST') ? request()->all() : null)); } public function payments(ReportAdmin $service) { return $this->run(fn () => request()->isMethod('POST') ? $service->reconcile(request()->all()) : $service->reconciliations(request()->all())); } public function orderTime(ReportAdmin $service) { return $this->run(fn () => $service->reconcileOrder(request()->all())); } public function quality(ReportAdmin $service) { return $this->run(fn () => $service->quality(request()->all())); } private function run(callable $callback) { try { return $this->success($callback()); } catch (ValidationException $e) { return $this->error(HttpStatus::CUSTOM_ERROR, $e->validator->errors()->first()); } catch (\Throwable $e) { Log::error('reporting_request_failed', ['exception' => $e]); return $this->error(HttpStatus::CUSTOM_ERROR, '报表暂不可用,请稍后重试'); } } }