Beispiel #1
0
 static function sendRequestToHotelProvider($hotelSearchParams)
 {
     Yii::import('site.frontend.models.*');
     Yii::import('site.frontend.components.*');
     $hotelClient = new HotelBookClient();
     $startTime = microtime(true);
     $variants = $hotelClient->fullHotelSearch($hotelSearchParams);
     $endTime = microtime(true);
     $startTime = microtime(true);
     self::storeToCache($hotelSearchParams, $variants);
     $endTime = microtime(true);
     $startTime = microtime(true);
     Yii::app()->hotelsRating->injectRating($variants->hotels, $hotelSearchParams->city);
     $endTime = microtime(true);
     //}
     $results = array();
     if ($variants->responseStatus == ResponseStatus::ERROR_CODE_NO_ERRORS) {
         $startTime = microtime(true);
         $stack = new HotelStack($variants);
         $results = $stack->groupBy('hotelId', 117501)->mergeStepV2()->groupBy('rubPrice')->getJsonObject(1);
         $stack->saveHotelDb();
         $nStack = new HotelStack();
         $nStack->_hotels = $stack->getHotels(1);
         $resultsHotels = $stack->getJsonObject();
         foreach ($resultsHotels['hotels'] as $i => $info) {
             $hotelInfo = $hotelClient->hotelDetail($info['hotelId']);
             if ($hotelInfo) {
                 $hotelsDetails[$info['hotelId'] . 'd'] = self::prepare($hotelInfo);
             }
         }
         /*
                     $query = array();
                     foreach ($resultsHotels['hotels'] as $i => $info)
                     {
                         $query[$info['hotelId']] = $hotelClient->hotelDetail($info['hotelId'], true);
                     }
         
                     $hotelClient->processAsyncRequests();
                     $endTime = microtime(true);
         
                     Header('ExecutionTimeSortAndDetails:' . ($endTime - $startTime));
         
                     $hotelsDetails = array();
                     foreach ($query as $hotelId => $responseId)
                     {
                         if (isset($hotelClient->requests[$responseId]['result']))
                         {
                             $hotelsDetails[$hotelId . 'd'] = self::prepare($hotelClient->requests[$responseId]['result']);
                             //Yii::app()->cache->set('HotelDetails-' . $hotelId, $hotelsDetails[$hotelId . 'd']);
                         }
                     }/**/
         $results['hotelsDetails'] = $hotelsDetails;
         return $results;
     } elseif ($variants->responseStatus == ResponseStatus::ERROR_CODE_EMPTY) {
         $results['hotels'] = array();
         return $results;
     } else {
         return false;
     }
 }