Beispiel #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;
 }
Beispiel #2
0
 public function mergeStepV2()
 {
     if ($this->_hotels) {
         $mergedStacks = array();
         $needStop = false;
         $firstElem = true;
         //foreach($this->hotelStacks as $keyStack=>$hotelStack){
         foreach ($this->_hotels as $hotelKey => $otherHotel) {
             if ($firstElem) {
                 $newHotelStack = new HotelStack();
                 $newHotelStack->addHotel($otherHotel);
                 $mergedStacks[] = $newHotelStack;
                 $firstElem = false;
             } else {
                 $found = false;
                 foreach ($mergedStacks as $workHotelStackKey => $workHotelStack) {
                     $tmpHotel = $workHotelStack->getHotel();
                     $same = $tmpHotel->getMergeMetricV2($otherHotel);
                     if ($same) {
                         $found = true;
                         //may be add to hotel stack...
                         $mergedStacks[$workHotelStackKey]->addHotel($otherHotel);
                         break;
                     } else {
                         if (false && $otherHotel->hotelId == '65664') {
                             echo Hotel::$compereDesc . "hotelId: {$otherHotel->hotelId}<br>";
                             //VarDumper::dump($otherHotel);
                             $needStop = true;
                         }
                     }
                 }
                 if (!$found) {
                     $newHotelStack = new HotelStack();
                     $newHotelStack->addHotel($otherHotel);
                     $mergedStacks[] = $newHotelStack;
                 }
             }
         }
         //}
         if ($needStop) {
             exit;
         }
         //$this->groupKey = 'merged';
         //foreach()
         $this->_hotels = null;
         $this->groupKey = 'merged';
         $this->hotelStacks = $mergedStacks;
         //}
     } else {
         foreach ($this->hotelStacks as $hotelStack) {
             $hotelStack->mergeStepV2();
         }
     }
     $this->groupDeep++;
     return $this;
 }