> */ public function fetchAll(): array { $warehouses = []; $type = self::WAREHOUSE_TYPE; $offset = 0; do { $request = [ 'type' => $type, 'is_delete' => '0,1', 'offset' => $offset, 'length' => self::PAGE_SIZE, ]; $started = microtime(true); $response = []; try { $response = $this->client->post(Endpoint::WAREHOUSE_LIST, $request); $rows = $response['data'] ?? null; if (!is_array($rows)) { throw new \RuntimeException('Lingxing warehouse response is missing data.'); } $this->logWriter->write([ 'direction' => 'pull', 'operation' => 'warehouse_sync', 'entity_type' => 'warehouse', 'external_id' => (string)$type, 'status' => 'success', 'attempt_number' => 1, 'request_id' => (string)($response['request_id'] ?? ''), 'request_payload' => $request, 'response_payload' => $response, 'duration_ms' => (int)round((microtime(true) - $started) * 1000), ]); } catch (\Throwable $exception) { $apiResponse = $exception instanceof ApiException ? $exception->getResponse() : $response; $this->logWriter->write([ 'direction' => 'pull', 'operation' => 'warehouse_sync', 'entity_type' => 'warehouse', 'external_id' => (string)$type, 'status' => 'failed', 'attempt_number' => 1, 'error_code' => $exception instanceof ApiException ? $exception->getErrorCode() : (string)$exception->getCode(), 'error_message' => $exception->getMessage(), 'request_id' => (string)($apiResponse['request_id'] ?? ''), 'request_payload' => $request, 'response_payload' => $apiResponse, 'duration_ms' => (int)round((microtime(true) - $started) * 1000), ]); throw $exception; } foreach ($rows as $row) { if (!is_array($row) || (int)($row['wid'] ?? 0) <= 0) { continue; } $row['type'] = (int)($row['type'] ?? $type); $warehouses[(int)$row['wid']] = $row; } $received = count($rows); $offset += $received; $total = max(0, (int)($response['total'] ?? $offset)); } while ($received > 0 && $offset < $total); return array_values($warehouses); } }