作者 lyh

gx

... ... @@ -44,6 +44,7 @@ class InquiryMonthlyCount extends Command
//按月统计询盘记录
$this->inquiryCount($startTime,$endTime,$value['test_domain'],$value['project_id']);
}
return true;
}
/**
... ... @@ -82,6 +83,7 @@ class InquiryMonthlyCount extends Command
$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;
... ... @@ -111,19 +113,26 @@ class InquiryMonthlyCount extends Command
}
/**
* @remark :访问前8
* @remark :来源访问前8
* @name :sourceCount
* @author :lyh
* @method :post
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$domain){
$data = DB::table('gl_customer_visit')
public function sourceCount(&$arr,$domain,$startTime,$endTime){
$arr['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(8)->get()->toArray();
if(!empty($data)){
$arr['source'] = json_encode($data);
$arr['source'] = json_encode($arr['source']);
}
$arr['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])
->orderBy('ip','desc')->limit(15)->get()->toArray();
return $arr;
}
}
... ...
... ... @@ -151,14 +151,14 @@ class ComController extends BaseController
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
$data = DB::table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>'http://lxl.petuu.shop/'])
$arr['source_country'] = DB::table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->where(['domain'=>'http://lxl.petuu.shop/'])
->where('updated_date','>=',$startTime)
->where('updated_date','<=',$endTime)
->orderByDesc('count')->limit(8)->get()->toArray();
->orderBy('ip','desc')->limit(15)->get()->toArray();
if(!empty($data)){
$data = json_encode($data);
$data = json_encode($arr['source_country']);
}
return $data;
}
... ...