当前位置: 首页>>代码示例>>PHP>>正文


PHP Tracking::runningInventory方法代码示例

本文整理汇总了PHP中Tracking::runningInventory方法的典型用法代码示例。如果您正苦于以下问题:PHP Tracking::runningInventory方法的具体用法?PHP Tracking::runningInventory怎么用?PHP Tracking::runningInventory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tracking的用法示例。


在下文中一共展示了Tracking::runningInventory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: adsProcess

 public function adsProcess()
 {
     $responseType = '';
     $expandFields = array();
     $zoneID = Input::get('zid', 0);
     $publisherID = Input::get('pid', 0);
     $requestType = Input::get('type', Delivery::REQUEST_TYPE_AD);
     $trackingModel = new Tracking();
     $deliveryModel = new Delivery();
     $flightDateModel = new FlightDateBaseModel();
     //ghi log trước khi xử lý
     $logPreProcess = $trackingModel->logPreProcess($requestType);
     if ($logPreProcess) {
         //kiểm tra referrer
         $hostReferer = $trackingModel->getRequestReferer();
         if (empty($zoneID)) {
             $responseType = Delivery::RESPONSE_TYPE_INVALID;
         } elseif (empty($hostReferer)) {
             $responseType = Delivery::RESPONSE_TYPE_EMPTY_REFERRER;
         } elseif ($trackingModel->countLatestRequest(1) < Delivery::ANTI_CHEAT_MAX_REQUEST_PER_1MIN && $trackingModel->countLatestRequest(5) < Delivery::ANTI_CHEAT_MAX_REQUEST_PER_5MIN) {
             $responseType = Delivery::RESPONSE_TYPE_ANTI_MANY_REQUEST;
         }
         //pre validate ok
         if (empty($responseType)) {
             //default invalid
             if ($zoneID && $publisherID) {
                 $adZone = PublisherAdZoneBaseModel::find($zoneID);
                 if ($adZone && $adZone->publisher) {
                     if ($adZone->publisher_id == $publisherID) {
                         $flightPublishers = FlightPublisherBaseModel::where('publisher_id', $publisherID)->with('flightDate', function ($query) {
                             $today = date('Y-m-d');
                             $query->where('start', '<=', $today)->where('end', '>=', $today);
                         })->where('publisher_ad_zone_id', $zoneID)->orderBy('order', 'asc')->get();
                         if ($flightPublishers) {
                             if ($requestType == Delivery::REQUEST_TYPE_AD) {
                                 //lấy ad từ list thỏa điều kiện để trả về
                                 foreach ($flightPublishers as $k => $flightPublisher) {
                                     if ($flightPublisher->flightDate) {
                                         $runningInventory = $trackingModel->runningInventory($flightPublisher->id);
                                         if ($flightPublisher->total_inventory < $runningInventory) {
                                             $deliveryStatus = $deliveryModel->deliveryAd($flightPublisher->ad, $flightPublisher->flight);
                                             if ($deliveryStatus == Delivery::DELIVERY_STATUS_OK) {
                                                 //trả về ad này
                                                 $serveAd = $flightPublisher->ad;
                                                 $expandFields = array('flight_id' => $flightPublisher->flight_id, 'ad_format_id' => $flightPublisher->ad_format_id, 'ad_id' => $flightPublisher->ad_id, 'campaign_id' => $flightPublisher->campaign_id, 'publisher_ad_zone_id' => $flightPublisher->publisher_ad_zone_id, 'flight_publisher_id' => $flightPublisher->id, 'publisher_id' => $flightPublisher->publisher_id, 'flight_publisher_id' => $flightPublisher->id);
                                                 break;
                                             }
                                         }
                                     }
                                 }
                                 //endforeach
                             } elseif ($requestType == Delivery::REQUEST_TYPE_TRACKING_BEACON) {
                                 //tracking beacon TO DO, now : do nothing
                                 if ($trackingModel->isKnownVisitor()) {
                                 } else {
                                     $responseType = Delivery::RESPONSE_TYPE_EMPTY_REFERRER;
                                 }
                             }
                         }
                     }
                     //serve Ad
                     if (!empty($serveAd)) {
                     } else {
                     }
                 }
             }
         }
     }
     if (empty($responseType)) {
         $responseType = Delivery::RESPONSE_TYPE_INVALID;
     }
     //ghi log process
     $trackingModel->logAfterProcess($responseType, $expandFields);
     return $deliveryModel->emptyAd();
 }
开发者ID:huycao,项目名称:yoplatform,代码行数:75,代码来源:TrackingEventController.php


注:本文中的Tracking::runningInventory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。