|
@@ -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,108 +110,31 @@ class OptimizationReportController extends BaseController |
|
@@ -110,108 +110,31 @@ 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){
|
|
|
|
114
|
- // 获取当前月的开始时间
|
|
|
|
115
|
- $startTime = date('Y-m-01', strtotime($this->param['date']));
|
|
|
|
116
|
- // 获取当前月的结束时间
|
|
|
|
117
|
- $endTime = date('Y-m-t', strtotime($this->param['date']));
|
113
|
+ public function currentMonthCount($project_id){
|
|
118
|
$arr = [];
|
114
|
$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));
|
115
|
+ $date = date('Y-m', strtotime($this->param['date']));
|
|
137
|
$monthCountModel = new MonthCount();
|
116
|
$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;
|
117
|
+ $month_info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$date]);
|
|
|
|
118
|
+ if($month_info !== false){
|
|
|
|
119
|
+ $arr['country'] = $month_info['country'];
|
|
|
|
120
|
+ $arr['total'] = $month_info['total'];
|
|
|
|
121
|
+ $arr['month_total'] = $month_info['month_total'];
|
|
|
|
122
|
+ $arr['pv'] = $month_info['pv'];
|
|
|
|
123
|
+ $arr['ip'] = $month_info['ip'];
|
|
163
|
$arr['rate'] = 0;
|
124
|
$arr['rate'] = 0;
|
|
164
|
if($arr['ip'] != 0){
|
125
|
if($arr['ip'] != 0){
|
|
165
|
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
|
126
|
$arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
|
|
166
|
}
|
127
|
}
|
|
167
|
- return $arr;
|
128
|
+ $arr['source'] = json_decode($month_info['source'],true);
|
|
|
|
129
|
+ $arr['source_country'] = json_decode($month_info['source_country'],true);
|
|
|
|
130
|
+ $arr['referrer_url'] = json_decode($month_info['referrer_url'],true);
|
|
|
|
131
|
+ $arr['referrer_port'] = json_decode($month_info['referrer_port'],true);
|
|
168
|
}
|
132
|
}
|
|
169
|
-
|
|
|
|
170
|
- /**
|
|
|
|
171
|
- * @remark :来源访问前8
|
|
|
|
172
|
- * @name :sourceCount
|
|
|
|
173
|
- * @author :lyh
|
|
|
|
174
|
- * @method :post
|
|
|
|
175
|
- * @time :2023/6/30 16:14
|
|
|
|
176
|
- */
|
|
|
|
177
|
- public function sourceCount(&$arr,$startTime,$endTime,$domain){
|
|
|
|
178
|
- //访问来源前10
|
|
|
|
179
|
- $source = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
180
|
- ->select('referrer_url', DB::raw('COUNT(*) as count'))
|
|
|
|
181
|
- ->groupBy('referrer_url')
|
|
|
|
182
|
- ->where('referrer_url','!=','')
|
|
|
|
183
|
- ->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
184
|
- ->orderByDesc('count')->limit(10)->get()->toArray();
|
|
|
|
185
|
- $arr['source'] = $source;
|
|
|
|
186
|
- //访问国家前15
|
|
|
|
187
|
- $query = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
188
|
- ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))
|
|
|
|
189
|
- ->groupBy('country');
|
|
|
|
190
|
-
|
|
|
|
191
|
- $query->where('country','<>','中国');
|
|
|
|
192
|
-
|
|
|
|
193
|
- $source_country = $query->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
194
|
- ->orderBy('ip','desc')->limit(15)->get()->toArray();
|
|
|
|
195
|
- $arr['source_country'] = $source_country;
|
|
|
|
196
|
- //受访界面前15
|
|
|
|
197
|
- $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
198
|
- ->select('url',DB::raw('COUNT(*) as num'))
|
|
|
|
199
|
- ->orderBy('num','desc')
|
|
|
|
200
|
- ->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
201
|
- ->groupBy('url')
|
|
|
|
202
|
- ->limit(15)->get()->toArray();
|
|
|
|
203
|
- $arr['referrer_url'] = $referrer_url;
|
|
|
|
204
|
- //访问断后
|
|
|
|
205
|
- $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')
|
|
|
|
206
|
- ->select('device_port',DB::raw('COUNT(*) as num'))
|
|
|
|
207
|
- ->orderBy('num','desc')
|
|
|
|
208
|
- ->whereBetween('updated_date', [$startTime,$endTime])
|
|
|
|
209
|
- ->groupBy('device_port')
|
|
|
|
210
|
- ->limit(15)->get()->toArray();
|
|
|
|
211
|
- $arr['referrer_port'] = $referrer_port;
|
133
|
+ $arr['month'] = date('Y-m',time());
|
|
212
|
return $arr;
|
134
|
return $arr;
|
|
213
|
}
|
135
|
}
|
|
214
|
|
136
|
|
|
|
|
137
|
+
|
|
215
|
public function getApiList($projectInfo,$export = false)
|
138
|
public function getApiList($projectInfo,$export = false)
|
|
216
|
{
|
139
|
{
|
|
217
|
$this->form_globalso_api = new FormGlobalsoApi();
|
140
|
$this->form_globalso_api = new FormGlobalsoApi();
|