public function getPayment() { $bookingModel = $this->getOrderBooking(); $haveStateStartPayment = true; $allTicketingValid = true; /** @var FlightBooker[] $flightBookers */ $flightBookers = FlightBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey)); foreach ($flightBookers as $flightBooker) { $status = $flightBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status !== 'startPayment') { echo 'flight'; $haveStateStartPayment = false; } //$flightBooker->timeout; } $hotelBookers = HotelBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey)); foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status !== 'softStartPayment' and $status !== 'hardStartPayment') { echo 'hotel' . $status; $haveStateStartPayment = false; } } if (!$haveStateStartPayment) { //TODO: make return money and go to find new objects $allTicketingValid = false; echo '=(('; } else { //TODO: make tiketing echo 'make ticketing'; /** @var FlightBooker[] $flightBookers */ $flightBookers = FlightBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey)); foreach ($flightBookers as $flightBooker) { $status = $flightBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'startPayment' and $allTicketingValid) { $flightBookerComponent = new FlightBookerComponent(); $flightBookerComponent->setFlightBookerFromId($flightBooker->id); $flightBookerComponent->status('ticketing'); //check that status is good //else $allTicketingValid = false; $newStatus = $flightBookerComponent->getStatus(); if ($newStatus == 'ticketingRepeat') { $allTicketingValid = false; } } //$flightBooker->timeout; } /** @var HotelBooker[] $hotelBookers */ $hotelBookers = HotelBooker::model()->findAllByAttributes(array('orderBookingId' => $bookingModel->primaryKey)); foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'softStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); //TODO: may be task to cron??? $hotelBookerComponent->status('moneyTransfer'); } } foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'hardStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); $res = $hotelBookerComponent->checkValid(); if (!$res) { $allTicketingValid = false; } } } $haveProblems = false; foreach ($hotelBookers as $hotelBooker) { $status = $hotelBooker->status; if (strpos($status, '/') !== false) { $status = substr($status, strpos($status, '/') + 1); } if ($status == 'hardStartPayment' and $allTicketingValid) { $hotelBookerComponent = new HotelBookerComponent(); $hotelBookerComponent->setHotelBookerFromId($hotelBooker->id); $hotelBookerComponent->status('ticketing'); $newStatus = $hotelBookerComponent->getCurrent()->status; if (strpos($newStatus, '/') !== false) { $newStatus = substr($newStatus, strpos($newStatus, '/') + 1); } if ($newStatus == 'ticketingRepeat') { $allTicketingValid = false; $haveProblems = true; } } } if (!$allTicketingValid) { $this->returnMoney($haveProblems); } } }