作者 lyh

gx数据

... ... @@ -82,7 +82,7 @@ class Count extends Command
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
$arr = $this->inquiry($arr,$v['test_domain'], $v['id'] , $v['is_upgrade'] ?? 0);
if($arr === false){
continue;
}
... ... @@ -134,8 +134,8 @@ class Count extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ... @@ -175,6 +175,7 @@ class Count extends Command
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.remain_day AS remain_day',
'gl_project.finish_remain_day AS finish_remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
... ...
... ... @@ -101,8 +101,8 @@ class CountAll extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ...
... ... @@ -32,7 +32,7 @@ class CountDate extends Command
*
* @var string
*/
protected $description = '统计昨日数据';
protected $description = '时间统计记录';
/**
* @name :(定时执行生成昨日数据统计)handle
... ... @@ -84,7 +84,7 @@ class CountDate extends Command
$arr['created_at'] = date('Y-m-d H:i:s');
$arr['updated_at'] = date('Y-m-d H:i:s');
//询盘统计
$arr = $this->inquiry($arr,$v['test_domain'], $v['id']);
$arr = $this->inquiry($arr,$v['test_domain'], $v['id'],$v['is_upgrade'] ?? 0);
if($arr === false){
continue;
}
... ... @@ -136,8 +136,8 @@ class CountDate extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ... @@ -177,6 +177,7 @@ class CountDate extends Command
'gl_project.id AS id',
'gl_project.type AS type',
'gl_project.extend_type AS extend_type',
'gl_project.is_upgrade AS is_upgrade',
'gl_project.remain_day AS remain_day',
'gl_project.finish_remain_day AS finish_remain_day',
'gl_project_deploy_build.test_domain AS test_domain',
... ...
... ... @@ -52,7 +52,7 @@ class CountProject extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id){
public function count($project_id,$is_upgrade = 0){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')->select('updated_date')
->groupBy('updated_date')->get()->toArray();
$project = new Project();
... ... @@ -87,7 +87,7 @@ class CountProject extends Command
$arr['compliance_day'] = $projectInfo['finish_remain_day'];
//剩余服务时常
$arr['service_day'] = $projectInfo['remain_day'];
$arr = $this->inquiry($arr,$domain, $project_id);
$arr = $this->inquiry($arr,$domain, $project_id,$projectInfo['is_upgrade'] ?? 0);
//查询当天数据是否存在 存在则更新
$info = $count->read(['date'=>$v['updated_date'],'project_id'=>$project_id]);
if($info === false){
... ... @@ -144,8 +144,8 @@ class CountProject extends Command
* @method :post
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade);
if($inquiry_list == false){
return false;
}
... ...
... ... @@ -59,7 +59,7 @@ class MonthAllCount extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url ,$v['is_upgrade']);
DB::disconnect('custom_mysql');
}
}
... ... @@ -71,7 +71,7 @@ class MonthAllCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
->groupBy('month')->get()->toArray();
... ... @@ -85,7 +85,7 @@ class MonthAllCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -67,7 +67,7 @@ class MonthCount extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url ,$v['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
}
... ... @@ -99,7 +99,7 @@ class MonthCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$arr = [];
$v = ['month'=>date('Y-m')];
$monthCountModel = new MonthCountModel();
... ... @@ -109,7 +109,7 @@ class MonthCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -67,7 +67,7 @@ class MonthCountDate extends Command
}
ProjectServer::useProject($v['id']);
echo date('Y-m-d H:i:s') . '项目id:'.$v['id'] . PHP_EOL;
$this->count($v['id'], $url);
$this->count($v['id'], $url , $v['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
}
... ... @@ -99,7 +99,7 @@ class MonthCountDate extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade){
$arr = [];
$date = $this->argument('date');
$v = ['month'=>$date];
... ... @@ -110,7 +110,7 @@ class MonthCountDate extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v['month']));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month']);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v['month'],$is_upgrade ?? 0);
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
echo date('Y-m-d H:i:s') . '数据:'.$res['data']['count'] . PHP_EOL;
... ...
... ... @@ -49,8 +49,10 @@ class MonthProjectCount extends Command
$info = $domainModel->read(['project_id'=>$project_id]);
$url = $info['domain'];
}
$projectModel = new Project();
$projectInfo = $projectModel->read(['id'=>$project_id]);
ProjectServer::useProject($project_id);
$this->count($project_id,$url);
$this->count($project_id,$url,$projectInfo['is_upgrade'] ?? 0);
DB::disconnect('custom_mysql');
}
... ... @@ -61,7 +63,7 @@ class MonthProjectCount extends Command
* @method :post
* @time :2024/1/8 9:05
*/
public function count($project_id,$url){
public function count($project_id,$url,$is_upgrade = 0){
$data = [];
$list = DB::connection('custom_mysql')->table('gl_customer_visit')
->select(DB::raw('DATE_FORMAT(updated_date, "%Y-%m") as month'))
... ... @@ -80,7 +82,7 @@ class MonthProjectCount extends Command
// 获取当月结束时间
$end = date('Y-m-t', strtotime($v));
$arr['project_id'] = $project_id;
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v);
$res = (new FormGlobalsoApi())->getMonthInquiry($url,$v ,$is_upgrade ?? 0);
echo date('Y-m-d H:i:s') . '月份:'.$v. PHP_EOL;
$arr['total'] = $arr['month_total'] = 0;
if(isset($res['data']['count'])){
... ...
... ... @@ -144,7 +144,7 @@ class Test extends Command
try {
$list = Count::where('date', '2023-12-11')->where('project_id', $project->id)->get();
foreach ($list as $v){
$arr = $this->inquiry([],$test_domain, $v['id']);
$arr = $this->inquiry([],$test_domain, $v['id'],$project->is_upgrade ?? 0);
$v->inquiry_num = $arr['inquiry_num'];
$v->country = $arr['country'];
$v->save();
... ... @@ -157,8 +157,8 @@ class Test extends Command
echo "finish";
}
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
public function inquiry($arr,$domain,$project_id,$is_upgrade = 0){
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade ?? 0);
if($inquiry_list['status'] == 400){
$arr['inquiry_num'] = 0;
$countryArr = [];
... ...
... ... @@ -162,12 +162,19 @@ class FormGlobalsoApi
* @method :post
* @time :2024/8/15 14:16
*/
public function getInquiryAll($domain){
public function getInquiryAll($domain,$is_upgrade = 0){
if (!(strpos($domain, 'https://') === 0)) {
$domain = 'https://'.$domain.'/';
}
$token = md5($domain.date("Y-m-d"));
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?domain=$domain&token=$token&source=1,2,3,4&num=15";
$data = [
'domain' => $domain,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4' : '1,3',
'num'=>15,
];
$queryString = http_build_query($data);
$url = "https://form.globalso.com/api/external-interface/domain_con/15243d63ed5a5738?".$queryString;
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
... ... @@ -184,10 +191,18 @@ class FormGlobalsoApi
* @method :post
* @time :2024/8/16 10:16
*/
public function getMonthInquiry($url,$month){
public function getMonthInquiry($url,$month,$is_upgrade = 0){
$url = 'https://'.$url.'/';
$token = md5($url.date("Y-m-d"));
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?domain='.$url.'&token='.$token.'&source=1,2,3,4&model=month&sta_date='.$month;
$data = [
'domain' => $url,
'token' => $token,
'source'=> $is_upgrade ? '1,2,3,4' : '1,3',
'model' => 'month',
'sta_date'=>$month,
];
$queryString = http_build_query($data);
$url = 'https://form.globalso.com/api/external-interface/country_con/15243d63ed5a5738?'.$queryString;
$res = http_get($url,['charset=utf-8']);
echo date('Y-m-d H:i:s') . '数据:'.json_encode($res) . PHP_EOL;
return $res;
... ...
... ... @@ -75,7 +75,7 @@ class OptimizationReportController extends BaseController
//关键词排名明细
$data['keywords_rank_list'] = $this->keywords_rank_list($this->param['project_id'],$projectInfo);
//pv_ip统计
$data['pv_ip'] = $this->pv_ip($domain_info['domain']);
$data['pv_ip'] = $this->pv_ip($domain_info['domain'],$projectInfo['is_upgrade']);
//30天统计
$data['count_30'] = $this->count_30_total();
//访问国家前10
... ... @@ -321,10 +321,10 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2024/3/7 16:53
*/
public function pv_ip($domain){
public function pv_ip($domain,$is_upgrade = 0){
$pv = (new VisitItem())->count();
$ip = (new Visit())->count();
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain,$is_upgrade ?? 0);
if(!empty($inquiry_list)){
$total = $inquiry_list['data']['count'] ?? 0;
}
... ...