作者 lyh

gx脚本demo

@@ -135,7 +135,7 @@ class Count extends Command @@ -135,7 +135,7 @@ class Count extends Command
135 * @time :2023/6/14 15:44 135 * @time :2023/6/14 15:44
136 */ 136 */
137 public function inquiry($arr,$domain,$project_id){ 137 public function inquiry($arr,$domain,$project_id){
138 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 138 + $inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
139 if($inquiry_list == false){ 139 if($inquiry_list == false){
140 return false; 140 return false;
141 } 141 }
@@ -143,17 +143,9 @@ class Count extends Command @@ -143,17 +143,9 @@ class Count extends Command
143 $arr['inquiry_num'] = 0; 143 $arr['inquiry_num'] = 0;
144 $countryArr = []; 144 $countryArr = [];
145 }else{ 145 }else{
146 - $arr['inquiry_num'] = $inquiry_list['data']['total']; 146 + $arr['inquiry_num'] = $inquiry_list['data']['count'];
147 //询盘国家统计 147 //询盘国家统计
148 - $countryData = $inquiry_list['data']['data'];  
149 - $countryArr = [];  
150 - foreach ($countryData as $v1){  
151 - if(isset($countryArr[$v1['country']])){  
152 - $countryArr[$v1['country']]++;  
153 - }else{  
154 - $countryArr[$v1['country']] = 1;  
155 - }  
156 - } 148 + $countryArr = $inquiry_list['data']['country'];
157 } 149 }
158 //加上其他询盘 150 //加上其他询盘
159 ProjectServer::useProject($project_id); 151 ProjectServer::useProject($project_id);
@@ -102,7 +102,7 @@ class CountAll extends Command @@ -102,7 +102,7 @@ class CountAll extends Command
102 * @time :2023/6/14 15:44 102 * @time :2023/6/14 15:44
103 */ 103 */
104 public function inquiry($arr,$domain,$project_id){ 104 public function inquiry($arr,$domain,$project_id){
105 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 105 + $inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
106 if($inquiry_list == false){ 106 if($inquiry_list == false){
107 return false; 107 return false;
108 } 108 }
@@ -110,17 +110,9 @@ class CountAll extends Command @@ -110,17 +110,9 @@ class CountAll extends Command
110 $arr['inquiry_num'] = 0; 110 $arr['inquiry_num'] = 0;
111 $countryArr = []; 111 $countryArr = [];
112 }else{ 112 }else{
113 - $arr['inquiry_num'] = $inquiry_list['data']['total']; 113 + $arr['inquiry_num'] = $inquiry_list['data']['count'];
114 //询盘国家统计 114 //询盘国家统计
115 - $countryData = $inquiry_list['data']['data'];  
116 - $countryArr = [];  
117 - foreach ($countryData as $v1){  
118 - if(isset($countryArr[$v1['country']])){  
119 - $countryArr[$v1['country']]++;  
120 - }else{  
121 - $countryArr[$v1['country']] = 1;  
122 - }  
123 - } 115 + $countryArr = $inquiry_list['data']['country'];
124 } 116 }
125 //加上其他询盘 117 //加上其他询盘
126 ProjectServer::useProject($project_id); 118 ProjectServer::useProject($project_id);
@@ -145,7 +145,7 @@ class CountProject extends Command @@ -145,7 +145,7 @@ class CountProject extends Command
145 * @time :2023/6/14 15:44 145 * @time :2023/6/14 15:44
146 */ 146 */
147 public function inquiry($arr,$domain,$project_id){ 147 public function inquiry($arr,$domain,$project_id){
148 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 148 + $inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
149 if($inquiry_list == false){ 149 if($inquiry_list == false){
150 return false; 150 return false;
151 } 151 }
@@ -154,17 +154,9 @@ class CountProject extends Command @@ -154,17 +154,9 @@ class CountProject extends Command
154 $arr['inquiry_num'] = 0; 154 $arr['inquiry_num'] = 0;
155 $countryArr = []; 155 $countryArr = [];
156 }else{ 156 }else{
157 - $arr['inquiry_num'] = $inquiry_list['data']['total']; 157 + $arr['inquiry_num'] = $inquiry_list['data']['count'];
158 //询盘国家统计 158 //询盘国家统计
159 - $countryData = $inquiry_list['data']['data'];  
160 - $countryArr = [];  
161 - foreach ($countryData as $v1){  
162 - if(isset($countryArr[$v1['country']])){  
163 - $countryArr[$v1['country']]++;  
164 - }else{  
165 - $countryArr[$v1['country']] = 1;  
166 - }  
167 - } 159 + $countryArr = $inquiry_list['data']['country'];
168 } 160 }
169 //加上其他询盘 161 //加上其他询盘
170 ProjectServer::useProject($project_id); 162 ProjectServer::useProject($project_id);
@@ -150,24 +150,15 @@ class Test extends Command @@ -150,24 +150,15 @@ class Test extends Command
150 } 150 }
151 151
152 public function inquiry($arr,$domain,$project_id){ 152 public function inquiry($arr,$domain,$project_id){
153 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 153 + $inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
154 if($inquiry_list['status'] == 400){ 154 if($inquiry_list['status'] == 400){
155 $arr['inquiry_num'] = 0; 155 $arr['inquiry_num'] = 0;
156 $countryArr = []; 156 $countryArr = [];
157 }else{ 157 }else{
158 - $arr['inquiry_num'] = $inquiry_list['data']['total']; 158 + $arr['inquiry_num'] = $inquiry_list['data']['count'];
159 //询盘国家统计 159 //询盘国家统计
160 - $countryData = $inquiry_list['data']['data'];  
161 - $countryArr = [];  
162 - foreach ($countryData as $v1){  
163 - if(isset($countryArr[$v1['country']])){  
164 - $countryArr[$v1['country']]++;  
165 - }else{  
166 - $countryArr[$v1['country']] = 1;  
167 - }  
168 - } 160 + $countryArr = $inquiry_list['data']['country'];
169 } 161 }
170 -  
171 //加上其他询盘 162 //加上其他询盘
172 $arr['inquiry_num'] += InquiryFormData::getCount(); 163 $arr['inquiry_num'] += InquiryFormData::getCount();
173 $countryData = InquiryFormData::getCountryCount(); 164 $countryData = InquiryFormData::getCountryCount();
@@ -162,10 +162,15 @@ class FormGlobalsoApi @@ -162,10 +162,15 @@ class FormGlobalsoApi
162 * @method :post 162 * @method :post
163 * @time :2024/8/15 14:16 163 * @time :2024/8/15 14:16
164 */ 164 */
165 - public function getInquiryAll($domain){  
166 - $domain = 'https://'.$domain.'/'; 165 + public function getInquiryAll($domain,$start_month = ''){
  166 + if (!(strpos($domain, 'https://') === 0)) {
  167 + $domain = 'https://'.$domain.'/';
  168 + }
167 $token = md5($domain.date("Y-m-d")); 169 $token = md5($domain.date("Y-m-d"));
168 $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15"; 170 $url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
  171 + if(!empty($start) && !empty($end)){
  172 + $url = $url."&sta_date=$start_month";
  173 + }
169 try { 174 try {
170 $res = http_get($url,['charset=utf-8']); 175 $res = http_get($url,['charset=utf-8']);
171 } catch (\Exception | GuzzleException $e) { 176 } catch (\Exception | GuzzleException $e) {
@@ -927,3 +927,5 @@ function base62_encode($num) { @@ -927,3 +927,5 @@ function base62_encode($num) {
927 } 927 }
928 928
929 929
  930 +
  931 +
@@ -14,6 +14,7 @@ use App\Helper\Arr; @@ -14,6 +14,7 @@ use App\Helper\Arr;
14 use App\Helper\FormGlobalsoApi; 14 use App\Helper\FormGlobalsoApi;
15 use App\Models\Domain\DomainInfo; 15 use App\Models\Domain\DomainInfo;
16 use App\Models\HomeCount\Count; 16 use App\Models\HomeCount\Count;
  17 +use App\Models\HomeCount\MonthCount;
17 use App\Models\Inquiry\InquiryFormData; 18 use App\Models\Inquiry\InquiryFormData;
18 use App\Models\Project\Project; 19 use App\Models\Project\Project;
19 use App\Models\RankData\ExternalLinks; 20 use App\Models\RankData\ExternalLinks;
@@ -115,7 +116,7 @@ class OptimizationReportController extends BaseController @@ -115,7 +116,7 @@ class OptimizationReportController extends BaseController
115 // 获取当前月的结束时间 116 // 获取当前月的结束时间
116 $endTime = date('Y-m-t', strtotime($this->param['date'])); 117 $endTime = date('Y-m-t', strtotime($this->param['date']));
117 $arr = []; 118 $arr = [];
118 - $arr = $this->inquiryCount($arr,$startTime,$endTime,$domain); 119 + $arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);
119 $arr = $this->flowCount($arr,$startTime,$endTime,$project_id); 120 $arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
120 $arr = $this->sourceCount($arr,$startTime,$endTime,$domain); 121 $arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
121 $arr['month'] = date('Y-m',time()); 122 $arr['month'] = date('Y-m',time());
@@ -131,42 +132,15 @@ class OptimizationReportController extends BaseController @@ -131,42 +132,15 @@ class OptimizationReportController extends BaseController
131 * @method :post 132 * @method :post
132 * @time :2023/6/30 14:29 133 * @time :2023/6/30 14:29
133 */ 134 */
134 - public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){  
135 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);  
136 - if(!empty($inquiry_list)){  
137 - //总数  
138 - $arr['total'] = $inquiry_list['data']['total'] ?? 0;  
139 - //数据详情  
140 - $data = $inquiry_list['data']['data'] ?? '';  
141 - $arr['month_total'] = 0;  
142 - $countryArr = [];  
143 - if(isset($data) && !empty($data)){  
144 - foreach ($data as $v){  
145 - if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){  
146 - $arr['month_total']++;  
147 - if(isset($countryArr[$v['country']])){  
148 - $countryArr[$v['country']]++;  
149 - }else{  
150 - $countryArr[$v['country']] = 1;  
151 - }  
152 - }  
153 - }  
154 - }  
155 - }  
156 - //加上其他询盘  
157 - $arr['total'] += InquiryFormData::getCount();  
158 - $arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);  
159 - $countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);  
160 - foreach ($countryData as $v1){  
161 - if(isset($countryArr[$v1['country']])){  
162 - $countryArr[$v1['country']] += $v1['count'];  
163 - }else{  
164 - $countryArr[$v1['country']] = $v1['count'];  
165 - } 135 + public function inquiryCount(&$arr, &$startTime, $project_id){
  136 + $month = date('Y-m',strtotime($startTime));
  137 + $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'];
166 } 143 }
167 - arsort($countryArr);  
168 - $top20 = array_slice($countryArr, 0, 15, true);  
169 - $arr['country'] = $top20;  
170 return $arr; 144 return $arr;
171 } 145 }
172 146
@@ -350,9 +324,9 @@ class OptimizationReportController extends BaseController @@ -350,9 +324,9 @@ class OptimizationReportController extends BaseController
350 public function pv_ip($domain){ 324 public function pv_ip($domain){
351 $pv = (new VisitItem())->count(); 325 $pv = (new VisitItem())->count();
352 $ip = (new Visit())->count(); 326 $ip = (new Visit())->count();
353 - $inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000); 327 + $inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
354 if(!empty($inquiry_list)){ 328 if(!empty($inquiry_list)){
355 - $total = $inquiry_list['data']['total'] ?? 0; 329 + $total = $inquiry_list['data']['count'] ?? 0;
356 } 330 }
357 return [ 331 return [
358 'total_pv'=>$pv, 332 'total_pv'=>$pv,