Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6
正在显示
7 个修改的文件
包含
88 行增加
和
18 行删除
| @@ -67,9 +67,7 @@ class DomainInfo extends Command | @@ -67,9 +67,7 @@ class DomainInfo extends Command | ||
| 67 | $serverIpModel = new ServersIp(); | 67 | $serverIpModel = new ServersIp(); |
| 68 | $domainCreateTaskModel = new DomainCreateTask(); | 68 | $domainCreateTaskModel = new DomainCreateTask(); |
| 69 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 | 69 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 |
| 70 | - $list = $domainModel->where('status', '=', 1)->where('type', 1)->where(function ($query) use ($end_day) { | ||
| 71 | - $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day); | ||
| 72 | - })->get()->toArray(); | 70 | + $list = $domainModel->where('status', '=', 1)->where('type', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray(); |
| 73 | foreach ($list as $v) { | 71 | foreach ($list as $v) { |
| 74 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); | 72 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); |
| 75 | if (!$project_info) { | 73 | if (!$project_info) { |
| @@ -116,9 +114,7 @@ class DomainInfo extends Command | @@ -116,9 +114,7 @@ class DomainInfo extends Command | ||
| 116 | $serverIpModel = new ServersIp(); | 114 | $serverIpModel = new ServersIp(); |
| 117 | $domainCreateTaskModel = new DomainCreateTask(); | 115 | $domainCreateTaskModel = new DomainCreateTask(); |
| 118 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 | 116 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 |
| 119 | - $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', 1)->where(function ($query) use ($end_day) { | ||
| 120 | - $query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day); | ||
| 121 | - })->get()->toArray(); | 117 | + $list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', 1)->where('amp_certificate_end_time', '<', $end_day)->get()->toArray(); |
| 122 | foreach ($list as $v) { | 118 | foreach ($list as $v) { |
| 123 | $domain_array = parse_url($v['domain']); | 119 | $domain_array = parse_url($v['domain']); |
| 124 | $host = $domain_array['host'] ?? $domain_array['path']; | 120 | $host = $domain_array['host'] ?? $domain_array['path']; |
| @@ -175,9 +171,7 @@ class DomainInfo extends Command | @@ -175,9 +171,7 @@ class DomainInfo extends Command | ||
| 175 | $serverIpModel = new ServersIp(); | 171 | $serverIpModel = new ServersIp(); |
| 176 | $domainCreateTaskModel = new DomainCreateTask(); | 172 | $domainCreateTaskModel = new DomainCreateTask(); |
| 177 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 | 173 | $end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期 |
| 178 | - $list = $customModel->where('status', 1)->where('is_create', 1)->where('type', 1)->where(function ($query) use ($end_day) { | ||
| 179 | - $query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day); | ||
| 180 | - })->get()->toArray(); | 174 | + $list = $customModel->where('status', 1)->where('is_create', 1)->where('type', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray(); |
| 181 | foreach ($list as $v) { | 175 | foreach ($list as $v) { |
| 182 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); | 176 | $project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']); |
| 183 | if (!$project_info) { | 177 | if (!$project_info) { |
| @@ -70,7 +70,12 @@ class SyncProject extends Command | @@ -70,7 +70,12 @@ class SyncProject extends Command | ||
| 70 | $is_update = $item['data']['is_update']??0;//是否是4.0或5.0更新到6.0 | 70 | $is_update = $item['data']['is_update']??0;//是否是4.0或5.0更新到6.0 |
| 71 | $order_id = $item['data']['order_id']; | 71 | $order_id = $item['data']['order_id']; |
| 72 | if($is_update == 1){ | 72 | if($is_update == 1){ |
| 73 | - $data = http_get('https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, ['charset' => 'UTF-8']); | 73 | +// $data = http_get('https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, ['charset' => 'UTF-8']); |
| 74 | + $client = new \GuzzleHttp\Client(); | ||
| 75 | + $data = $client->request('GET', 'https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, [ | ||
| 76 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 77 | + ])->getBody()->getContents(); | ||
| 78 | + $data = json_decode($data, true); | ||
| 74 | }else{ | 79 | }else{ |
| 75 | $api = new OaGlobalsoApi(); | 80 | $api = new OaGlobalsoApi(); |
| 76 | $data = $api->order_info($order_id); | 81 | $data = $api->order_info($order_id); |
| @@ -64,7 +64,7 @@ class RankData extends BaseCommands | @@ -64,7 +64,7 @@ class RankData extends BaseCommands | ||
| 64 | foreach ($list as $item) { | 64 | foreach ($list as $item) { |
| 65 | Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . ''; | 65 | Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . ''; |
| 66 | try { | 66 | try { |
| 67 | - (new RankDataLogic())->syncRankData($item['api_no'], $site_res, true); | 67 | + (new RankDataLogic())->syncRankData($item['api_no'], $site_res); |
| 68 | } catch (\Exception $e) { | 68 | } catch (\Exception $e) { |
| 69 | Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); | 69 | Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage()); |
| 70 | $error++; | 70 | $error++; |
| @@ -38,7 +38,12 @@ class SyncMobile extends Command | @@ -38,7 +38,12 @@ class SyncMobile extends Command | ||
| 38 | */ | 38 | */ |
| 39 | public function handle(){ | 39 | public function handle(){ |
| 40 | $url = 'https://www.quanqiusou.cn/extend_api/saas/get_phone.php'; | 40 | $url = 'https://www.quanqiusou.cn/extend_api/saas/get_phone.php'; |
| 41 | - $data = curlGet($url);//TODO::获取号码库 | 41 | +// $data = curlGet($url);//TODO::获取号码库 |
| 42 | + $client = new \GuzzleHttp\Client(); | ||
| 43 | + $data = $client->request('GET', $url, [ | ||
| 44 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 45 | + ])->getBody()->getContents(); | ||
| 46 | + $data = json_decode($data, true); | ||
| 42 | DB::table('gl_mobile')->delete(); | 47 | DB::table('gl_mobile')->delete(); |
| 43 | $create_time = date('Y-m-d H:i:s'); | 48 | $create_time = date('Y-m-d H:i:s'); |
| 44 | foreach ($data as $v){ | 49 | foreach ($data as $v){ |
| @@ -3,7 +3,9 @@ | @@ -3,7 +3,9 @@ | ||
| 3 | 3 | ||
| 4 | namespace App\Helper; | 4 | namespace App\Helper; |
| 5 | 5 | ||
| 6 | +use App\Models\RankData\RankDataLog; | ||
| 6 | use App\Utils\HttpUtils; | 7 | use App\Utils\HttpUtils; |
| 8 | +use GuzzleHttp\Client; | ||
| 7 | use GuzzleHttp\Exception\GuzzleException; | 9 | use GuzzleHttp\Exception\GuzzleException; |
| 8 | use Illuminate\Support\Facades\Cache; | 10 | use Illuminate\Support\Facades\Cache; |
| 9 | use Illuminate\Support\Facades\Log; | 11 | use Illuminate\Support\Facades\Log; |
| @@ -74,6 +76,7 @@ class QuanqiusouApi | @@ -74,6 +76,7 @@ class QuanqiusouApi | ||
| 74 | 76 | ||
| 75 | /** | 77 | /** |
| 76 | * 获取谷歌排名数据 | 78 | * 获取谷歌排名数据 |
| 79 | + * @param $project_id | ||
| 77 | * @param $api_no | 80 | * @param $api_no |
| 78 | * @param string $lang | 81 | * @param string $lang |
| 79 | * @param int $day | 82 | * @param int $day |
| @@ -81,7 +84,7 @@ class QuanqiusouApi | @@ -81,7 +84,7 @@ class QuanqiusouApi | ||
| 81 | * @author zbj | 84 | * @author zbj |
| 82 | * @date 2023/5/11 | 85 | * @date 2023/5/11 |
| 83 | */ | 86 | */ |
| 84 | - public function getGoogleRank($api_no, string $lang = '', int $day = 7, $force = true) | 87 | + public function getGoogleRank($project_id, $api_no, string $lang = '', int $day = 7, $force = true) |
| 85 | { | 88 | { |
| 86 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); | 89 | $key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d'); |
| 87 | $res = Cache::get($key); | 90 | $res = Cache::get($key); |
| @@ -95,10 +98,16 @@ class QuanqiusouApi | @@ -95,10 +98,16 @@ class QuanqiusouApi | ||
| 95 | //8918_kr_2024-02-19_2024-02-25.json 8918_2024-02-19_2024-02-25.json | 98 | //8918_kr_2024-02-19_2024-02-25.json 8918_2024-02-19_2024-02-25.json |
| 96 | $api_url = "https://quanqiusou.cn/google-rank/data_json/{$today}/{$api_no}_{$startDay}_{$endDay}.json"; | 99 | $api_url = "https://quanqiusou.cn/google-rank/data_json/{$today}/{$api_no}_{$startDay}_{$endDay}.json"; |
| 97 | try { | 100 | try { |
| 98 | - $res = HttpUtils::get($api_url, []); | 101 | + //$res = HttpUtils::get($api_url, []); |
| 102 | + $client = new Client(); | ||
| 103 | + $res = $client->request('GET', $api_url, [ | ||
| 104 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 105 | + // 其他请求选项 | ||
| 106 | + ])->getBody()->getContents(); | ||
| 99 | if($res){ | 107 | if($res){ |
| 100 | $res = Arr::s2a($res); | 108 | $res = Arr::s2a($res); |
| 101 | Cache::put($key, $res, 2 * 3600); | 109 | Cache::put($key, $res, 2 * 3600); |
| 110 | + RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res); | ||
| 102 | } | 111 | } |
| 103 | } catch (\Exception | GuzzleException $e) { | 112 | } catch (\Exception | GuzzleException $e) { |
| 104 | errorLog('获取谷歌排名数据失败', [$api_no], $e); | 113 | errorLog('获取谷歌排名数据失败', [$api_no], $e); |
| @@ -390,7 +390,7 @@ class RankDataLogic extends BaseLogic | @@ -390,7 +390,7 @@ class RankDataLogic extends BaseLogic | ||
| 390 | $api = new QuanqiusouApi(); | 390 | $api = new QuanqiusouApi(); |
| 391 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); | 391 | $model = RankData::where('project_id', $project_id)->where('lang', '')->first(); |
| 392 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 392 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 393 | - $res = $api->getGoogleRank($api_no, '', 7, $force); | 393 | + $res = $api->getGoogleRank($project_id, $api_no, '', 7, $force); |
| 394 | if (!$res) { | 394 | if (!$res) { |
| 395 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); | 395 | throw new \Exception("接口数据获取失败,api_no:{$api_no}"); |
| 396 | } | 396 | } |
| @@ -416,7 +416,7 @@ class RankDataLogic extends BaseLogic | @@ -416,7 +416,7 @@ class RankDataLogic extends BaseLogic | ||
| 416 | } | 416 | } |
| 417 | $model = RankData::where('project_id', $project_id)->where('lang', $lang)->first(); | 417 | $model = RankData::where('project_id', $project_id)->where('lang', $lang)->first(); |
| 418 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { | 418 | if (!$model || $model->updated_date != date('Y-m-d') || $force) { |
| 419 | - $res = $api->getGoogleRank($api_no, $lang, 7, $force); | 419 | + $res = $api->getGoogleRank($project_id, $api_no, $lang, 7, $force); |
| 420 | if (!$res) { | 420 | if (!$res) { |
| 421 | throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); | 421 | throw new \Exception("接口数据获取失败,api_no:{$api_no},lang"); |
| 422 | } | 422 | } |
| @@ -586,7 +586,11 @@ class RankDataLogic extends BaseLogic | @@ -586,7 +586,11 @@ class RankDataLogic extends BaseLogic | ||
| 586 | 586 | ||
| 587 | //5.0 | 587 | //5.0 |
| 588 | try { | 588 | try { |
| 589 | - $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []); | 589 | +// $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []); |
| 590 | + $client = new \GuzzleHttp\Client(); | ||
| 591 | + $data = $client->request('GET', "https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", [ | ||
| 592 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 593 | + ])->getBody()->getContents(); | ||
| 590 | $data = Arr::s2a($data); | 594 | $data = Arr::s2a($data); |
| 591 | }catch (\Exception $e){ | 595 | }catch (\Exception $e){ |
| 592 | $data = []; | 596 | $data = []; |
| @@ -668,7 +672,11 @@ class RankDataLogic extends BaseLogic | @@ -668,7 +672,11 @@ class RankDataLogic extends BaseLogic | ||
| 668 | 672 | ||
| 669 | //5.0 | 673 | //5.0 |
| 670 | try { | 674 | try { |
| 671 | - $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []); | 675 | +// $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []); |
| 676 | + $client = new \GuzzleHttp\Client(); | ||
| 677 | + $data = $client->request('GET', "https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", [ | ||
| 678 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 679 | + ])->getBody()->getContents(); | ||
| 672 | $data = Arr::s2a($data)['list']; | 680 | $data = Arr::s2a($data)['list']; |
| 673 | }catch (\Exception $e){ | 681 | }catch (\Exception $e){ |
| 674 | $data = []; | 682 | $data = []; |
app/Models/RankData/RankDataLog.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\RankData; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Helper\Arr; | ||
| 7 | +use App\Models\Base; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * Class GoogleRank | ||
| 11 | + * @package App\Models | ||
| 12 | + * @author zbj | ||
| 13 | + * @date 2023/5/6 | ||
| 14 | + */ | ||
| 15 | +class RankDataLog extends Base | ||
| 16 | +{ | ||
| 17 | + //设置关联表名 | ||
| 18 | + protected $table = 'gl_rank_data_log'; | ||
| 19 | + | ||
| 20 | + public function setDataAttribute($value) | ||
| 21 | + { | ||
| 22 | + $this->attributes['data'] = Arr::a2s($value); | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public function getDataAttribute($value) | ||
| 26 | + { | ||
| 27 | + return Arr::s2a($value); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + public static function addLog($project_id, $api_no, $lang, $date, $res){ | ||
| 31 | + $data= []; | ||
| 32 | + foreach ($res as $key=>$item){ | ||
| 33 | + $data[$key] = $item[$date]; | ||
| 34 | + } | ||
| 35 | + $model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first(); | ||
| 36 | + if(!$model){ | ||
| 37 | + $model = new self(); | ||
| 38 | + } | ||
| 39 | + $model->project_id = $project_id; | ||
| 40 | + $model->api_no = $api_no; | ||
| 41 | + $model->lang = $lang; | ||
| 42 | + $model->date = $date; | ||
| 43 | + $model->data = $data; | ||
| 44 | + $model->save(); | ||
| 45 | + | ||
| 46 | + return true; | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | +} |
-
请 注册 或 登录 后发表评论