mailer = $mailer; $this->bookingPaymentService = $bookingPaymentService; } public function handle() { try { $this->info(date('Y-m-d H:i:s') . ' : Start'); $bookingPaymentDataCriteria = [ 'criteria' => [ ['field' => 'status', 'condition' => '=', 'value' => 2], ['field' => 'type', 'condition' => '=', 'value' => 'ch'], ], 'with' => ['bookingDetail.channelManager'], 'orderBy' => [ ['field' => 'id', 'value' => 'ASC'] ] ]; $bookingPaymentData = $this->bookingPaymentService->selectPaymentData($bookingPaymentDataCriteria); $bookingPaymentData = $bookingPaymentData['status'] == 'success' && !empty($bookingPaymentData['data']) ? $bookingPaymentData['data'] : []; if (!empty($bookingPaymentData)) { $bookingPaymentDataCollect = collect($bookingPaymentData); $bookingPaymentData = $bookingPaymentDataCollect->where('booking_detail.checkout_date', '<', Carbon::now()->subDays(7))->toArray(); } //$bookingPaymentData foreach ($bookingPaymentData as $bookingPaymentKey => $bookingPayment) { if (empty($bookingPayment['booking_detail']['channel_manager_id'])) { continue; } $channelManagerId = $bookingPayment['booking_detail']['channel_manager_id']; switch ($channelManagerId) { case 2 : $channelService = App::make("App\Core\Service\ChannelManager\\{$bookingPayment['booking_detail']['channel_manager']['name']}"); $removeCreditCardToken = $channelService->removeCreditCardToken($bookingPayment['data']); if (!$removeCreditCardToken['status']) { //Hata maili atılsın $this->error(date('Y-m-d H:i:s') . ' : Channel: ' . $bookingPayment['booking_detail']['channel_manager']['name'] . ' Token: ' . $bookingPayment['data']); } else { $this->bookingPaymentService->updatePaymentData($bookingPayment['id'], ['status' => 1]); $this->info(date('Y-m-d H:i:s') . ' : Channel: ' . $bookingPayment['booking_detail']['channel_manager']['name'] . ' Token: ' . $bookingPayment['data']); } break; default; break; } } $this->info(date('Y-m-d H:i:s') . ' : Finished'); } catch (ApiErrorException $e) { $this->error(date('Y-m-d H:i:s') . ' : Error: ' . $e->getMessage()); } catch (Exception $e) { $message = $e->getFile() . " " . $e->getLine() . " " . $e->getMessage(); Log::error($message); $this->error(date('Y-m-d H:i:s') . ' : Error: ' . $message); } } }