peopleCountingUrl()); } /** * 单日快照:过去日期读归档 venues[],今天读内存。 * * @return array */ public function fetchDailySnapshot(Carbon $day): array { $d = $day->toDateString(); $url = $this->peopleCountingUrl(); $res = Http::timeout($this->timeout()) ->acceptJson() ->get($url, [ 'date' => $d, 'end_date' => $d, ]); if (! $res->successful()) { throw new RuntimeException("客流日接口 HTTP {$res->status()} {$url}: ".mb_substr($res->body(), 0, 400)); } $json = $res->json(); if (! is_array($json) || (int) ($json['code'] ?? 0) !== 200) { throw new RuntimeException('客流日接口业务失败: '.mb_substr((string) $res->body(), 0, 500)); } return $json; } /** * 全场馆 24 小时桶。 * * @return array */ public function fetchHourly(Carbon $day): array { $url = $this->apiBase().'/api/venues/hourly'; $res = Http::timeout($this->timeout()) ->acceptJson() ->get($url, [ 'date' => $day->toDateString(), ]); if (! $res->successful()) { throw new RuntimeException("客流小时接口 HTTP {$res->status()} {$url}: ".mb_substr($res->body(), 0, 400)); } $json = $res->json(); if (! is_array($json) || (int) ($json['code'] ?? 0) !== 200) { throw new RuntimeException('客流小时接口业务失败: '.mb_substr((string) $res->body(), 0, 500)); } return $json; } private function timeout(): int { $n = (int) config('services.people_counting.timeout', 20); return max(5, min($n, 120)); } }