作者 lyh

gx

@@ -120,19 +120,24 @@ class InquiryMonthlyCount extends Command @@ -120,19 +120,24 @@ class InquiryMonthlyCount extends Command
120 * @time :2023/6/30 16:14 120 * @time :2023/6/30 16:14
121 */ 121 */
122 public function sourceCount(&$arr,$domain,$startTime,$endTime){ 122 public function sourceCount(&$arr,$domain,$startTime,$endTime){
  123 + //访问来源前10
123 $arr['source'] = DB::table('gl_customer_visit') 124 $arr['source'] = DB::table('gl_customer_visit')
124 ->select('referrer_url', DB::raw('COUNT(*) as count')) 125 ->select('referrer_url', DB::raw('COUNT(*) as count'))
125 ->groupBy('referrer_url')->where(['domain'=>$domain]) 126 ->groupBy('referrer_url')->where(['domain'=>$domain])
126 ->where('updated_date','>=',$startTime->toDateString()) 127 ->where('updated_date','>=',$startTime->toDateString())
127 ->where('updated_date','<=',$endTime->toDateString()) 128 ->where('updated_date','<=',$endTime->toDateString())
128 - ->orderByDesc('count')->limit(8)->get()->toArray(); 129 + ->orderByDesc('count')->limit(10)->get()->toArray();
129 if(!empty($data)){ 130 if(!empty($data)){
130 $arr['source'] = json_encode($arr['source']); 131 $arr['source'] = json_encode($arr['source']);
131 } 132 }
  133 + //访问国家前15
132 $arr['source_country'] = DB::table('gl_customer_visit') 134 $arr['source_country'] = DB::table('gl_customer_visit')
133 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 135 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
134 ->groupBy('country')->where(['domain'=>$domain]) 136 ->groupBy('country')->where(['domain'=>$domain])
  137 + ->where('updated_date','>=',$startTime->toDateString())
  138 + ->where('updated_date','<=',$endTime->toDateString())
135 ->orderBy('ip','desc')->limit(15)->get()->toArray(); 139 ->orderBy('ip','desc')->limit(15)->get()->toArray();
  140 + //受访界面
136 return $arr; 141 return $arr;
137 } 142 }
138 } 143 }
@@ -151,16 +151,14 @@ class ComController extends BaseController @@ -151,16 +151,14 @@ class ComController extends BaseController
151 $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString(); 151 $startTime = Carbon::now()->subMonth()->startOfMonth()->toDateString();
152 // 获取上个月的结束时间 152 // 获取上个月的结束时间
153 $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString(); 153 $endTime = Carbon::now()->subMonth()->endOfMonth()->toDateString();
154 - $arr['source_country'] = DB::table('gl_customer_visit')  
155 - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))  
156 - ->groupBy('country')->where(['domain'=>'http://lxl.petuu.shop/'])  
157 -// ->where('updated_date','>=',$startTime)  
158 -// ->where('updated_date','<=',$endTime)  
159 - ->orderBy('ip','desc')->limit(15)->get()->toArray();  
160 - if(!empty($arr['source_country'])){  
161 - $arr['source_country'] = json_encode($arr['source_country']);  
162 - }  
163 - return $arr['source_country']; 154 + $arr = DB::table('gl_customer_visit_item')
  155 + ->select('url',DB::raw('COUNT(*) as num'))
  156 + ->groupBy('url')->where(['domain'=>'http://lxl.petuu.shop/'])
  157 + ->limit(15)->get()->toArray();
  158 + if(!empty($arr)){
  159 + $arr = json_encode($arr['source_country']);
  160 + }
  161 + return $arr;
164 } 162 }
165 163
166 /** 164 /**