作者 赵彬吉

update

<?php
namespace App\Console\Commands\Inquiry;
use App\Models\Inquiry\ReInquiryCount;
use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryDetailLog;
use App\Models\Inquiry\ReInquiryForm;
... ... @@ -186,6 +187,10 @@ class postInquiry extends Command
}
$log->status = ReInquiryDetailLog::STATUS_SUCCESS;
$log->save();
//统计
ReInquiryCount::addInquiryNum($detail['id'], $detail['re_website']);
return true;
}
... ...
... ... @@ -266,5 +266,25 @@ class QuanqiusouApi
return $res;
}
/**
* 获取代理信息
* @param $domain
* @return array|mixed
* @author zbj
* @date 2024/10/26
*/
public function getV5Agent($domain){
$token = md5($domain.'qqs');
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
return Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
errorLog('获取代理失败', [$domain], $e);
return [];
}
}
}
... ...
... ... @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task;
use App\Enums\Common\Code;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Http\Controllers\Aside\BaseController;
use App\Models\Channel\Channel;
use App\Models\Domain\DomainInfo;
use App\Models\Inquiry\ReInquiryCount;
use App\Models\Inquiry\ReInquiryDetail;
use App\Models\Inquiry\ReInquiryForm;
use App\Models\Inquiry\ReInquiryTask;
... ... @@ -117,6 +119,9 @@ class AdsController extends BaseController
}
$item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/');
}
foreach ($target as $v){
ReInquiryCount::addInquiryNum($id, $v['url'], 0);
}
$task->target = json_encode($target);
$task->save();
return $this->response('success', Code::SUCCESS, []);
... ... @@ -141,19 +146,9 @@ class AdsController extends BaseController
];
return $this->response('success', Code::SUCCESS, $data);
}
$token = md5($domain.'qqs');
try {
$client = new \GuzzleHttp\Client();
$res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [
'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号
])->getBody()->getContents();
$res = Arr::s2a($res);
} catch (\Exception | GuzzleException $e) {
return $this->response('验证失败,请稍后再试!', Code::USER_ERROR, []);
}
$res = (new QuanqiusouApi())->getV5Agent($domain);
if(empty($res['status']) || $res['status'] != 200){
return $this->response($res['msg'], Code::USER_ERROR, []);
return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []);
}
$agent = implode(',', array_map(function ($v){
... ...
... ... @@ -5,9 +5,13 @@
* Date: 2024/9/30
* Time: 14:56
*/
namespace App\Models\Inquiry;
use App\Helper\Arr;
use App\Helper\QuanqiusouApi;
use App\Models\Domain\DomainInfo;
use App\Models\Project\Project;
use Illuminate\Database\Eloquent\Model;
/**
... ... @@ -23,26 +27,47 @@ class ReInquiryCount extends Model
*/
protected $table = 'gl_re_inquiry_count';
//`task_id` int(11) NOT NULL DEFAULT '0' COMMENT '转发任务ID',
// `company` varchar(255) NOT NULL DEFAULT '',
// `domain` varchar(200) NOT NULL DEFAULT '' COMMENT '广告名称',
// `num` int(2) NOT NU
public static function updateCount($task_id, $domain, $num = 0){
$model = self::where('domain', $domain)->first();
if(!$model){
$model = new self();
$model->domain = $domain;
$model->company =
}
$model->task_id =
/**
* @param $task_id
* @param $domain
* @param int $num
* @author zbj
* @date 2024/10/26
*/
public static function addInquiryNum($task_id, $domain, $num = 1)
{
$model = self::where('domain', $domain)->first();
if (!$model) {
//新增时获取公司名
$company = '';
$domain_info = DomainInfo::where('domain', $domain)->first();
if ($domain_info) {
$company = Project::where('id', $domain_info['project_id'])->value('company');
} else {
$res = (new QuanqiusouApi())->getV5Agent($domain);
if (!empty($res['status']) && $res['status'] == 200) {
$company = $res['company_name'];
}
}
$model = new self();
$model->domain = $domain;
$model->company = $company;
}
$model->task_ids = $model->task_ids + [$task_id];
$model->num = $model->num + $num;
$model->save();
}
public function setTaskIdsAttribute($value){
$this->attributes['task_ids'] = Arr::a2s($value);
public function setTaskIdsAttribute($value)
{
$this->attributes['task_ids'] = Arr::arrToSet($value);
}
public function getTaskIdsAttribute($value){
return Arr::s2a($value);
public function getTaskIdsAttribute($value)
{
return Arr::setToArr($value);
}
}
... ...