shjOneService = $shjOneService; } /** * Execute the console command. */ public function handle() { $startTime = now(); $processName = config('shj1.batch_log.process_name'); // 【処理0】パラメーターを取得する $userId = $this->argument('user_id'); $parkId = $this->argument('park_id'); $parameters = [ 'user_id' => $userId, 'park_id' => $parkId ]; $this->info("=== SHJ-1 本人確認自動処理 開始 ==="); $this->info("利用者ID: {$userId}"); $this->info("駐輪場ID: {$parkId}"); try { // SHJ-1 メイン処理を実行 $result = $this->shjOneService->execute($userId, $parkId); // 処理結果の表示 $this->displayResult($result); // バッチログはShjOneServiceが自動的にSHJ-8経由で作成 $this->info("=== SHJ-1 本人確認自動処理 完了 ==="); // システムエラーまたは身元確認失敗の場合は exit code 1 $isSuccess = $result['system_success'] && ($result['identity_result'] ?? '') === 'OK'; return $isSuccess ? 0 : 1; } catch (Exception $e) { $this->error("SHJ-1処理中にエラーが発生しました: " . $e->getMessage()); // エラー時もShjOneServiceが自動的にバッチログを作成 Log::error('SHJ-1処理例外エラー', [ 'user_id' => $userId, 'park_id' => $parkId, 'exception' => $e->getMessage(), 'trace' => $e->getTraceAsString() ]); return 1; } } /** * 処理結果を表示 */ private function displayResult(array $result): void { $this->line(''); $this->info('=== 処理結果 ==='); if ($result['system_success']) { $this->info("✓ 処理実行成功: " . $result['message']); if (isset($result['identity_result'])) { $identityStatus = $result['identity_result'] === 'OK' ? '✓ 本人確認OK' : '✗ 本人確認NG'; $this->line(" 本人確認結果: " . $identityStatus); } } else { $this->error("✗ 処理実行失敗: " . $result['message']); } if (isset($result['details'])) { foreach ($result['details'] as $key => $value) { $this->line(" {$key}: {$value}"); } } if (isset($result['stats'])) { $this->line(''); $this->info('=== 統計情報 ==='); foreach ($result['stats'] as $key => $value) { $this->line(" {$key}: {$value}"); } } } }