Example #1
0
 /**
  * 
  * Enter Get province list
  * @param array $country_code country code
  */
 public function getRegionByCountry($country_code = array())
 {
     $redis = new RedisBaseModel(Config::get('redis.redis_3.host'), Config::get('redis.redis_3.port'), false);
     $result = array();
     if (!empty($country_code)) {
         foreach ($country_code as $value) {
             $cacheKey = "GeoBaseModel:Region:{$value}";
             $retval = $redis->get($cacheKey);
             if (!$retval) {
                 $retval = DB::table('geo')->select('country_code', 'country_name', 'region')->groupBy('country_code', 'region')->where('region', '<>', '-')->where('country_code', $value)->get();
                 $redis->set($cacheKey, $retval);
             }
             $result = $this->meargeObj($result, $retval);
         }
         return $result;
     } else {
         return FALSE;
     }
 }
Example #2
0
 public function getListTrackURL($id, $inputs = '')
 {
     $redis = new RedisBaseModel(Config::get('redis.redis_3.host'), Config::get('redis.redis_3.port'), false);
     $cacheKey = "URLTrack3rd." . $id;
     $data = array();
     $end = date('Y-m-d');
     $start = strtotime('-7 days', strtotime($end));
     if (isset($inputs['start']) && isset($inputs['end']) && $inputs['start'] != '' && $inputs['end'] != '') {
         $start = strtotime($inputs['start']);
         $end = $inputs['end'];
     }
     if (URLTrackGAModel::sum($id) > 0) {
         while (strtotime($end) >= $start) {
             $total = $redis->get($cacheKey . "." . date('Ymd', strtotime($end)));
             if ($total > 0) {
                 $item['date'] = $end;
                 $item['total'] = $total;
                 $data[] = $item;
             }
             $end = date('Y-m-d', strtotime("-1 day" . $end));
         }
     }
     return $data;
 }
Example #3
0
 function getConversion($conversionID, $renewCache = false)
 {
     $redis = new RedisBaseModel(Config::get('redis.redis_2.host'), Config::get('redis.redis_2.port'), false);
     $cacheKey = "Conversion";
     $cacheField = $conversionID;
     $retval = $redis->hGet($cacheKey, $cacheField);
     if (Input::get('cleared') || $renewCache) {
         $redis->hDel($cacheKey, $cacheField);
         if (!empty($retval->campaign_id)) {
             $redis->hDel("CampConv_{$retval->campaign_id}", $cacheField);
         }
         $retval = 0;
     }
     if (!$retval) {
         $retval = DB::table('conversion')->join('campaign', 'conversion.campaign_id', '=', 'campaign.id')->where('conversion.id', $conversionID)->where('conversion.status', 1)->select('conversion.id', 'conversion.name', 'conversion.campaign_id', 'conversion.param', 'conversion.source', 'campaign.name')->first();
         if ($retval) {
             $retval->param = json_decode($retval->param);
             $redis->hSet("CampConv_{$retval->campaign_id}", $conversionID, $conversionID);
         }
         $redis->hSet($cacheKey, $cacheField, $retval);
     }
     return $retval;
 }
Example #4
0
 public function getPfcountAttribute()
 {
     $oRedis = new RedisBaseModel(Config::get('redis.redis_6.host'), Config::get('redis.redis_6.port'), false);
     $kM = "au." . $this->audience_id;
     return $oRedis->pfcount($kM);
 }
Example #5
0
 /**
  * 
  * Get campaign
  * @param int $campaignID
  * @param bool $renewCache
  */
 public function getCampaign($campaignID, $renewCache = false)
 {
     $redis = new RedisBaseModel(Config::get('redis.redis_2.host'), Config::get('redis.redis_2.port'), false);
     $cacheKey = "Campaign";
     $cacheField = $campaignID;
     $retval = $redis->hGet($cacheKey, $cacheField);
     if (Input::get('cleared') || $renewCache) {
         $redis->hDel($cacheKey, $cacheField);
         $retval = 0;
     }
     if (!$retval) {
         $retval = DB::table('campaign')->select('id', 'name', 'advertiser_id', 'category_id')->where('id', $campaignID)->first();
         $redis->hSet($cacheKey, $cacheField, $retval);
     }
     return $retval;
 }