|
...
|
...
|
@@ -41,8 +41,19 @@ class InquiryMonthlyCount extends Command |
|
|
|
// 获取上个月的结束时间
|
|
|
|
$endTime = Carbon::now()->subMonth()->endOfMonth();
|
|
|
|
foreach ($list as $value){
|
|
|
|
$arr = [];
|
|
|
|
//按月统计询盘记录
|
|
|
|
$this->inquiryCount($startTime,$endTime,$value['test_domain'],$value['project_id']);
|
|
|
|
$arr = $this->inquiryCount($startTime,$endTime,$value['test_domain']);
|
|
|
|
$arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
|
|
|
|
$arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
|
|
|
|
$arr['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$arr['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$arr['project_id'] = $value['project_id'];
|
|
|
|
// 获取当前日期时间
|
|
|
|
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
|
|
|
|
var_dump($arr);
|
|
|
|
die();
|
|
|
|
DB::table('gl_month_count')->insert($arr);
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
...
|
...
|
@@ -56,10 +67,9 @@ class InquiryMonthlyCount extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 14:29
|
|
|
|
*/
|
|
|
|
public function inquiryCount(&$startTime,&$endTime,$domain,$project_id){
|
|
|
|
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
|
|
|
|
//TODO::上线后注释
|
|
|
|
$domain = 'https://demomark.globalso.com/';
|
|
|
|
$arr = [];
|
|
|
|
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
|
|
|
|
//总数
|
|
|
|
$arr['total'] = $inquiry_list['data']['total'];
|
|
...
|
...
|
@@ -77,17 +87,10 @@ class InquiryMonthlyCount extends Command |
|
|
|
$countryArr[$v['country']] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 获取当前日期时间
|
|
|
|
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
|
|
|
|
arsort($countryArr);
|
|
|
|
$top20 = array_slice($countryArr, 0, 15, true);
|
|
|
|
$arr['country'] = json_encode($top20);
|
|
|
|
$this->flowCount($arr,$startTime,$endTime,$project_id);
|
|
|
|
$this->sourceCount($arr,$domain,$startTime,$endTime);
|
|
|
|
$arr['created_at'] = date('Y-m-d H:i:s');
|
|
|
|
$arr['updated_at'] = date('Y-m-d H:i:s');
|
|
|
|
$arr['project_id'] = $project_id;
|
|
|
|
DB::table('gl_month_count')->insert($arr);
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -121,47 +124,39 @@ class InquiryMonthlyCount extends Command |
|
|
|
*/
|
|
|
|
public function sourceCount(&$arr,$domain,$startTime,$endTime){
|
|
|
|
//访问来源前10
|
|
|
|
$arr['source'] = DB::table('gl_customer_visit')
|
|
|
|
$source = DB::table('gl_customer_visit')
|
|
|
|
->select('referrer_url', DB::raw('COUNT(*) as count'))
|
|
|
|
->groupBy('referrer_url')->where(['domain'=>$domain])
|
|
|
|
->where('updated_date','>=',$startTime->toDateString())
|
|
|
|
->where('updated_date','<=',$endTime->toDateString())
|
|
|
|
->orderByDesc('count')->limit(10)->get()->toArray();
|
|
|
|
if(!empty($arr['source'])){
|
|
|
|
$arr['source'] = json_encode($arr['source']);
|
|
|
|
}
|
|
|
|
$arr['source'] = json_encode($source);
|
|
|
|
//访问国家前15
|
|
|
|
$arr['source_country'] = DB::table('gl_customer_visit')
|
|
|
|
$source_country = DB::table('gl_customer_visit')
|
|
|
|
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
|
|
|
|
->groupBy('country')->where(['domain'=>$domain])
|
|
|
|
->where('updated_date','>=',$startTime->toDateString())
|
|
|
|
->where('updated_date','<=',$endTime->toDateString())
|
|
|
|
->orderBy('ip','desc')->limit(15)->get()->toArray();
|
|
|
|
if(!empty($arr['source_country'])){
|
|
|
|
$arr['source_country'] = json_encode($arr['source_country']);
|
|
|
|
}
|
|
|
|
$arr['source_country'] = json_encode($source_country);
|
|
|
|
//受访界面前15
|
|
|
|
$arr['referrer_url'] = DB::table('gl_customer_visit_item')
|
|
|
|
$referrer_url = DB::table('gl_customer_visit_item')
|
|
|
|
->select('url',DB::raw('COUNT(*) as num'))
|
|
|
|
->orderBy('num','desc')->where(['domain'=>$domain])
|
|
|
|
->where('updated_date','>=',$startTime->toDateString())
|
|
|
|
->where('updated_date','<=',$endTime->toDateString())
|
|
|
|
->groupBy('url')
|
|
|
|
->limit(15)->get()->toArray();
|
|
|
|
if(!empty($arr['referrer_url'])){
|
|
|
|
$arr['referrer_url'] = json_encode($arr['referrer_url']);
|
|
|
|
}
|
|
|
|
$arr['referrer_url'] = json_encode($referrer_url);
|
|
|
|
//访问断后
|
|
|
|
$arr['referrer_port'] = DB::table('gl_customer_visit_item')
|
|
|
|
$referrer_port = DB::table('gl_customer_visit_item')
|
|
|
|
->select('device_port',DB::raw('COUNT(*) as num'))
|
|
|
|
->orderBy('num','desc')->where(['domain'=>$domain])
|
|
|
|
->where('updated_date','>=',$startTime->toDateString())
|
|
|
|
->where('updated_date','<=',$endTime->toDateString())
|
|
|
|
->groupBy('device_port')
|
|
|
|
->limit(15)->get()->toArray();
|
|
|
|
if(!empty($arr['referrer_port'])){
|
|
|
|
$arr['referrer_port'] = json_encode($arr['referrer_port']);
|
|
|
|
}
|
|
|
|
$arr['referrer_port'] = json_encode($referrer_port);
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|