|
...
|
...
|
@@ -4,6 +4,7 @@ namespace App\Console\Commands\MonthlyCount; |
|
|
|
|
|
|
|
use App\Helper\FormGlobalsoApi;
|
|
|
|
use App\Models\Domain\DomainInfo;
|
|
|
|
use App\Models\Inquiry\InquiryOther;
|
|
|
|
use App\Models\Project\Project;
|
|
|
|
use App\Services\ProjectServer;
|
|
|
|
use Carbon\Carbon;
|
|
...
|
...
|
@@ -54,12 +55,12 @@ class InquiryMonthlyCount extends Command |
|
|
|
if(!empty($value['domain'])){
|
|
|
|
$info = $domainInfo->read(['id'=>$value['domain']]);
|
|
|
|
if($info !== false){
|
|
|
|
$value['test_domain'] = $value['domain'];
|
|
|
|
$value['test_domain'] = $info['domain'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$arr = [];
|
|
|
|
//按月统计询盘记录
|
|
|
|
$arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain']);
|
|
|
|
$arr = $this->inquiryCount($arr,$startTime,$endTime,$value['test_domain'],$value['project_id']);
|
|
|
|
$arr = $this->flowCount($arr,$startTime,$endTime,$value['project_id']);
|
|
|
|
ProjectServer::useProject($value['project_id']);
|
|
|
|
$arr = $this->sourceCount($arr,$value['test_domain'],$startTime,$endTime);
|
|
...
|
...
|
@@ -83,7 +84,7 @@ class InquiryMonthlyCount extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2023/6/30 14:29
|
|
|
|
*/
|
|
|
|
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
|
|
|
|
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain,$project_id){
|
|
|
|
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
|
|
|
|
//总数
|
|
|
|
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
|
|
...
|
...
|
@@ -96,17 +97,32 @@ class InquiryMonthlyCount extends Command |
|
|
|
foreach ($data as $v){
|
|
|
|
if(($startTime.' 00:00:00' <= $v['submit_time']) && $v['submit_time'] <= $endTime.' 23:59:59'){
|
|
|
|
$arr['month_total']++;
|
|
|
|
}
|
|
|
|
if(isset($countryArr[$v['country']])){
|
|
|
|
$countryArr[$v['country']]++;
|
|
|
|
}else{
|
|
|
|
$countryArr[$v['country']] = 0;
|
|
|
|
$countryArr[$v['country']] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//加上其他询盘
|
|
|
|
ProjectServer::useProject($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'] = json_encode($top20);
|
|
|
|
}
|
|
|
|
return $arr;
|
|
|
|
}
|
|
|
|
|
...
|
...
|
|