option('dry-run'); if ($isDryRun) { return $this->runDryRun(); } if (! (bool) g7_module_settings('sirsoft-ecommerce', 'dashboard.scheduler_enabled', true)) { $this->warn('대시보드 집계 스케줄러가 비활성화되어 있습니다 (dashboard.scheduler_enabled=false). 건너뜁니다.'); return Command::SUCCESS; } $rows = $this->dashboardService->aggregateRecentDays(self::AGGREGATE_DAYS); $this->info(sprintf('판매 현황 집계 완료: 최근 %d일치 %d개 행 갱신', self::AGGREGATE_DAYS, count($rows))); $this->table(['날짜', '판매수량', '순매출'], array_map( fn (array $row) => [$row['date'], $row['sales_quantity'], number_format($row['sales_amount'])], $rows, )); return Command::SUCCESS; } /** * dry-run: 저장 없이 대상 날짜와 예상 판매 현황만 출력합니다. * * @return int 종료 코드 */ private function runDryRun(): int { $today = CarbonImmutable::today(); $preview = []; for ($i = 0; $i < self::AGGREGATE_DAYS; $i++) { $date = $today->subDays($i)->toDateString(); $preview[] = [ $date, $this->orderOptionRepository->sumNetQuantityOnDate($date), number_format($this->orderOptionRepository->sumNetSalesOnDate($date)), ]; } $this->info(sprintf('[dry-run] 집계 대상 최근 %d일 (저장하지 않음):', self::AGGREGATE_DAYS)); $this->table(['날짜', '판매수량', '순매출'], $preview); return Command::SUCCESS; } }