作者 赵彬吉

update

@@ -3,7 +3,9 @@ @@ -3,7 +3,9 @@
3 namespace App\Console\Commands; 3 namespace App\Console\Commands;
4 4
5 use App\Helper\FormGlobalsoApi; 5 use App\Helper\FormGlobalsoApi;
  6 +use App\Models\Inquiry\InquiryOther;
6 use App\Models\Project\Project; 7 use App\Models\Project\Project;
  8 +use App\Services\ProjectServer;
7 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
8 10
9 /** 11 /**
@@ -51,13 +53,19 @@ class LastInquiry extends Command @@ -51,13 +53,19 @@ class LastInquiry extends Command
51 } 53 }
52 $api = new FormGlobalsoApi(); 54 $api = new FormGlobalsoApi();
53 $res = $api->getInquiryList($item['deploy_optimize']['domain']); 55 $res = $api->getInquiryList($item['deploy_optimize']['domain']);
54 - if($res && $res['status'] == 200){  
55 - if(empty($res['data']['data'][0])){ 56 + $last_time = $res['data']['data'][0] ?? '';
  57 + //其他询盘的最新时间
  58 + ProjectServer::useProject($item['id']);
  59 + $other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time');
  60 +
  61 + $last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
  62 +
  63 + if(!$last_inquiry_time){
56 continue; 64 continue;
57 } 65 }
58 - $item->last_inquiry_time = $res['data']['data'][0]['submit_time']; 66 +
  67 + $item->last_inquiry_time = $last_inquiry_time;
59 $item->save(); 68 $item->save();
60 } 69 }
61 } 70 }
62 - }  
63 } 71 }
@@ -6,7 +6,9 @@ use App\Helper\FormGlobalsoApi; @@ -6,7 +6,9 @@ use App\Helper\FormGlobalsoApi;
6 use App\Http\Logic\Bside\BaseLogic; 6 use App\Http\Logic\Bside\BaseLogic;
7 use App\Models\HomeCount\Count; 7 use App\Models\HomeCount\Count;
8 use App\Models\HomeCount\MonthCount; 8 use App\Models\HomeCount\MonthCount;
  9 +use App\Models\Inquiry\InquiryOther;
9 use App\Models\Project\DeployOptimize; 10 use App\Models\Project\DeployOptimize;
  11 +use App\Services\ProjectServer;
10 use Carbon\Carbon; 12 use Carbon\Carbon;
11 use Illuminate\Support\Facades\DB; 13 use Illuminate\Support\Facades\DB;
12 14
@@ -67,8 +69,8 @@ class MonthCountLogic extends BaseLogic @@ -67,8 +69,8 @@ class MonthCountLogic extends BaseLogic
67 //数据详情 69 //数据详情
68 $data = $inquiry_list['data']['data'] ?? ''; 70 $data = $inquiry_list['data']['data'] ?? '';
69 $arr['month_total'] = 0; 71 $arr['month_total'] = 0;
70 - if(isset($data) && !empty($data)){  
71 $countryArr = []; 72 $countryArr = [];
  73 + if(isset($data) && !empty($data)){
72 foreach ($data as $v){ 74 foreach ($data as $v){
73 if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){ 75 if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
74 $arr['month_total']++; 76 $arr['month_total']++;
@@ -76,14 +78,28 @@ class MonthCountLogic extends BaseLogic @@ -76,14 +78,28 @@ class MonthCountLogic extends BaseLogic
76 if(isset($countryArr[$v['country']])){ 78 if(isset($countryArr[$v['country']])){
77 $countryArr[$v['country']]++; 79 $countryArr[$v['country']]++;
78 }else{ 80 }else{
79 - $countryArr[$v['country']] = 0; 81 + $countryArr[$v['country']] = 1;
  82 + }
  83 + }
  84 + }
  85 + }
  86 + //加上其他询盘
  87 + ProjectServer::useProject($this->user['project_id']);
  88 + $arr['total'] += InquiryOther::count();
  89 + $arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
  90 + $countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
  91 + ->select("country",DB::raw('COUNT(*) as count'))
  92 + ->groupBy('country')->get()->toArray();
  93 + foreach ($countryData as $v1){
  94 + if(isset($countryArr[$v1['country']])){
  95 + $countryArr[$v1['country']] += $v1['count'];
  96 + }else{
  97 + $countryArr[$v1['country']] = $v1['count'];
80 } 98 }
81 } 99 }
82 arsort($countryArr); 100 arsort($countryArr);
83 $top20 = array_slice($countryArr, 0, 15, true); 101 $top20 = array_slice($countryArr, 0, 15, true);
84 $arr['country'] = $top20; 102 $arr['country'] = $top20;
85 - }  
86 - }  
87 return $arr; 103 return $arr;
88 } 104 }
89 105