作者 lyh

gx脚本demo

... ... @@ -135,7 +135,7 @@ class Count extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
... ... @@ -143,17 +143,9 @@ class Count extends Command
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -102,7 +102,7 @@ class CountAll extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
... ... @@ -110,17 +110,9 @@ class CountAll extends Command
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -145,7 +145,7 @@ class CountProject extends Command
* @time :2023/6/14 15:44
*/
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list == false){
return false;
}
... ... @@ -154,17 +154,9 @@ class CountProject extends Command
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
}
}
$countryArr = $inquiry_list['data']['country'];
}
//加上其他询盘
ProjectServer::useProject($project_id);
... ...
... ... @@ -150,24 +150,15 @@ class Test extends Command
}
public function inquiry($arr,$domain,$project_id){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if($inquiry_list['status'] == 400){
$arr['inquiry_num'] = 0;
$countryArr = [];
}else{
$arr['inquiry_num'] = $inquiry_list['data']['total'];
$arr['inquiry_num'] = $inquiry_list['data']['count'];
//询盘国家统计
$countryData = $inquiry_list['data']['data'];
$countryArr = [];
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']]++;
}else{
$countryArr[$v1['country']] = 1;
$countryArr = $inquiry_list['data']['country'];
}
}
}
//加上其他询盘
$arr['inquiry_num'] += InquiryFormData::getCount();
$countryData = InquiryFormData::getCountryCount();
... ...
... ... @@ -162,10 +162,15 @@ class FormGlobalsoApi
* @method :post
* @time :2024/8/15 14:16
*/
public function getInquiryAll($domain){
public function getInquiryAll($domain,$start_month = ''){
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";
if(!empty($start) && !empty($end)){
$url = $url."&sta_date=$start_month";
}
try {
$res = http_get($url,['charset=utf-8']);
} catch (\Exception | GuzzleException $e) {
... ...
... ... @@ -927,3 +927,5 @@ function base62_encode($num) {
}
... ...
... ... @@ -14,6 +14,7 @@ use App\Helper\Arr;
use App\Helper\FormGlobalsoApi;
use App\Models\Domain\DomainInfo;
use App\Models\HomeCount\Count;
use App\Models\HomeCount\MonthCount;
use App\Models\Inquiry\InquiryFormData;
use App\Models\Project\Project;
use App\Models\RankData\ExternalLinks;
... ... @@ -115,7 +116,7 @@ class OptimizationReportController extends BaseController
// 获取当前月的结束时间
$endTime = date('Y-m-t', strtotime($this->param['date']));
$arr = [];
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain);
$arr = $this->inquiryCount($arr,$startTime,$endTime,$domain,$project_id);
$arr = $this->flowCount($arr,$startTime,$endTime,$project_id);
$arr = $this->sourceCount($arr,$startTime,$endTime,$domain);
$arr['month'] = date('Y-m',time());
... ... @@ -131,42 +132,15 @@ class OptimizationReportController extends BaseController
* @method :post
* @time :2023/6/30 14:29
*/
public function inquiryCount(&$arr,&$startTime,&$endTime,$domain){
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
if(!empty($inquiry_list)){
//总数
$arr['total'] = $inquiry_list['data']['total'] ?? 0;
//数据详情
$data = $inquiry_list['data']['data'] ?? '';
$arr['month_total'] = 0;
$countryArr = [];
if(isset($data) && !empty($data)){
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']] = 1;
}
}
}
}
}
//加上其他询盘
$arr['total'] += InquiryFormData::getCount();
$arr['month_total'] += InquiryFormData::getCount([$startTime, $endTime]);
$countryData = InquiryFormData::getCountryCount([$startTime, $endTime]);
foreach ($countryData as $v1){
if(isset($countryArr[$v1['country']])){
$countryArr[$v1['country']] += $v1['count'];
}else{
$countryArr[$v1['country']] = $v1['count'];
}
public function inquiryCount(&$arr, &$startTime, $project_id){
$month = date('Y-m',strtotime($startTime));
$monthCountModel = new MonthCount();
$info = $monthCountModel->read(['project_id'=>$project_id,'month'=>$month]);
if($info !== false){
$arr['country'] = $info['country'];
$arr['total'] = $info['total'];
$arr['month_total'] = $info['month_total'];
}
arsort($countryArr);
$top20 = array_slice($countryArr, 0, 15, true);
$arr['country'] = $top20;
return $arr;
}
... ... @@ -350,9 +324,9 @@ class OptimizationReportController extends BaseController
public function pv_ip($domain){
$pv = (new VisitItem())->count();
$ip = (new Visit())->count();
$inquiry_list = (new FormGlobalsoApi())->getInquiryList($domain,'',1,100000000);
$inquiry_list = (new FormGlobalsoApi())->getInquiryAll($domain);
if(!empty($inquiry_list)){
$total = $inquiry_list['data']['total'] ?? 0;
$total = $inquiry_list['data']['count'] ?? 0;
}
return [
'total_pv'=>$pv,
... ...