/** * * 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; } }
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; }