作者 lyh
... ... @@ -3,7 +3,9 @@
namespace App\Console\Commands;
use App\Helper\FormGlobalsoApi;
use App\Models\Inquiry\InquiryOther;
use App\Models\Project\Project;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
/**
... ... @@ -51,13 +53,19 @@ class LastInquiry extends Command
}
$api = new FormGlobalsoApi();
$res = $api->getInquiryList($item['deploy_optimize']['domain']);
if($res && $res['status'] == 200){
if(empty($res['data']['data'][0])){
continue;
}
$item->last_inquiry_time = $res['data']['data'][0]['submit_time'];
$item->save();
$last_time = $res['data']['data'][0] ?? '';
//其他询盘的最新时间
ProjectServer::useProject($item['id']);
$other_last_time = InquiryOther::orderBy('id', 'desc')->value('submit_time');
$last_inquiry_time = $last_time > $other_last_time ? $last_time : $other_last_time;
if(!$last_inquiry_time){
continue;
}
$item->last_inquiry_time = $last_inquiry_time;
$item->save();
}
}
}
... ...
... ... @@ -6,7 +6,9 @@ use App\Helper\FormGlobalsoApi;
use App\Http\Logic\Bside\BaseLogic;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryOther;
use App\Models\Project\DeployOptimize;
use App\Services\ProjectServer;
use Carbon\Carbon;
use Illuminate\Support\Facades\DB;
... ... @@ -67,8 +69,8 @@ class MonthCountLogic extends BaseLogic
//数据详情
$data = $inquiry_list['data']['data'] ?? '';
$arr['month_total'] = 0;
$countryArr = [];
if(isset($data) && !empty($data)){
$countryArr = [];
foreach ($data as $v){
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
$arr['month_total']++;
... ... @@ -76,14 +78,28 @@ class MonthCountLogic extends BaseLogic
if(isset($countryArr[$v['country']])){
$countryArr[$v['country']]++;
}else{
$countryArr[$v['country']] = 0;
$countryArr[$v['country']] = 1;
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = $top20;
}
}
//加上其他询盘
ProjectServer::useProject($this->user['project_id']);
$arr['total'] += InquiryOther::count();
$arr['month_total'] += InquiryOther::whereBetween('submit_time',[$startTime, $endTime])->count();
$countryData = InquiryOther::whereBetween('submit_time',[$startTime, $endTime])
->select("country",DB::raw('COUNT(*) as count'))
->groupBy('country')->get()->toArray();
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
}else{
$countryArr[$v1['country']] = $v1['count'];
}
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = $top20;
return $arr;
}
... ...