作者 赵彬吉

update

... ... @@ -310,4 +310,25 @@ class QuanqiusouApi
}
}
/**
* 获取代理信息
* @param $domain
* @return array|mixed
* @author zbj
* @date 2024/10/26
*/
public function getV5RemainDay($domain){
$token = md5($domain.'qqs');
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_remain_day_by_domain.php?'.http_build_query(['token' => $token]), [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
return Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('获取代理失败', [$domain], $e);
return [];
}
}
}
... ...
... ... @@ -400,7 +400,8 @@ class AdsController extends BaseController
}else{
$item['project_id'] = 0;
}
//获取剩余天数
$item['remaining_days'] = ReInquiryCount::getRemainingDays($item['domain'], $item['type'], $item['project_id']);
}
return $this->response('success', Code::SUCCESS, $result);
... ...
... ... @@ -103,4 +103,22 @@ class ReInquiryCount extends Base
}
return $res;
}
public static function getRemainingDays($domain, $type, $project_id)
{
$cache_key = 're_inquiry_count_' . $domain . '_' . date('Ymd');
$data = Cache::get($cache_key);
if($data === null){
if($project_id){
$data = Project::where('id', $project_id)->value('remain_day');
}else if($type == 3){
$data = '-';
}else{
$res = (new QuanqiusouApi())->getV5RemainDay($domain);
$data = $res['data']['remain_day'] ??'-';
}
Cache::put($cache_key, $data, 24 * 3600);
}
return $data;
}
}
... ...