作者 lyh

gx

... ... @@ -81,16 +81,10 @@ class InquiryMonthlyCount extends Command
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = json_encode($top20);
$this->flowCount($arr,$startTime,$endTime,$project_id);
$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;
$pv_ip = DB::table('gl_count')
->where(['project_id'=>1])
->where('date','>=',$startTime->toDateString().' 00:00:00')
->where('date','<=',$endTime->toDateString().' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->get();
DB::table('gl_inquiry_month_count')->insert($arr);
}
... ... @@ -101,11 +95,35 @@ class InquiryMonthlyCount extends Command
* @method :post
* @time :2023/6/30 14:31
*/
public function flowCount($startTime,$endTime,$project_id){
DB::table('gl_count')
public function flowCount(&$arr,$startTime,$endTime,$project_id){
$pv_ip = DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$startTime.' 00:00:00')
->where('date','<=',$endTime.' 23:59:59')
->sum('pv_num');
->where('date','>=',$startTime->toDateString().' 00:00:00')
->where('date','<=',$endTime->toDateString().' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->first();
$arr['pv'] = $pv_ip['pv_num'];
$arr['ip'] = $pv_ip['ip_num'];
if($arr['ip'] != 0){
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
}
return $arr;
}
/**
* @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')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$domain])
->orderByDesc('count')->limit(8)->get()->toArray();
if(!empty($data)){
$arr['source'] = json_encode($data);
}
}
}
... ...
... ... @@ -147,19 +147,11 @@ class ComController extends BaseController
}
public function ceshi(){
$startTime = Carbon::now()->subMonth(1)->startOfMonth();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth(1)->endOfMonth();
$pv = DB::table('gl_count')
->where(['project_id'=>1])
->where('date','>=',$startTime->toDateString().' 00:00:00')
->where('date','<=',$endTime->toDateString().' 23:59:59')
->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
->first();
var_dump($pv);
die();
$this->response('success',Code::SUCCESS,$pv);
$data = DB::table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>'http://lxl.petuu.shop/'])
->orderByDesc('count')->limit(8)->get()->toArray();
return $data;
}
/**
... ...
... ... @@ -130,7 +130,8 @@ class CountLogic extends BaseLogic
*/
public function referrer_count(){
$data = DB::table('gl_customer_visit')
->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url')
->select('referrer_url', DB::raw('COUNT(*) as count'))
->groupBy('referrer_url')->where(['domain'=>$this->project['deploy_build']['test_domain']])
->orderByDesc('count')->limit(8)->get()->toArray();
$total = DB::table('gl_customer_visit')->count();
if(!empty($data)){
... ... @@ -151,7 +152,8 @@ class CountLogic extends BaseLogic
public function access_country_count(){
$data = DB::table('gl_customer_visit')
->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
->groupBy('country')->orderBy('ip','desc')->limit(20)->get()->toArray();
->groupBy('country')->where(['domain'=>$this->project['deploy_build']['test_domain']])
->orderBy('ip','desc')->limit(20)->get()->toArray();
if(!empty($data)){
$data = object_to_array($data);
foreach ($data as $k => $v){
... ...