|
...
|
...
|
@@ -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;
|
|
...
|
...
|
@@ -57,11 +59,14 @@ class AdsController extends BaseController |
|
|
|
->paginate($page_size);
|
|
|
|
|
|
|
|
$relay_site_total = 0;
|
|
|
|
foreach ($result as $item){
|
|
|
|
foreach ($result as &$item){
|
|
|
|
$relay_site_total += count($item->target);
|
|
|
|
$item->requiry_num = ReInquiryDetail::where('task_id', $item->id)->where('status', ReInquiryDetail::STATUS_SUCCESS)->count();
|
|
|
|
$item->form_num = ReInquiryForm::where('ad_id', $item->ad_id)->count();
|
|
|
|
}
|
|
|
|
$result = $result->toArray();
|
|
|
|
$result['relay_site_total'] = $relay_site_total;
|
|
|
|
$result['default_ai_param'] = ReInquiryTask::DEFAULT_AI_PARAM;
|
|
|
|
|
|
|
|
return $this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
...
|
...
|
@@ -81,10 +86,27 @@ class AdsController extends BaseController |
|
|
|
$ad_img = trim($request->input('ad_img'));
|
|
|
|
$num = intval($request->input('num'));
|
|
|
|
$status = intval($request->input('status'));
|
|
|
|
$is_replace_text = intval($request->input('is_replace_text'));
|
|
|
|
$ai_param = $request->input('ai_param');
|
|
|
|
if (empty($title) || empty($ad_id))
|
|
|
|
return $this->response('请填写完整信息!', Code::USER_ERROR, []);
|
|
|
|
|
|
|
|
ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status);
|
|
|
|
//AI生成
|
|
|
|
if($is_replace_text == 2){
|
|
|
|
if(empty($ai_param['mkeywords'])){
|
|
|
|
return $this->response('工厂关键词不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
if(empty($ai_param['characters'])){
|
|
|
|
return $this->response('随机字符数不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
if(empty($ai_param['inkeywords'])){
|
|
|
|
return $this->response('询盘内容关键词不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
if(empty($ai_param['suoxie'])){
|
|
|
|
return $this->response('英文缩写参考不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReInquiryTask::createTask($id, $title, $industry, $ad_id, $ad_url, $ad_img, $num, $status, $is_replace_text, $ai_param);
|
|
|
|
return $this->response('success', Code::SUCCESS, []);
|
|
|
|
}
|
|
|
|
|
|
...
|
...
|
@@ -104,6 +126,7 @@ class AdsController extends BaseController |
|
|
|
if(empty($target)){
|
|
|
|
return $this->response('请添加关联网站!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
$is_require_num = 0;
|
|
|
|
foreach ($target as &$item){
|
|
|
|
if(empty($item['url'])){
|
|
|
|
return $this->response('网站域名不能为空!', Code::USER_ERROR, []);
|
|
...
|
...
|
@@ -111,7 +134,20 @@ class AdsController extends BaseController |
|
|
|
if(empty($item['agent'])){
|
|
|
|
return $this->response('代理不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
if(empty($item['agent_group'])){
|
|
|
|
return $this->response('代理商分组不能为空!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
$item['url'] = trim(str_replace(['http://', 'https://'], '', $item['url']), '/');
|
|
|
|
if(!empty($item['is_require'])){
|
|
|
|
$is_require_num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if($is_require_num > $task->num){
|
|
|
|
return $this->response('必选渠道不能大于转发数量!', Code::USER_ERROR, []);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($target as $v){
|
|
|
|
ReInquiryCount::addInquiryNum($id, $v['url'], 0);
|
|
|
|
}
|
|
|
|
$task->target = json_encode($target);
|
|
|
|
$task->save();
|
|
...
|
...
|
@@ -129,28 +165,28 @@ class AdsController extends BaseController |
|
|
|
//是否v6
|
|
|
|
$domain_info = DomainInfo::where('domain', $domain)->first();
|
|
|
|
if($domain_info){
|
|
|
|
$channel = Project::where('id', $domain_info['project_id'])->value('channel');
|
|
|
|
$channel = Project::where('id', $domain_info['project_id'])->where('delete_status', 0)->value('channel');
|
|
|
|
if($channel){
|
|
|
|
$data = [
|
|
|
|
'is_v6' => 1,
|
|
|
|
'agent' => Channel::getChannelText($channel['user_id']??0),
|
|
|
|
'agent' => trim(explode('-', Channel::getChannelText($channel['user_id']??0))[0]),
|
|
|
|
'domain' => $domain,
|
|
|
|
];
|
|
|
|
return $this->response('success', Code::SUCCESS, $data);
|
|
|
|
}
|
|
|
|
|
|
|
|
$token = md5($domain.'qqs');
|
|
|
|
try {
|
|
|
|
$res = HttpUtils::get('https://quanqiusou.cn/extend_api/api/get_agent_by_domain.php', ['token' => $token, 'domain' => $domain]);
|
|
|
|
$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){
|
|
|
|
return trim(explode('-', $v)[0]);
|
|
|
|
}, explode(',', $res['data'] ?? '')));
|
|
|
|
|
|
|
|
$data = [
|
|
|
|
'is_v6' => 0,
|
|
|
|
'agent' => $res['data'],
|
|
|
|
'agent' => $agent,
|
|
|
|
'domain' => $domain,
|
|
|
|
];
|
|
|
|
return $this->response('success', Code::SUCCESS, $data);
|
|
...
|
...
|
@@ -214,4 +250,34 @@ class AdsController extends BaseController |
|
|
|
->paginate();
|
|
|
|
return $this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fbRelayCount(Request $request){
|
|
|
|
$task_id = intval($request->input('task_id'));
|
|
|
|
$domain = trim($request->input('domain'));
|
|
|
|
$company = trim($request->input('company'));
|
|
|
|
$operator = trim($request->input('operator'));
|
|
|
|
$num = intval($request->input('num'));
|
|
|
|
$row = intval($request->input('row', 20));
|
|
|
|
|
|
|
|
$result = ReInquiryCount::when($task_id, function ($query, $task_id) {
|
|
|
|
return $query->WhereRaw("FIND_IN_SET({$task_id}, `task_ids`)");
|
|
|
|
})
|
|
|
|
->when($domain, function ($query, $domain) {
|
|
|
|
return $query->where('domain', 'like', '%'.$domain.'%');
|
|
|
|
})
|
|
|
|
->when($company, function ($query, $company) {
|
|
|
|
return $query->where('company', 'like', '%'.$company.'%');
|
|
|
|
})
|
|
|
|
->when($num, function ($query) use($num, $operator) {
|
|
|
|
return $query->where('num', $operator?:'=', $num);
|
|
|
|
})
|
|
|
|
->orderBy('num', 'desc')
|
|
|
|
->paginate($row);
|
|
|
|
|
|
|
|
foreach ($result as $item){
|
|
|
|
$item->tasks = $item->tasks; //调用访问器
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->response('success', Code::SUCCESS, $result);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|