作者 lyh

gx

... ... @@ -120,19 +120,24 @@ class InquiryMonthlyCount extends Command
* @time :2023/6/30 16:14
*/
public function sourceCount(&$arr,$domain,$startTime,$endTime){
//访问来源前10
$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();
->orderByDesc('count')->limit(10)->get()->toArray();
if(!empty($data)){
$arr['source'] = json_encode($arr['source']);
}
//访问国家前15
$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])
->where('updated_date','>=',$startTime->toDateString())
->where('updated_date','<=',$endTime->toDateString())
->orderBy('ip','desc')->limit(15)->get()->toArray();
//受访界面
return $arr;
}
}
... ...
... ... @@ -151,16 +151,14 @@ class ComController extends BaseController
$startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
$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)
->orderBy('ip','desc')->limit(15)->get()->toArray();
if(!empty($arr['source_country'])){
$arr['source_country'] = json_encode($arr['source_country']);
$arr = DB::table('gl_customer_visit_item')
->select('url',DB::raw('COUNT(*) as num'))
->groupBy('url')->where(['domain'=>'http://lxl.petuu.shop/'])
->limit(15)->get()->toArray();
if(!empty($arr)){
$arr = json_encode($arr['source_country']);
}
return $arr['source_country'];
return $arr;
}
/**
... ...