|
...
|
...
|
@@ -52,139 +52,6 @@ class MonthCountLogic extends BaseLogic |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :获取当前月数据统计
|
|
|
|
* @name :currentMonth
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/7/3 9:55
|
|
|
|
*/
|
|
|
|
public function currentMonthCount(){
|
|
|
|
$startTime = Carbon::now()->startOfMonth()->toDateString();
|
|
|
|
$endTime = date('Y-m-d',time());
|
|
|
|
$arr = [];
|
|
|
|
$arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);
|
|
|
|
$arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);
|
|
|
|
$arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']);
|
|
|
|
$arr['month'] = date('Y-m',time());
|
|
|
|
return $this->success($arr);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param $domain
|
|
|
|
* @param $project_id
|
|
|
|
* @remark :询盘按月统计
|
|
|
|
* @name :inquiryCount
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 14:29
|
|
|
|
*/
|
|
|
|
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
|
|
|
|
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
|
|
|
|
if(!empty($inquiry_list)){
|
|
|
|
//总数
|
|
|
|
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
|
|
|
|
//数据详情
|
|
|
|
$data = $inquiry_list['data']['data'] ?? '';
|
|
|
|
$arr['month_total'] = 0;
|
|
|
|
$countryArr = [];
|
|
|
|
if(isset($data) && !empty($data)){
|
|
|
|
foreach ($data as $v){
|
|
|
|
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
|
|
|
|
$arr['month_total']++;
|
|
|
|
if(isset($countryArr[$v['country']])){
|
|
|
|
$countryArr[$v['country']]++;
|
|
|
|
}else{
|
|
|
|
$countryArr[$v['country']] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//加上其他询盘
|
|
|
|
$arr['total'] += InquiryFormData::getCount();
|
|
|
|
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
|
|
|
|
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
|
|
|
|
foreach ($countryData as $v1){
|
|
|
|
if(isset($countryArr[$v1['country']])){
|
|
|
|
$countryArr[$v1['country']] += $v1['count'];
|
|
|
|
}else{
|
|
|
|
$countryArr[$v1['country']] = $v1['count'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
arsort($countryArr);
|
|
|
|
$top20 = array_slice($countryArr, 0, 15, true);
|
|
|
|
$arr['country'] = $top20;
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
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');
|
|
|
|
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
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :根据时间获取pv,ip
|
|
|
|
* @name :getIpPvCount
|
|
|
|
* @author :lyh
|
...
|
...
|
|