作者 lyh

gx

... ... @@ -3,8 +3,10 @@
namespace App\Console\Commands\MonthlyCount;
use App\Helper\FormGlobalsoApi;
use App\Models\Project\DeployBuild;
use Carbon\Carbon;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class InquiryMonthlyCount extends Command
{
... ... @@ -32,40 +34,71 @@ class InquiryMonthlyCount extends Command
* @time :2023/6/30 9:32
*/
public function handle(){
//统计数据
$arr = [];
$deployModel = new DeployBuild();
$list = $deployModel->list();
// 获取上个月的开始时间
$startTime = Carbon::now()->subMonth()->startOfMonth();
// 获取上个月的结束时间
$endTime = Carbon::now()->subMonth()->endOfMonth();
foreach ($list as $value){
//按月统计询盘记录
$this->inquiryCount($startTime,$endTime,$value['test_domain'],$value['project_id']);
}
}
/**
* @param $arr
* @param $domain
* @name :(询盘统计)inquiry
* @param $project_id
* @remark :询盘按月统计
* @name :inquiryCount
* @author :lyh
* @method :post
* @time :2023/6/14 15:44
* @time :2023/6/30 14:29
*/
public function inquiry($arr,$domain){
public function inquiryCount($startTime,$endTime,$domain,$project_id){
//TODO::上线后注释
$domain = 'https://demomark.globalso.com/';
$arr = [];
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$arr['count'] = $inquiry_list['data']['total'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
//总数
$arr['total'] = $inquiry_list['data']['total'];
//数据详情
$data = $inquiry_list['data']['data'];
$arr['month_total'] = 0;
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
foreach ($data as $v){
if(($startTime <= $v['submit_time']) && $v['submit_time'] <= $endTime){
$arr['month_total']++;
}
if(isset($countryArr[$v['country']])){
$countryArr[$v['country']]++;
}else{
$countryArr[$v1['country']] = 0;
$countryArr[$v['country']] = 0;
}
}
// 获取当前日期时间
$arr['month'] = Carbon::now()->subMonth()->format('Y-m');
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 20, true);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = json_encode($top20);
return $arr;
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = $project_id;
DB::table('gl_inquiry_month_count')->insert($arr);
}
/**
* @remark :流量统计
* @name :flowCount
* @author :lyh
* @method :post
* @time :2023/6/30 14:31
*/
public function flowCount($startTime,$endTime,$project_id){
DB::table('gl_count')
->where(['project_id'=>$project_id])
->where('date','>=',$startTime)
->where('date','<=',$endTime)
->sum('pv_num');
}
}
... ...
... ... @@ -178,7 +178,7 @@ class ComController extends BaseController
$arr['updated_at'] = date('Y-m-d H:i:s');
$arr['project_id'] = 1;
DB::table('gl_inquiry_month_count')->insert($arr);
$this->response('success',Code::SUCCESS,$inquiry_list);
$this->response('success',Code::SUCCESS,$startTime);
}
/**
... ...