作者 lyh

gx

@@ -76,22 +76,25 @@ class InquiryMonthlyCount extends Command @@ -76,22 +76,25 @@ class InquiryMonthlyCount extends Command
76 //总数 76 //总数
77 $arr['total'] = $inquiry_list['data']['total'] ?? 0; 77 $arr['total'] = $inquiry_list['data']['total'] ?? 0;
78 //数据详情 78 //数据详情
79 - $data = $inquiry_list['data']['data']; 79 + $data = $inquiry_list['data']['data'] ?? 0;
80 $arr['month_total'] = 0; 80 $arr['month_total'] = 0;
81 $countryArr = []; 81 $countryArr = [];
82 - foreach ($data as $v){  
83 - if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){  
84 - $arr['month_total']++;  
85 - }  
86 - if(isset($countryArr[$v['country']])){  
87 - $countryArr[$v['country']]++;  
88 - }else{  
89 - $countryArr[$v['country']] = 0; 82 + $arr['count'] = "";
  83 + if(!empty($data)){
  84 + foreach ($data as $v){
  85 + if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
  86 + $arr['month_total']++;
  87 + }
  88 + if(isset($countryArr[$v['country']])){
  89 + $countryArr[$v['country']]++;
  90 + }else{
  91 + $countryArr[$v['country']] = 0;
  92 + }
90 } 93 }
  94 + arsort($countryArr);
  95 + $top20 = array_slice($countryArr, 0, 15, true);
  96 + $arr['country'] = json_encode($top20);
91 } 97 }
92 - arsort($countryArr);  
93 - $top20 = array_slice($countryArr, 0, 15, true);  
94 - $arr['country'] = json_encode($top20);  
95 return $arr; 98 return $arr;
96 } 99 }
97 100