作者 刘锟

Merge remote-tracking branch 'origin/master' into akun

@@ -63,13 +63,18 @@ class TemplateLog extends Command @@ -63,13 +63,18 @@ 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('-60 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]]);
70 - //首页保存最新的20条记录  
71 - $latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段  
72 - return $templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]); 69 + //查询最近20天是否有装修记录,首页保存最新的20条记录
  70 + $counts = $templateLogModel->counts(['source'=>1,'source_id'=>0,'is_custom'=>0,'created_at'=>['>=',$date]]);
  71 + if($counts == 0){
  72 + $latestIds = $templateLogModel->where(['source'=>1,'is_custom'=>0])->orderBy('created_at', 'desc')->take(20)->pluck('id'); // 仅提取ID字段
  73 + $templateLogModel->del(['id'=>['not in',$latestIds],'source'=>1,'is_custom'=>0,'is_list'=>0]);
  74 + }else{
  75 + $templateLogModel->del(['created_at'=>['<=',$date],'source'=>1]);
  76 + }
  77 + return true;
73 } 78 }
74 79
75 /** 80 /**
@@ -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,107 +110,30 @@ class OptimizationReportController extends BaseController @@ -110,107 +110,30 @@ 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;  
163 - $arr['rate'] = 0;  
164 - if($arr['ip'] != 0){  
165 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2); 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'];
  124 + $arr['rate'] = 0;
  125 + if($arr['ip'] != 0){
  126 + $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);
  127 + }
  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);
166 } 132 }
  133 + $arr['month'] = date('Y-m',time());
167 return $arr; 134 return $arr;
168 } 135 }
169 136
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;  
212 - return $arr;  
213 - }  
214 137
215 public function getApiList($projectInfo,$export = false) 138 public function getApiList($projectInfo,$export = false)
216 { 139 {
@@ -72,6 +72,7 @@ class CNoticeController extends BaseController @@ -72,6 +72,7 @@ class CNoticeController extends BaseController
72 if($number >= 450000){ 72 if($number >= 450000){
73 $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']); 73 $this->response('success',Code::SUCCESS,['msg'=>'翻译数量过多, 大概页面数量:'.$number.', 磁盘空间占用可能会超过40G,请联系管理员操作!']);
74 } 74 }
  75 + //? Copyright - 2010-2024 : All Rights Reserved.© Copyright - 2010-2024 : All Rights Reserved.
75 $this->response('success'); 76 $this->response('success');
76 } 77 }
77 78
@@ -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'];