예제 #1
0
 public function onAfterSave($event)
 {
     //CVarDumper::dump(get_class_vars(get_class($event->sender)));
     $transition = array();
     $transition['type'] = 'afterSave';
     $transition['modelName'] = get_class($event->sender);
     $transition['modelId'] = $event->sender->primaryKey;
     $transition['state'] = $event->sender->{$this->statusAttribute};
     $transition['time'] = date('Y-m-d H:i:s');
     $transition['requestIds'] = SWLogActiveRecord::$requestIds;
     SWLogActiveRecord::$requestIds = array();
     //CVarDumper::dump($transition);
     WorkflowStates::setTransition($transition);
     //return parent::afterSave();
 }
예제 #2
0
 public function stageTicketingRepeat()
 {
     $this->status('ticketingError');
     return;
     //pass;
     $this->flightBooker->tryCount++;
     $this->flightBooker->save();
     if ($this->flightBooker->tryCount > 3) {
         $this->status('ticketingError');
     } else {
         $flightTicketingParams = new FlightTicketingParams();
         $flightTicketingParams->nemoBookId = $this->flightBooker->nemoBookId;
         $flightTicketingParams->pnr = $this->flightBooker->pnr;
         /** @var FlightTicketingResponse $flightTicketingResponse  */
         $flightTicketingResponse = Yii::app()->gdsAdapter->FlightTicketing($flightTicketingParams);
         SWLogActiveRecord::$requestIds = array_merge(SWLogActiveRecord::$requestIds, GDSNemoAgency::$requestIds);
         GDSNemoAgency::$requestIds = array();
         if ($flightTicketingResponse->status == 1) {
             $this->status('ticketReady');
         } else {
             //TODO: переставить стутус через время T + считать количество раз.
             $res = Yii::app()->cron->add(time() + appParams('flight_repeat_time'), 'flightbooking', 'ChangeState', array('flightBookerId' => $this->flightBooker->id, 'newState' => 'ticketingRepeat'));
             if ($res) {
                 $this->flightBooker->saveTaskInfo('ticketingRepeat', $res);
                 return true;
             }
             //$this->status('ticketingRepeat');
         }
     }
 }
예제 #3
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');
     }
 }