正在显示
4 个修改的文件
包含
73 行增加
和
28 行删除
| 1 | <?php | 1 | <?php |
| 2 | namespace App\Console\Commands\Inquiry; | 2 | namespace App\Console\Commands\Inquiry; |
| 3 | 3 | ||
| 4 | +use App\Models\Inquiry\ReInquiryCount; | ||
| 4 | use App\Models\Inquiry\ReInquiryDetail; | 5 | use App\Models\Inquiry\ReInquiryDetail; |
| 5 | use App\Models\Inquiry\ReInquiryDetailLog; | 6 | use App\Models\Inquiry\ReInquiryDetailLog; |
| 6 | use App\Models\Inquiry\ReInquiryForm; | 7 | use App\Models\Inquiry\ReInquiryForm; |
| @@ -186,6 +187,10 @@ class postInquiry extends Command | @@ -186,6 +187,10 @@ class postInquiry extends Command | ||
| 186 | } | 187 | } |
| 187 | $log->status = ReInquiryDetailLog::STATUS_SUCCESS; | 188 | $log->status = ReInquiryDetailLog::STATUS_SUCCESS; |
| 188 | $log->save(); | 189 | $log->save(); |
| 190 | + | ||
| 191 | + //统计 | ||
| 192 | + ReInquiryCount::addInquiryNum($detail['id'], $detail['re_website']); | ||
| 193 | + | ||
| 189 | return true; | 194 | return true; |
| 190 | } | 195 | } |
| 191 | 196 |
| @@ -266,5 +266,25 @@ class QuanqiusouApi | @@ -266,5 +266,25 @@ class QuanqiusouApi | ||
| 266 | return $res; | 266 | return $res; |
| 267 | } | 267 | } |
| 268 | 268 | ||
| 269 | + /** | ||
| 270 | + * 获取代理信息 | ||
| 271 | + * @param $domain | ||
| 272 | + * @return array|mixed | ||
| 273 | + * @author zbj | ||
| 274 | + * @date 2024/10/26 | ||
| 275 | + */ | ||
| 276 | + public function getV5Agent($domain){ | ||
| 277 | + $token = md5($domain.'qqs'); | ||
| 278 | + try { | ||
| 279 | + $client = new \GuzzleHttp\Client(); | ||
| 280 | + $res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [ | ||
| 281 | + 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 282 | + ])->getBody()->getContents(); | ||
| 283 | + return Arr::s2a($res); | ||
| 284 | + } catch (\Exception | GuzzleException $e) { | ||
| 285 | + errorLog('获取代理失败', [$domain], $e); | ||
| 286 | + return []; | ||
| 287 | + } | ||
| 288 | + } | ||
| 269 | 289 | ||
| 270 | } | 290 | } |
| @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task; | @@ -9,9 +9,11 @@ namespace App\Http\Controllers\Aside\Task; | ||
| 9 | 9 | ||
| 10 | use App\Enums\Common\Code; | 10 | use App\Enums\Common\Code; |
| 11 | use App\Helper\Arr; | 11 | use App\Helper\Arr; |
| 12 | +use App\Helper\QuanqiusouApi; | ||
| 12 | use App\Http\Controllers\Aside\BaseController; | 13 | use App\Http\Controllers\Aside\BaseController; |
| 13 | use App\Models\Channel\Channel; | 14 | use App\Models\Channel\Channel; |
| 14 | use App\Models\Domain\DomainInfo; | 15 | use App\Models\Domain\DomainInfo; |
| 16 | +use App\Models\Inquiry\ReInquiryCount; | ||
| 15 | use App\Models\Inquiry\ReInquiryDetail; | 17 | use App\Models\Inquiry\ReInquiryDetail; |
| 16 | use App\Models\Inquiry\ReInquiryForm; | 18 | use App\Models\Inquiry\ReInquiryForm; |
| 17 | use App\Models\Inquiry\ReInquiryTask; | 19 | use App\Models\Inquiry\ReInquiryTask; |
| @@ -117,6 +119,9 @@ class AdsController extends BaseController | @@ -117,6 +119,9 @@ class AdsController extends BaseController | ||
| 117 | } | 119 | } |
| 118 | $item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/'); | 120 | $item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/'); |
| 119 | } | 121 | } |
| 122 | + foreach ($target as $v){ | ||
| 123 | + ReInquiryCount::addInquiryNum($id, $v['url'], 0); | ||
| 124 | + } | ||
| 120 | $task->target = json_encode($target); | 125 | $task->target = json_encode($target); |
| 121 | $task->save(); | 126 | $task->save(); |
| 122 | return $this->response('success', Code::SUCCESS, []); | 127 | return $this->response('success', Code::SUCCESS, []); |
| @@ -141,19 +146,9 @@ class AdsController extends BaseController | @@ -141,19 +146,9 @@ class AdsController extends BaseController | ||
| 141 | ]; | 146 | ]; |
| 142 | return $this->response('success', Code::SUCCESS, $data); | 147 | return $this->response('success', Code::SUCCESS, $data); |
| 143 | } | 148 | } |
| 144 | - | ||
| 145 | - $token = md5($domain.'qqs'); | ||
| 146 | - try { | ||
| 147 | - $client = new \GuzzleHttp\Client(); | ||
| 148 | - $res = $client->request('GET', 'https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php?'.http_build_query(['token' => $token, 'domain' => $domain]), [ | ||
| 149 | - 'proxy' => env('CURL_PROXY'), // 代理服务器地址和端口号 | ||
| 150 | - ])->getBody()->getContents(); | ||
| 151 | - $res = Arr::s2a($res); | ||
| 152 | - } catch (\Exception | GuzzleException $e) { | ||
| 153 | - return $this->response('验证失败,请稍后再试!', Code::USER_ERROR, []); | ||
| 154 | - } | 149 | + $res = (new QuanqiusouApi())->getV5Agent($domain); |
| 155 | if(empty($res['status']) || $res['status'] != 200){ | 150 | if(empty($res['status']) || $res['status'] != 200){ |
| 156 | - return $this->response($res['msg'], Code::USER_ERROR, []); | 151 | + return $this->response($res['msg'] ?? '验证失败,请稍后再试!', Code::USER_ERROR, []); |
| 157 | } | 152 | } |
| 158 | 153 | ||
| 159 | $agent = implode(',', array_map(function ($v){ | 154 | $agent = implode(',', array_map(function ($v){ |
| @@ -5,9 +5,13 @@ | @@ -5,9 +5,13 @@ | ||
| 5 | * Date: 2024/9/30 | 5 | * Date: 2024/9/30 |
| 6 | * Time: 14:56 | 6 | * Time: 14:56 |
| 7 | */ | 7 | */ |
| 8 | + | ||
| 8 | namespace App\Models\Inquiry; | 9 | namespace App\Models\Inquiry; |
| 9 | 10 | ||
| 10 | use App\Helper\Arr; | 11 | use App\Helper\Arr; |
| 12 | +use App\Helper\QuanqiusouApi; | ||
| 13 | +use App\Models\Domain\DomainInfo; | ||
| 14 | +use App\Models\Project\Project; | ||
| 11 | use Illuminate\Database\Eloquent\Model; | 15 | use Illuminate\Database\Eloquent\Model; |
| 12 | 16 | ||
| 13 | /** | 17 | /** |
| @@ -23,26 +27,47 @@ class ReInquiryCount extends Model | @@ -23,26 +27,47 @@ class ReInquiryCount extends Model | ||
| 23 | */ | 27 | */ |
| 24 | protected $table = 'gl_re_inquiry_count'; | 28 | protected $table = 'gl_re_inquiry_count'; |
| 25 | 29 | ||
| 26 | - //`task_id` int(11) NOT NULL DEFAULT '0' COMMENT '转发任务ID', | ||
| 27 | - // `company` varchar(255) NOT NULL DEFAULT '', | ||
| 28 | - // `domain` varchar(200) NOT NULL DEFAULT '' COMMENT '广告名称', | ||
| 29 | - // `num` int(2) NOT NU | ||
| 30 | - public static function updateCount($task_id, $domain, $num = 0){ | ||
| 31 | - $model = self::where('domain', $domain)->first(); | ||
| 32 | - if(!$model){ | ||
| 33 | - $model = new self(); | ||
| 34 | - $model->domain = $domain; | ||
| 35 | - $model->company = | ||
| 36 | - } | ||
| 37 | - $model->task_id = | 30 | + /** |
| 31 | + * @param $task_id | ||
| 32 | + * @param $domain | ||
| 33 | + * @param int $num | ||
| 34 | + * @author zbj | ||
| 35 | + * @date 2024/10/26 | ||
| 36 | + */ | ||
| 37 | + public static function addInquiryNum($task_id, $domain, $num = 1) | ||
| 38 | + { | ||
| 39 | + $model = self::where('domain', $domain)->first(); | ||
| 40 | + | ||
| 41 | + if (!$model) { | ||
| 42 | + //新增时获取公司名 | ||
| 43 | + $company = ''; | ||
| 44 | + $domain_info = DomainInfo::where('domain', $domain)->first(); | ||
| 45 | + if ($domain_info) { | ||
| 46 | + $company = Project::where('id', $domain_info['project_id'])->value('company'); | ||
| 47 | + } else { | ||
| 48 | + $res = (new QuanqiusouApi())->getV5Agent($domain); | ||
| 49 | + if (!empty($res['status']) && $res['status'] == 200) { | ||
| 50 | + $company = $res['company_name']; | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + $model = new self(); | ||
| 55 | + $model->domain = $domain; | ||
| 56 | + $model->company = $company; | ||
| 57 | + } | ||
| 58 | + $model->task_ids = $model->task_ids + [$task_id]; | ||
| 59 | + $model->num = $model->num + $num; | ||
| 60 | + $model->save(); | ||
| 38 | } | 61 | } |
| 39 | 62 | ||
| 40 | - public function setTaskIdsAttribute($value){ | ||
| 41 | - $this->attributes['task_ids'] = Arr::a2s($value); | 63 | + public function setTaskIdsAttribute($value) |
| 64 | + { | ||
| 65 | + $this->attributes['task_ids'] = Arr::arrToSet($value); | ||
| 42 | } | 66 | } |
| 43 | 67 | ||
| 44 | - public function getTaskIdsAttribute($value){ | ||
| 45 | - return Arr::s2a($value); | 68 | + public function getTaskIdsAttribute($value) |
| 69 | + { | ||
| 70 | + return Arr::setToArr($value); | ||
| 46 | } | 71 | } |
| 47 | 72 | ||
| 48 | } | 73 | } |
-
请 注册 或 登录 后发表评论