作者 Your Name
... ... @@ -67,9 +67,7 @@ class DomainInfo extends Command
$serverIpModel = new ServersIp();
$domainCreateTaskModel = new DomainCreateTask();
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$list = $domainModel->where('status', '=', 1)->where('type', 1)->where(function ($query) use ($end_day) {
$query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day);
})->get()->toArray();
$list = $domainModel->where('status', '=', 1)->where('type', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray();
foreach ($list as $v) {
$project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
if (!$project_info) {
... ... @@ -116,9 +114,7 @@ class DomainInfo extends Command
$serverIpModel = new ServersIp();
$domainCreateTaskModel = new DomainCreateTask();
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', 1)->where(function ($query) use ($end_day) {
$query->whereNull('amp_certificate_end_time')->orWhere('amp_certificate_end_time', '<', $end_day);
})->get()->toArray();
$list = $domainModel->where('status', '=', 1)->where('amp_status', 1)->where('amp_type', 1)->where('amp_certificate_end_time', '<', $end_day)->get()->toArray();
foreach ($list as $v) {
$domain_array = parse_url($v['domain']);
$host = $domain_array['host'] ?? $domain_array['path'];
... ... @@ -175,9 +171,7 @@ class DomainInfo extends Command
$serverIpModel = new ServersIp();
$domainCreateTaskModel = new DomainCreateTask();
$end_day = date('Y-m-d H:i:s', time() + 3 * 24 * 3600);//3天后到期
$list = $customModel->where('status', 1)->where('is_create', 1)->where('type', 1)->where(function ($query) use ($end_day) {
$query->whereNull('certificate_end_time')->orWhere('certificate_end_time', '<', $end_day);
})->get()->toArray();
$list = $customModel->where('status', 1)->where('is_create', 1)->where('type', 1)->where('certificate_end_time', '<', $end_day)->get()->toArray();
foreach ($list as $v) {
$project_info = $projectModel->read(['id' => $v['project_id']], ['serve_id']);
if (!$project_info) {
... ...
... ... @@ -70,7 +70,12 @@ class SyncProject extends Command
$is_update = $item['data']['is_update']??0;//是否是4.0或5.0更新到6.0
$order_id = $item['data']['order_id'];
if($is_update == 1){
$data = http_get('https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, ['charset' => 'UTF-8']);
// $data = http_get('https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, ['charset' => 'UTF-8']);
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', 'https://quanqiusou.cn/extend_api/v6/update.php?postid='.$order_id, [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$data = json_decode($data, true);
}else{
$api = new OaGlobalsoApi();
$data = $api->order_info($order_id);
... ...
... ... @@ -64,7 +64,7 @@ class RankData extends BaseCommands
foreach ($list as $item) {
Log::channel('rank_data')->info('项目开始:ID' . $item['project_id'] .' - '. $item['api_no']) . '';
try {
(new RankDataLogic())->syncRankData($item['api_no'], $site_res, true);
(new RankDataLogic())->syncRankData($item['api_no'], $site_res);
} catch (\Exception $e) {
Log::channel('rank_data')->error('RankData:失败 ' . $item['api_no'] . $e->getMessage());
$error++;
... ...
... ... @@ -38,7 +38,12 @@ class SyncMobile extends Command
*/
public function handle(){
$url = 'https://www.quanqiusou.cn/extend_api/saas/get_phone.php';
$data = curlGet($url);//TODO::获取号码库
// $data = curlGet($url);//TODO::获取号码库
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', $url, [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$data = json_decode($data, true);
DB::table('gl_mobile')->delete();
$create_time = date('Y-m-d H:i:s');
foreach ($data as $v){
... ...
... ... @@ -3,7 +3,9 @@
namespace App\Helper;
use App\Models\RankData\RankDataLog;
use App\Utils\HttpUtils;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
... ... @@ -74,6 +76,7 @@ class QuanqiusouApi
/**
* 获取谷歌排名数据
* @param $project_id
* @param $api_no
* @param string $lang
* @param int $day
... ... @@ -81,7 +84,7 @@ class QuanqiusouApi
* @author zbj
* @date 2023/5/11
*/
public function getGoogleRank($api_no, string $lang = '', int $day = 7, $force = true)
public function getGoogleRank($project_id, $api_no, string $lang = '', int $day = 7, $force = true)
{
$key = "quanqiusou_api_rank_{$api_no}_{$lang}_{$day}_" . date('Y-m-d');
$res = Cache::get($key);
... ... @@ -95,10 +98,16 @@ class QuanqiusouApi
//8918_kr_2024-02-19_2024-02-25.json 8918_2024-02-19_2024-02-25.json
$api_url = "https://quanqiusou.cn/google-rank/data_json/{$today}/{$api_no}_{$startDay}_{$endDay}.json";
try {
$res = HttpUtils::get($api_url, []);
//$res = HttpUtils::get($api_url, []);
$client = new Client();
$res = $client->request('GET', $api_url, [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
// 其他请求选项
])->getBody()->getContents();
if($res){
$res = Arr::s2a($res);
Cache::put($key, $res, 2 * 3600);
RankDataLog::addLog($project_id, $api_no, $lang, $endDay, $res);
}
} catch (\Exception | GuzzleException $e) {
errorLog('获取谷歌排名数据失败', [$api_no], $e);
... ...
... ... @@ -390,7 +390,7 @@ class RankDataLogic extends BaseLogic
$api = new QuanqiusouApi();
$model = RankData::where('project_id', $project_id)->where('lang', '')->first();
if (!$model || $model->updated_date != date('Y-m-d') || $force) {
$res = $api->getGoogleRank($api_no, '', 7, $force);
$res = $api->getGoogleRank($project_id, $api_no, '', 7, $force);
if (!$res) {
throw new \Exception("接口数据获取失败,api_no:{$api_no}");
}
... ... @@ -416,7 +416,7 @@ class RankDataLogic extends BaseLogic
}
$model = RankData::where('project_id', $project_id)->where('lang', $lang)->first();
if (!$model || $model->updated_date != date('Y-m-d') || $force) {
$res = $api->getGoogleRank($api_no, $lang, 7, $force);
$res = $api->getGoogleRank($project_id, $api_no, $lang, 7, $force);
if (!$res) {
throw new \Exception("接口数据获取失败,api_no:{$api_no},lang");
}
... ... @@ -586,7 +586,11 @@ class RankDataLogic extends BaseLogic
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
// $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', "https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$data = Arr::s2a($data);
}catch (\Exception $e){
$data = [];
... ... @@ -668,7 +672,11 @@ class RankDataLogic extends BaseLogic
//5.0
try {
$data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
// $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
$client = new \GuzzleHttp\Client();
$data = $client->request('GET', "https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$data = Arr::s2a($data)['list'];
}catch (\Exception $e){
$data = [];
... ...
<?php
namespace App\Models\RankData;
use App\Helper\Arr;
use App\Models\Base;
/**
* Class GoogleRank
* @package App\Models
* @author zbj
* @date 2023/5/6
*/
class RankDataLog extends Base
{
//设置关联表名
protected $table = 'gl_rank_data_log';
public function setDataAttribute($value)
{
$this->attributes['data'] = Arr::a2s($value);
}
public function getDataAttribute($value)
{
return Arr::s2a($value);
}
public static function addLog($project_id, $api_no, $lang, $date, $res){
$data= [];
foreach ($res as $key=>$item){
$data[$key] = $item[$date];
}
$model = self::where('project_id', $project_id)->where('date', $date)->where('lang', $lang)->first();
if(!$model){
$model = new self();
}
$model->project_id = $project_id;
$model->api_no = $api_no;
$model->lang = $lang;
$model->date = $date;
$model->data = $data;
$model->save();
return true;
}
}
... ...