shjNineService = $shjNineService; } /** * コンソールコマンドを実行 * * 処理フロー: * 1. 集計対象日設定(JOB1) * 2. 売上集計処理実行(JOB2~JOB4) * 3. バッチログ作成(JOB5) * * 日付バリデーション・バッチログ作成はService側で実施 * ステータスは常にsuccess(式様書準拠) * * @return int */ public function handle(): int { // 開始ログ出力 $startTime = now(); $this->info('SHJ-9 売上集計処理を開始します。'); // 集計種別は日次固定(SHJ-9は日次のみ) $type = 'daily'; // 集計対象日設定(JOB1) $targetDate = $this->argument('target_date'); // パラメータ指定がない場合は昨日(本日の1日前) $aggregationDate = $targetDate ?? now()->subDay()->format('Y-m-d'); Log::info('SHJ-9 売上集計処理開始', [ 'start_time' => $startTime, 'type' => $type, 'target_date' => $aggregationDate ]); $this->info("集計種別: {$type}"); $this->info("集計対象日: {$aggregationDate}"); // SHJ-9処理実行(日付バリデーション・バッチログ作成含む) $result = $this->shjNineService->executeEarningsAggregation($type, $aggregationDate); $endTime = now(); $this->info("処理時間: {$startTime->diffInSeconds($endTime)}秒"); if ($result['success']) { $this->info('SHJ-9 売上集計処理が正常に完了しました。'); $this->info("処理結果: 駐輪場数 {$result['processed_parks']}, 集計レコード数 {$result['summary_records']}"); } else { $this->info('SHJ-9 売上集計処理が完了しました(エラーあり): ' . $result['message']); } Log::info('SHJ-9 売上集計処理完了', [ 'end_time' => $endTime, 'duration_seconds' => $startTime->diffInSeconds($endTime), 'result' => $result ]); // 式様書準拠: ステータスは常にsuccess return self::SUCCESS; } }