예제 #1
0
 protected function loadStat(YandexDirect $liveEngine, $campaignXmlId, $dateStart, $dateFinish, $skipCurrency = false)
 {
     $dateStart = new Date($dateStart);
     $dateFinish = new Date($dateFinish);
     $queryData = array("CampaignID" => $campaignXmlId, "StartDate" => $dateStart->format("Y-m-d"), 'EndDate' => $dateFinish->format("Y-m-d"), 'GroupByColumns' => array('clDate', 'clBanner'));
     $currency = '';
     if (!$skipCurrency && Loader::includeModule('currency')) {
         $baseCurrency = \CCurrency::GetBaseCurrency();
         if ($baseCurrency == 'RUR') {
             $baseCurrency = 'RUB';
         }
         if (in_array($baseCurrency, $liveEngine->allowedCurrency)) {
             $currency = $baseCurrency;
         }
     }
     if ($currency != '') {
         $queryData['Currency'] = $currency;
     }
     try {
         $result = $liveEngine->getBannerStats($queryData);
         $result['Currency'] = $currency;
     } catch (YandexDirectException $e) {
         if ($currency != '' && $e->getCode() == YandexDirect::ERROR_WRONG_CURRENCY) {
             $result = static::loadStat($liveEngine, $campaignXmlId, $dateStart, $dateFinish, true);
         } else {
             throw $e;
         }
     }
     return $result;
 }