Пример #1
0
 public function hotelSearchFullDetails(HotelSearchParams $hotelSearchParams, $hotelId, $hotels = null)
 {
     $rooms = $hotelSearchParams->rooms;
     //Make combinations to combinations Array
     //uasort($rooms,'HotelBookClient::compareArrayAdultCount');
     $maxAdultCount = 0;
     foreach ($rooms as $room) {
         $count = $room['adultCount'] + $room['childCount'];
         if ($count > $maxAdultCount) {
             $maxAdultCount = $count;
         }
     }
     if ($maxAdultCount > 4) {
         $maxAdultCount = 4;
     }
     self::$groupId = substr(md5(uniqid('', true)), 0, 10);
     $i = 1;
     $j = 0;
     $end = false;
     $reqs = array();
     while (!$end) {
         $params = array('cityId' => $hotelSearchParams->city->hotelbookId, 'checkIn' => $hotelSearchParams->checkIn, 'duration' => $hotelSearchParams->duration, 'hotelId' => $hotelId);
         $params['rooms'] = array();
         $params['rooms'][] = array('roomSizeId' => self::$roomSizeRoomTypesMap[$i][$j], 'child' => 0, 'cots' => 0, 'roomNumber' => 1);
         $reqs[] = self::hotelSearch($params, true);
         if (count(self::$roomSizeRoomTypesMap[$i]) > $j + 1) {
             $j++;
         } elseif ($i < $maxAdultCount) {
             $i++;
             $j = 0;
         } else {
             $end = true;
         }
     }
     //run all requests
     $this->processAsyncRequests();
     //$hotelStacks = array();
     $hotels = array();
     foreach ($reqs as $requestId) {
         $hotelStack = new HotelStack();
         if ($this->requests[$requestId]['result']->hotels) {
             //print_r($this->requests[$requestId]['result']);die();
             foreach ($this->requests[$requestId]['result']->hotels as $hotel) {
                 $hotelStack->addHotel($hotel);
             }
             foreach ($hotelStack->_hotels as $key => $hotel) {
                 if (!isset($hotels[$key])) {
                     $hotels[$key] = $hotel;
                 }
             }
         }
         //$hotelStacks[] = $hotelStack;
     }
     return $hotels;
 }