peopleCountingDays( $this->option('date'), $this->option('from'), $this->option('to'), Carbon::today() ); } catch (InvalidArgumentException $e) { $this->error($e->getMessage()); return self::FAILURE; } $force = (bool) $this->option('force'); $protect = ! $force; $sleepMs = $this->peopleCountingSleepMs(); $today = Carbon::today()->toDateString(); $ok = 0; $fail = 0; foreach ($days as $i => $day) { $d = $day->toDateString(); if ($d > $today) { $this->warn("跳过未来日期 {$d}"); continue; } try { $r = $sync->syncDailyForDate($day, $protect); $ok++; $this->info(sprintf( '%s written=%d skipped=%d venues=%d%s', $r['date'], $r['written'], $r['skipped'], $r['venues'], $force ? ' (force)' : '' )); Log::info('people-counting.sync-daily', $r); } catch (Throwable $e) { $fail++; $this->error("{$d} 失败: ".$e->getMessage()); Log::warning('people-counting.sync-daily.failed', [ 'date' => $d, 'error' => $e->getMessage(), ]); } if ($i < count($days) - 1 && $sleepMs > 0) { usleep($sleepMs * 1000); } } return $fail > 0 && $ok === 0 ? self::FAILURE : self::SUCCESS; } }