作者 lyh

gx数据

@@ -63,7 +63,6 @@ class TemplateLog extends Command @@ -63,7 +63,6 @@ class TemplateLog extends Command
63 * @time :2024/7/10 14:48 63 * @time :2024/7/10 14:48
64 */ 64 */
65 public function deleteTemplate(){ 65 public function deleteTemplate(){
66 -  
67 $date = date('Y-m-d H:i:s', strtotime('-30 days')); 66 $date = date('Y-m-d H:i:s', strtotime('-30 days'));
68 $templateLogModel = new BTemplateLog(); 67 $templateLogModel = new BTemplateLog();
69 $templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]); 68 $templateLogModel->del(['created_at'=>['<=',$date],'source'=>['!=',1]]);
@@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController @@ -93,7 +93,7 @@ class OptimizationReportController extends BaseController
93 'data' => array_values($indexed_pages['data'] ?? []), 93 'data' => array_values($indexed_pages['data'] ?? []),
94 ]; 94 ];
95 //月统计报告 95 //月统计报告
96 - $data['month_count'] = $this->currentMonthCount($domain_info['domain'],$this->param['project_id']); 96 + $data['month_count'] = $this->currentMonthCount($this->param['project_id']);
97 //测速 97 //测速
98 $speed = Speed::where('project_id', $this->param['project_id'])->first(); 98 $speed = Speed::where('project_id', $this->param['project_id'])->first();
99 $data['speed'] = $speed['data'] ?? []; 99 $data['speed'] = $speed['data'] ?? [];
@@ -110,60 +110,27 @@ class OptimizationReportController extends BaseController @@ -110,60 +110,27 @@ class OptimizationReportController extends BaseController
110 * @method :post 110 * @method :post
111 * @time :2023/7/3 9:55 111 * @time :2023/7/3 9:55
112 */ 112 */
113 - public function currentMonthCount($domain,$project_id){ 113 + public function currentMonthCount($project_id){
114 // 获取当前月的开始时间 114 // 获取当前月的开始时间
115 $startTime = date('Y-m-01', strtotime($this->param['date'])); 115 $startTime = date('Y-m-01', strtotime($this->param['date']));
116 // 获取当前月的结束时间 116 // 获取当前月的结束时间
117 $endTime = date('Y-m-t', strtotime($this->param['date'])); 117 $endTime = date('Y-m-t', strtotime($this->param['date']));
118 $arr = []; 118 $arr = [];
119 - $arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);  
120 - $arr = $this->flowCount($arr,$startTime,$endTime,$project_id);  
121 - $arr = $this->sourceCount($arr,$startTime,$endTime,$domain);  
122 - $arr['month'] = date('Y-m',time());  
123 - return $arr;  
124 - }  
125 -  
126 - /**  
127 - * @param $domain  
128 - * @param $project_id  
129 - * @remark :询盘按月统计  
130 - * @name :inquiryCount  
131 - * @author :lyh  
132 - * @method :post  
133 - * @time :2023/6/30 14:29  
134 - */  
135 - public function inquiryCount(&$arr, &$startTime, $project_id){  
136 - $month = date('Y-m',strtotime($startTime));  
137 $monthCountModel = new MonthCount(); 119 $monthCountModel = new MonthCount();
138 - $info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]);  
139 - if($info !== false){  
140 - $arr['country'] = $info['country'];  
141 - $arr['total'] = $info['total'];  
142 - $arr['month_total'] = $info['month_total'];  
143 - }  
144 - return $arr;  
145 - }  
146 -  
147 - /**  
148 - * @remark :流量统计  
149 - * @name :flowCount  
150 - * @author :lyh  
151 - * @method :post  
152 - * @time :2023/6/30 14:31  
153 - */  
154 - public function flowCount(&$arr,&$startTime,&$endTime,$project_id){  
155 - $pv_ip = DB::table('gl_count')  
156 - ->where(['project_id'=>$project_id])  
157 - ->whereBetween('date', [$startTime,$endTime])  
158 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
159 - ->orderBy('id','desc')  
160 - ->first();  
161 - $arr['pv'] = $pv_ip->pv_num;  
162 - $arr['ip'] = $pv_ip->ip_num;  
163 - $arr['rate'] = 0;  
164 - if($arr['ip'] != 0){  
165 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2); 120 + $month_info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$this->param['date']]);
  121 + if($month_info !== false){
  122 + $arr['country'] = $month_info['country'];
  123 + $arr['total'] = $month_info['total'];
  124 + $arr['month_total'] = $month_info['month_total'];
  125 + $arr['pv'] = $month_info['pv'];
  126 + $arr['ip'] = $month_info['ip'];
  127 + $arr['rate'] = 0;
  128 + if($arr['ip'] != 0){
  129 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
  130 + }
166 } 131 }
  132 + $arr = $this->sourceCount($arr,$startTime,$endTime);
  133 + $arr['month'] = date('Y-m',time());
167 return $arr; 134 return $arr;
168 } 135 }
169 136
@@ -174,7 +141,7 @@ class OptimizationReportController extends BaseController @@ -174,7 +141,7 @@ class OptimizationReportController extends BaseController
174 * @method :post 141 * @method :post
175 * @time :2023/6/30 16:14 142 * @time :2023/6/30 16:14
176 */ 143 */
177 - public function sourceCount(&$arr,$startTime,$endTime,$domain){ 144 + public function sourceCount(&$arr,$startTime,$endTime){
178 //访问来源前10 145 //访问来源前10
179 $source = DB::connection('custom_mysql')->table('gl_customer_visit') 146 $source = DB::connection('custom_mysql')->table('gl_customer_visit')
180 ->select('referrer_url', DB::raw('COUNT(*) as count')) 147 ->select('referrer_url', DB::raw('COUNT(*) as count'))
@@ -88,7 +88,6 @@ class MonthReportController extends BaseController @@ -88,7 +88,6 @@ class MonthReportController extends BaseController
88 ])->count(); 88 ])->count();
89 $info['service_duration'] = $this->user['service_duration'];//服务天数 89 $info['service_duration'] = $this->user['service_duration'];//服务天数
90 $info['ip_total'] = (new Visit())->count();//ip总数 90 $info['ip_total'] = (new Visit())->count();//ip总数
91 -  
92 $info['remain_day'] = $this->user['remain_day'];//剩余服务天数 91 $info['remain_day'] = $this->user['remain_day'];//剩余服务天数
93 $info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2); 92 $info['speed'] = round((0.3 + mt_rand()/mt_getrandmax() * (1-0.3)),2);
94 $info['month_total'] = (int)$info['month_total']; 93 $info['month_total'] = (int)$info['month_total'];