Пример #1
0
 public function stageTicketingRepeat()
 {
     echo "event ticketing repeat {$this->hotelBooker->tryCount}\n";
     $this->hotelBooker->tryCount++;
     echo "after ++ {$this->hotelBooker->tryCount}\n";
     //return;
     //$this->hotelBooker->save(); рекурсия
     if ($this->hotelBooker->tryCount > 3) {
         $this->status('ticketingError');
         return;
     }
     $hotelOrderParams = new HotelOrderParams();
     $hotelOrderParams->hotel = $this->hotel;
     $contactName = '';
     foreach ($this->hotelBooker->hotelBookingPassports as $passport) {
         $roomer = new Roomer();
         $roomer->setFromHotelBookingPassport($passport);
         $roomer->roomId = $passport->roomKey;
         if (!$contactName) {
             $contactName = $roomer->fullName;
         }
         $hotelOrderParams->roomers[] = $roomer;
     }
     $hotelOrderParams->contactPhone = $this->hotelBooker->orderBooking->phone;
     $hotelOrderParams->contactEmail = $this->hotelBooker->orderBooking->email;
     $hotelOrderParams->contactName = $contactName;
     $hotelBookClient = new HotelBookClient();
     if ($this->hotelBooker->orderId) {
         $orderInfo = new HotelOrderResponse();
         $orderInfo->orderId = $this->hotelBooker->orderId;
     } else {
         $orderInfo = $hotelBookClient->addOrder($hotelOrderParams);
         SWLogActiveRecord::$requestIds = array_merge(SWLogActiveRecord::$requestIds, HotelBookClient::$requestIds);
         HotelBookClient::$requestIds = array();
     }
     if ($orderInfo->orderId) {
         $this->hotelBooker->orderId = $orderInfo->orderId;
         $confirmInfo = $hotelBookClient->confirmOrder($orderInfo->orderId);
         SWLogActiveRecord::$requestIds = array_merge(SWLogActiveRecord::$requestIds, HotelBookClient::$requestIds);
         HotelBookClient::$requestIds = array();
         if (!$confirmInfo->error) {
             $this->status('ticketReady');
         } else {
             echo $this->hotelBooker->id;
             $res = Yii::app()->cron->add(time() + appParams('hotel_repeat_time'), 'hotelbooking', 'ChangeState', array('hotelBookerId' => $this->hotelBooker->id, 'newState' => 'ticketingRepeat'));
             if ($res) {
                 $this->hotelBooker->saveTaskInfo('repeatTime', $res);
             }
             //$this->status('ticketingRepeat');
         }
     } else {
         $res = Yii::app()->cron->add(time() + appParams('hotel_repeat_time'), 'hotelbooking', 'ChangeState', array('hotelBookerId' => $this->hotelBooker->id, 'newState' => 'ticketingRepeat'));
         if ($res) {
             $this->hotelBooker->saveTaskInfo('repeatTime', $res);
         }
         //$this->status('ticketingRepeat');
     }
 }