info('---------------------------'); $this->info('reschedule sts:' . Carbon::now()->toDateTimeString()); $this->info('---------------------------'); // get reschedu;e sts logs $success = 0; $failed = 0; $rescheduleStsLogs = StsLog::where(['is_retry' => true])->get(); foreach($rescheduleStsLogs as $rescheduleStsLog) { try { $partner = $rescheduleStsLog->partner; $module = $rescheduleStsLog->module; $serviceName = $rescheduleStsLog->service_name; $request = new Request((array) $rescheduleStsLog->request_data ?? []); $localId = $rescheduleStsLog->local_id; $partnerId = $rescheduleStsLog->partner_id; $lastSeq = $rescheduleStsLog->seq; if($partner == StsLog::PARTNER_INDOKARGO) { if($module == StsLog::MODULE_TV) { if($serviceName == StsLog::SERVICE_CREATE_TV_ADDRESS) { Indokargo::createTVAddress($request, $localId, $lastSeq); } else if($serviceName == StsLog::SERVICE_UPDATE_TV_ADDRESS) { Indokargo::updateTVAddress($request, $localId, $partnerId, $lastSeq); } else if($serviceName == StsLog::SERVICE_CHANGE_STATUS_TV_ADDRESS) { Indokargo::changeStatusAddress($request, $localId, $partnerId, $lastSeq); } else { throw new \Exception("Service name '$partner' > '$module' > '$serviceName' not found service"); } } else { throw new \Exception("Module name '$partner' > '$module' not found service"); } } else { throw new \Exception("Partner name '$partner' not found service"); } $success++; } catch(\Throwable $th) { $failed++; $this->info("stsLog id: ". $rescheduleStsLog->id . " => " . $th->getMessage()); } } // save all retry request is retry false $rescheduleStsLogIds = $rescheduleStsLogs->pluck('id')->toArray(); StsLog::whereIn('id', $rescheduleStsLogIds)->update(['is_retry' => false]); $this->info('---------------------------'); $this->info("result: $success success, $failed failed" ); $this->info("Sleep in $sleep seconds" ); $this->info('---------------------------'); sleep($sleep); } } }