作者 lyh

gx

@@ -52,139 +52,6 @@ class MonthCountLogic extends BaseLogic @@ -52,139 +52,6 @@ class MonthCountLogic extends BaseLogic
52 } 52 }
53 53
54 /** 54 /**
55 - * @remark :获取当前月数据统计  
56 - * @name :currentMonth  
57 - * @author :lyh  
58 - * @method :post  
59 - * @time :2023/7/3 9:55  
60 - */  
61 - public function currentMonthCount(){  
62 - $startTime = Carbon::now()->startOfMonth()->toDateString();  
63 - $endTime = date('Y-m-d',time());  
64 - $arr = [];  
65 - $arr = $this->inquiryCount($arr,$startTime,$endTime,$this->user['domain']);  
66 - $arr = $this->flowCount($arr,$startTime,$endTime,$this->user['project_id']);  
67 - $arr = $this->sourceCount($arr,$startTime,$endTime,$this->user['domain']);  
68 - $arr['month'] = date('Y-m',time());  
69 - return $this->success($arr);  
70 - }  
71 - /**  
72 - * @param $domain  
73 - * @param $project_id  
74 - * @remark :询盘按月统计  
75 - * @name :inquiryCount  
76 - * @author :lyh  
77 - * @method :post  
78 - * @time :2023/6/30 14:29  
79 - */  
80 - public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){  
81 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);  
82 - if(!empty($inquiry_list)){  
83 - //总数  
84 - $arr['total'] = $inquiry_list['data']['total'] ?? 0;  
85 - //数据详情  
86 - $data = $inquiry_list['data']['data'] ?? '';  
87 - $arr['month_total'] = 0;  
88 - $countryArr = [];  
89 - if(isset($data) && !empty($data)){  
90 - foreach ($data as $v){  
91 - if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){  
92 - $arr['month_total']++;  
93 - if(isset($countryArr[$v['country']])){  
94 - $countryArr[$v['country']]++;  
95 - }else{  
96 - $countryArr[$v['country']] = 1;  
97 - }  
98 - }  
99 - }  
100 - }  
101 - }  
102 - //加上其他询盘  
103 - $arr['total'] += InquiryFormData::getCount();  
104 - $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);  
105 - $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);  
106 - foreach ($countryData as $v1){  
107 - if(isset($countryArr[$v1['country']])){  
108 - $countryArr[$v1['country']] += $v1['count'];  
109 - }else{  
110 - $countryArr[$v1['country']] = $v1['count'];  
111 - }  
112 - }  
113 - arsort($countryArr);  
114 - $top20 = array_slice($countryArr, 0, 15, true);  
115 - $arr['country'] = $top20;  
116 - return $arr;  
117 - }  
118 -  
119 - /**  
120 - * @remark :流量统计  
121 - * @name :flowCount  
122 - * @author :lyh  
123 - * @method :post  
124 - * @time :2023/6/30 14:31  
125 - */  
126 - public function flowCount(&$arr,&$startTime,&$endTime,$project_id){  
127 - $pv_ip = DB::table('gl_count')  
128 - ->where(['project_id'=>$project_id])  
129 - ->whereBetween('date', [$startTime,$endTime])  
130 - ->select(DB::raw('SUM(pv_num) as pv_num'), DB::raw('SUM(ip_num) as ip_num'))  
131 - ->orderBy('id','desc')  
132 - ->first();  
133 - $arr['pv'] = $pv_ip->pv_num;  
134 - $arr['ip'] = $pv_ip->ip_num;  
135 - $arr['rate'] = 0;  
136 - if($arr['ip'] != 0){  
137 - $arr['rate'] = round(($arr['month_total'] / $arr['ip']) * 100,2);  
138 - }  
139 - return $arr;  
140 - }  
141 -  
142 - /**  
143 - * @remark :来源访问前8  
144 - * @name :sourceCount  
145 - * @author :lyh  
146 - * @method :post  
147 - * @time :2023/6/30 16:14  
148 - */  
149 - public function sourceCount(&$arr,$startTime,$endTime,$domain){  
150 - //访问来源前10  
151 - $source = DB::connection('custom_mysql')->table('gl_customer_visit')  
152 - ->select('referrer_url', DB::raw('COUNT(*) as count'))  
153 - ->groupBy('referrer_url')  
154 - ->where('referrer_url','!=','')  
155 - ->whereBetween('updated_date', [$startTime,$endTime])  
156 - ->orderByDesc('count')->limit(10)->get()->toArray();  
157 - $arr['source'] = $source ?? [];  
158 - //访问国家前15  
159 - $query = DB::connection('custom_mysql')->table('gl_customer_visit')  
160 - ->select('country',DB::raw('COUNT(*) as ip'),DB::raw('SUM(depth) as pv'))  
161 - ->groupBy('country');  
162 - if(isset($this->project['is_record_china_visit']) && ($this->project['is_record_china_visit'] == 0)){  
163 - $query->where('country','<>','中国');  
164 - }  
165 - $source_country = $query->whereBetween('updated_date', [$startTime,$endTime])  
166 - ->orderBy('ip','desc')->limit(15)->get()->toArray();  
167 - $arr['source_country'] = $source_country ?? [];  
168 - //受访界面前15  
169 - $referrer_url = DB::connection('custom_mysql')->table('gl_customer_visit')  
170 - ->select('url',DB::raw('COUNT(*) as num'))  
171 - ->orderBy('num','desc')  
172 - ->whereBetween('updated_date', [$startTime,$endTime])  
173 - ->groupBy('url')  
174 - ->limit(15)->get()->toArray();  
175 - $arr['referrer_url'] = $referrer_url ?? [];  
176 - //访问端口  
177 - $referrer_port = DB::connection('custom_mysql')->table('gl_customer_visit')  
178 - ->select('device_port',DB::raw('COUNT(*) as num'))  
179 - ->orderBy('num','desc')  
180 - ->whereBetween('updated_date', [$startTime,$endTime])  
181 - ->groupBy('device_port')  
182 - ->limit(15)->get()->toArray();  
183 - $arr['referrer_port'] = $referrer_port ?? [];  
184 - return $arr;  
185 - }  
186 -  
187 - /**  
188 * @remark :根据时间获取pv,ip 55 * @remark :根据时间获取pv,ip
189 * @name :getIpPvCount 56 * @name :getIpPvCount
190 * @author :lyh 57 * @author :lyh