作者 lyh

gx

@@ -81,16 +81,10 @@ class InquiryMonthlyCount extends Command @@ -81,16 +81,10 @@ class InquiryMonthlyCount extends Command
81 arsort($countryArr); 81 arsort($countryArr);
82 $top20 = array_slice($countryArr, 0, 15, true); 82 $top20 = array_slice($countryArr, 0, 15, true);
83 $arr['country'] = json_encode($top20); 83 $arr['country'] = json_encode($top20);
  84 + $this->flowCount($arr,$startTime,$endTime,$project_id);
84 $arr['created_at'] = date('Y-m-d H:i:s'); 85 $arr['created_at'] = date('Y-m-d H:i:s');
85 $arr['updated_at'] = date('Y-m-d H:i:s'); 86 $arr['updated_at'] = date('Y-m-d H:i:s');
86 $arr['project_id'] = $project_id; 87 $arr['project_id'] = $project_id;
87 - $pv_ip = DB::table('gl_count')  
88 - ->where(['project_id'=>1])  
89 - ->where('date','>=',$startTime->toDateString().' 00:00:00')  
90 - ->where('date','<=',$endTime->toDateString().' 23:59:59')  
91 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
92 - ->get();  
93 -  
94 DB::table('gl_inquiry_month_count')->insert($arr); 88 DB::table('gl_inquiry_month_count')->insert($arr);
95 } 89 }
96 90
@@ -101,11 +95,35 @@ class InquiryMonthlyCount extends Command @@ -101,11 +95,35 @@ class InquiryMonthlyCount extends Command
101 * @method :post 95 * @method :post
102 * @time :2023/6/30 14:31 96 * @time :2023/6/30 14:31
103 */ 97 */
104 - public function flowCount($startTime,$endTime,$project_id){  
105 - DB::table('gl_count') 98 + public function flowCount(&$arr,$startTime,$endTime,$project_id){
  99 + $pv_ip = DB::table('gl_count')
106 ->where(['project_id'=>$project_id]) 100 ->where(['project_id'=>$project_id])
107 - ->where('date','>=',$startTime.' 00:00:00')  
108 - ->where('date','<=',$endTime.' 23:59:59')  
109 - ->sum('pv_num'); 101 + ->where('date','>=',$startTime->toDateString().' 00:00:00')
  102 + ->where('date','<=',$endTime->toDateString().' 23:59:59')
  103 + ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))
  104 + ->first();
  105 + $arr['pv'] = $pv_ip['pv_num'];
  106 + $arr['ip'] = $pv_ip['ip_num'];
  107 + if($arr['ip'] != 0){
  108 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 10,2);
  109 + }
  110 + return $arr;
  111 + }
  112 +
  113 + /**
  114 + * @remark :访问前8
  115 + * @name :sourceCount
  116 + * @author :lyh
  117 + * @method :post
  118 + * @time :2023/6/30 16:14
  119 + */
  120 + public function sourceCount(&$arr,$domain){
  121 + $data = DB::table('gl_customer_visit')
  122 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  123 + ->groupBy('referrer_url')->where(['domain'=>$domain])
  124 + ->orderByDesc('count')->limit(8)->get()->toArray();
  125 + if(!empty($data)){
  126 + $arr['source'] = json_encode($data);
  127 + }
110 } 128 }
111 } 129 }
@@ -147,19 +147,11 @@ class ComController extends BaseController @@ -147,19 +147,11 @@ class ComController extends BaseController
147 } 147 }
148 148
149 public function ceshi(){ 149 public function ceshi(){
150 -  
151 - $startTime = Carbon::now()->subMonth(1)->startOfMonth();  
152 - // 获取上个月的结束时间  
153 - $endTime = Carbon::now()->subMonth(1)->endOfMonth();  
154 - $pv = DB::table('gl_count')  
155 - ->where(['project_id'=>1])  
156 - ->where('date','>=',$startTime->toDateString().' 00:00:00')  
157 - ->where('date','<=',$endTime->toDateString().' 23:59:59')  
158 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
159 - ->first();  
160 - var_dump($pv);  
161 - die();  
162 - $this->response('success',Code::SUCCESS,$pv); 150 + $data = DB::table('gl_customer_visit')
  151 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  152 + ->groupBy('referrer_url')->where(['domain'=>'http://lxl.petuu.shop/'])
  153 + ->orderByDesc('count')->limit(8)->get()->toArray();
  154 + return $data;
163 } 155 }
164 156
165 /** 157 /**
@@ -130,7 +130,8 @@ class CountLogic extends BaseLogic @@ -130,7 +130,8 @@ class CountLogic extends BaseLogic
130 */ 130 */
131 public function referrer_count(){ 131 public function referrer_count(){
132 $data = DB::table('gl_customer_visit') 132 $data = DB::table('gl_customer_visit')
133 - ->select('referrer_url', DB::raw('COUNT(*) as count'))->groupBy('referrer_url') 133 + ->select('referrer_url', DB::raw('COUNT(*) as count'))
  134 + ->groupBy('referrer_url')->where(['domain'=>$this->project['deploy_build']['test_domain']])
134 ->orderByDesc('count')->limit(8)->get()->toArray(); 135 ->orderByDesc('count')->limit(8)->get()->toArray();
135 $total = DB::table('gl_customer_visit')->count(); 136 $total = DB::table('gl_customer_visit')->count();
136 if(!empty($data)){ 137 if(!empty($data)){
@@ -151,7 +152,8 @@ class CountLogic extends BaseLogic @@ -151,7 +152,8 @@ class CountLogic extends BaseLogic
151 public function access_country_count(){ 152 public function access_country_count(){
152 $data = DB::table('gl_customer_visit') 153 $data = DB::table('gl_customer_visit')
153 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv')) 154 ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
154 - ->groupBy('country')->orderBy('ip','desc')->limit(20)->get()->toArray(); 155 + ->groupBy('country')->where(['domain'=>$this->project['deploy_build']['test_domain']])
  156 + ->orderBy('ip','desc')->limit(20)->get()->toArray();
155 if(!empty($data)){ 157 if(!empty($data)){
156 $data = object_to_array($data); 158 $data = object_to_array($data);
157 foreach ($data as $k => $v){ 159 foreach ($data as $k => $v){