作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

... ... @@ -162,15 +162,20 @@ class CountLogic extends BaseLogic
public function access_country_count(){
$customerVisitModel = new Visit();
$data = $customerVisitModel->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->where(['domain'=>$this->user['domain']])
->orderBy('ip','desc')->limit(10)->get()->toArray();
->groupBy('country')
->orderBy('ip','desc')->limit(11)->get()->toArray();
$result =array();
if(!empty($data)){
foreach ($data as $k => $v){
if(($this->project['is_record_china_visit'] != 1) && ($v['country'] == '中国')){
continue;
}else{
$v['pv'] = (int)$v['pv'];
$data[$k] = $v;
$result[] = $v;
}
}
return $this->success($data);
}
return $this->success($result);
}
/**
... ...
... ... @@ -31,6 +31,21 @@ class MonthCountLogic extends BaseLogic
public function getCountLists($map,$order = 'created_at',$filed = ['*']){
$map['project_id'] = $this->user['project_id'];
$lists = $this->model->list($map,$order,$filed);
if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){
foreach ($lists as $k => $v){
if(empty($v['source_country'])){
continue;
}
$source_country = json_decode($v['source_country']);
foreach ($source_country as $k1 => $v1){
if($v1['country'] == '中国'){
unset($source_country[$k1]);
}
}
$v['source_country'] = json_encode(array_values($source_country));
$lists[$k] = $v;
}
}
$lists['new'] = $this->currentMonthCount();
return $this->success($lists);
}
... ... @@ -46,7 +61,6 @@ class MonthCountLogic extends BaseLogic
$startTime = Carbon::now()->startOfMonth()->toDateString();
$endTime = date('Y-m-d',time());
$arr = [];
ProjectServer::useProject($this->user['project_id']);
$arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);
$arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);
... ... @@ -114,6 +128,7 @@ class MonthCountLogic extends BaseLogic
->where(['project_id'=>$project_id])
->whereBetween('date', [$startTime,$endTime])
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->orderBy('id','desc')
->first();
$arr['pv'] = $pv_ip->pv_num;
$arr['ip'] = $pv_ip->ip_num;
... ... @@ -140,10 +155,13 @@ class MonthCountLogic extends BaseLogic
->orderByDesc('count')->limit(10)->get()->toArray();
$arr['source'] = $source;
//访问国家前15
$source_country = DB::connection('custom_mysql')->table('gl_customer_visit')
$query = DB::connection('custom_mysql')->table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')
->whereBetween('updated_date', [$startTime,$endTime])
->groupBy('country');
if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){
$query->where('country','<>','中国');
}
$source_country = $query->whereBetween('updated_date', [$startTime,$endTime])
->orderBy('ip','desc')->limit(15)->get()->toArray();
$arr['source_country'] = $source_country;
//受访界面前15
... ... @@ -176,7 +194,7 @@ class MonthCountLogic extends BaseLogic
$count = new Count();
$startTime = date("Y-m-d", strtotime("-9 months", mktime(0, 0, 0)));
$ensTime = date('Y-m-d',time());
$lists = $count->list(['date'=>['between',[$startTime,$ensTime]],'project_id'=>$this->user['project_id']]);
$lists = $count->list(['date'=>['between',[$startTime,$ensTime]],'project_id'=>$this->user['project_id']],'id',['*'],'asc');
$groupedData = [];
foreach ($lists as $k=>$v){
$month = date('Y-m', strtotime($v['date']));
... ... @@ -184,7 +202,7 @@ class MonthCountLogic extends BaseLogic
$groupedData[$month] = [];
}
if(empty($v['country'])){
$v['country'] = ['中国'=>0];
$v['country'] = [];
}
$groupedData[$month][] = $v;
}
... ...