settlementTransactionId = $settlementTransactionId; $this->context = $context; } /** * ジョブを実行 * * SHJ-4Bサービスを使用して決済トランザクション処理を実行 * * @return void */ public function handle() { $startTime = now(); try { Log::info('SHJ-4B ProcessSettlementJob開始', [ 'settlement_transaction_id' => $this->settlementTransactionId, 'context' => $this->context, 'start_time' => $startTime, ]); // SHJ-4Bサービスを使用して決済トランザクション処理を実行 // バッチログはShjFourBServiceが自動的にSHJ-8経由で作成 $shjFourBService = app(ShjFourBService::class); $result = $shjFourBService->processSettlementTransaction( $this->settlementTransactionId, $this->context ); // 処理結果のログ記録 if ($result['success']) { Log::info('SHJ-4B ProcessSettlementJob完了', [ 'settlement_transaction_id' => $this->settlementTransactionId, 'execution_time' => now()->diffInSeconds($startTime), 'result' => $result, ]); } else { // ビジネスロジック上の問題(エラーではない) Log::warning('SHJ-4B ProcessSettlementJob要手動対応', [ 'settlement_transaction_id' => $this->settlementTransactionId, 'result' => $result, ]); } } catch (\Throwable $e) { Log::error('SHJ-4B ProcessSettlementJob失敗', [ 'settlement_transaction_id' => $this->settlementTransactionId, 'error' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]); // エラー時もShjFourBServiceが自動的にバッチログを作成 // ジョブを失敗させて再試行を促す throw $e; } } /** * ジョブが失敗した場合の処理 * * @param \Throwable $exception * @return void */ public function failed(\Throwable $exception) { Log::error('SHJ-4B ProcessSettlementJob最終失敗', [ 'settlement_transaction_id' => $this->settlementTransactionId, 'context' => $this->context, 'error' => $exception->getMessage(), 'attempts' => $this->attempts(), ]); // バッチログはShjFourBServiceが既に作成済み // 最終失敗時の追加処理があればここに記述 // 例:管理者への通知、障害キューへの登録など } }