|
...
|
...
|
@@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController |
|
|
|
'data' => array_values($indexed_pages['data'] ?? []),
|
|
|
|
];
|
|
|
|
//月统计报告
|
|
|
|
$data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']);
|
|
|
|
$data['month_count'] = $this->currentMonthCount($this->param['project_id']);
|
|
|
|
//测速
|
|
|
|
$speed = Speed::where('project_id', $this->param['project_id'])->first();
|
|
|
|
$data['speed'] = $speed['data'] ?? [];
|
|
...
|
...
|
@@ -110,107 +110,30 @@ class OptimizationReportController extends BaseController |
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/3 9:55
|
|
|
|
*/
|
|
|
|
public function currentMonthCount($domain,$project_id){
|
|
|
|
// 获取当前月的开始时间
|
|
|
|
$startTime = date('Y-m-01', strtotime($this->param['date']));
|
|
|
|
// 获取当前月的结束时间
|
|
|
|
$endTime = date('Y-m-t', strtotime($this->param['date']));
|
|
|
|
public function currentMonthCount($project_id){
|
|
|
|
$arr = [];
|
|
|
|
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);
|
|
|
|
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
|
|
|
|
$arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
|
|
|
|
$arr['month'] = date('Y-m',time());
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $domain
|
|
|
|
* @param $project_id
|
|
|
|
* @remark :询盘按月统计
|
|
|
|
* @name :inquiryCount
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 14:29
|
|
|
|
*/
|
|
|
|
public function inquiryCount(&$arr, &$startTime, $project_id){
|
|
|
|
$month = date('Y-m',strtotime($startTime));
|
|
|
|
$date = date('Y-m', strtotime($this->param['date']));
|
|
|
|
$monthCountModel = new MonthCount();
|
|
|
|
$info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]);
|
|
|
|
if($info !== false){
|
|
|
|
$arr['country'] = $info['country'];
|
|
|
|
$arr['total'] = $info['total'];
|
|
|
|
$arr['month_total'] = $info['month_total'];
|
|
|
|
}
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :流量统计
|
|
|
|
* @name :flowCount
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 14:31
|
|
|
|
*/
|
|
|
|
public function flowCount(&$arr,&$startTime,&$endTime,$project_id){
|
|
|
|
$pv_ip = DB::table('gl_count')
|
|
|
|
->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;
|
|
|
|
$arr['rate'] = 0;
|
|
|
|
if($arr['ip'] != 0){
|
|
|
|
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
|
|
|
|
$month_info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$date]);
|
|
|
|
if($month_info !== false){
|
|
|
|
$arr['country'] = $month_info['country'];
|
|
|
|
$arr['total'] = $month_info['total'];
|
|
|
|
$arr['month_total'] = $month_info['month_total'];
|
|
|
|
$arr['pv'] = $month_info['pv'];
|
|
|
|
$arr['ip'] = $month_info['ip'];
|
|
|
|
$arr['rate'] = 0;
|
|
|
|
if($arr['ip'] != 0){
|
|
|
|
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
|
|
|
|
}
|
|
|
|
$arr['source'] = json_decode($month_info['source'],true);
|
|
|
|
$arr['source_country'] = json_decode($month_info['source_country'],true);
|
|
|
|
$arr['referrer_url'] = json_decode($month_info['referrer_url'],true);
|
|
|
|
$arr['referrer_port'] = json_decode($month_info['referrer_port'],true);
|
|
|
|
}
|
|
|
|
$arr['month'] = date('Y-m',time());
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :来源访问前8
|
|
|
|
* @name :sourceCount
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 16:14
|
|
|
|
*/
|
|
|
|
public function sourceCount(&$arr,$startTime,$endTime,$domain){
|
|
|
|
//访问来源前10
|
|
|
|
$source = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
->select('referrer_url', DB::raw('COUNT(*) as count'))
|
|
|
|
->groupBy('referrer_url')
|
|
|
|
->where('referrer_url','!=','')
|
|
|
|
->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->orderByDesc('count')->limit(10)->get()->toArray();
|
|
|
|
$arr['source'] = $source;
|
|
|
|
//访问国家前15
|
|
|
|
$query = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
|
|
|
|
->groupBy('country');
|
|
|
|
|
|
|
|
$query->where('country','<>','中国');
|
|
|
|
|
|
|
|
$source_country = $query->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->orderBy('ip','desc')->limit(15)->get()->toArray();
|
|
|
|
$arr['source_country'] = $source_country;
|
|
|
|
//受访界面前15
|
|
|
|
$referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
->select('url',DB::raw('COUNT(*) as num'))
|
|
|
|
->orderBy('num','desc')
|
|
|
|
->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->groupBy('url')
|
|
|
|
->limit(15)->get()->toArray();
|
|
|
|
$arr['referrer_url'] = $referrer_url;
|
|
|
|
//访问断后
|
|
|
|
$referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
->select('device_port',DB::raw('COUNT(*) as num'))
|
|
|
|
->orderBy('num','desc')
|
|
|
|
->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
->groupBy('device_port')
|
|
|
|
->limit(15)->get()->toArray();
|
|
|
|
$arr['referrer_port'] = $referrer_port;
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getApiList($projectInfo,$export = false)
|
|
|
|
{
|
...
|
...
|
|