|
...
|
...
|
@@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside\Optimize; |
|
|
|
use App\Http\Logic\Aside\BaseLogic;
|
|
|
|
use App\Models\Inquiry\InquiryInfo;
|
|
|
|
use App\Models\Inquiry\InquiryProject;
|
|
|
|
use App\Models\Inquiry\InquiryProjectRoute;
|
|
|
|
use App\Models\Inquiry\InquiryRelayDetail;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
...
|
...
|
@@ -113,4 +114,84 @@ class InquiryForwardLogic extends BaseLogic |
|
|
|
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取随机ip
|
|
|
|
* @return array
|
|
|
|
* @throws \App\Exceptions\AsideGlobalException
|
|
|
|
* @throws \App\Exceptions\BsideGlobalException
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/02/26 15:50
|
|
|
|
*/
|
|
|
|
public function getIp()
|
|
|
|
{
|
|
|
|
$ip = DB::table('gl_xunpan_ipdata')->where('ip_area', $this->param['country'])->inRandomOrder()->value('ip');
|
|
|
|
if (!$ip) {
|
|
|
|
$this->fail('当前国家无法获取随机ip');
|
|
|
|
}
|
|
|
|
|
|
|
|
return $this->success(['ip' => $ip]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 关键词查询项目着陆页
|
|
|
|
* @return int|mixed
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/02/26 17:13
|
|
|
|
*/
|
|
|
|
public function searchKeywords()
|
|
|
|
{
|
|
|
|
$num = $this->param['num'] ?? 3;
|
|
|
|
|
|
|
|
$model = new InquiryProjectRoute();
|
|
|
|
if ($this->param['type'] == 1) {
|
|
|
|
//使用全文索引搜索
|
|
|
|
$routeQuery = $model->select(['project_id', 'route'])->whereRaw("MATCH(title) AGAINST(? IN BOOLEAN MODE)", [$this->param['keywords']]);
|
|
|
|
} else {
|
|
|
|
//使用like查询
|
|
|
|
$routeQuery = $model->select(['project_id', 'route'])->where('title', 'like', '%' . $this->param['keywords'] . '%');
|
|
|
|
}
|
|
|
|
|
|
|
|
$re_route = $routeQuery->inRandomOrder()->take(100)->get()->toArray();
|
|
|
|
|
|
|
|
$lists = [];
|
|
|
|
if (count($re_route) > 0) {
|
|
|
|
$project_ids = array_column($re_route, 'project_id');
|
|
|
|
$re_project = InquiryProject::select(['id', 'project', 'channel', 'domain'])->whereIn('id', $project_ids)->orderBy('recent_inquiry', 'asc')->get();
|
|
|
|
|
|
|
|
if ($re_project->count() > 0) {
|
|
|
|
//根据代理商去重
|
|
|
|
$channel = [];
|
|
|
|
foreach ($re_project as $vp) {
|
|
|
|
$vp_channel = explode(',', $vp->channel);
|
|
|
|
$has_channel = 0;
|
|
|
|
foreach ($vp_channel as $vpc) {
|
|
|
|
if (in_array($vpc, $channel)) {
|
|
|
|
$has_channel = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($has_channel == 0) {
|
|
|
|
$channel = array_merge($channel, $vp_channel);
|
|
|
|
|
|
|
|
$route = '';
|
|
|
|
foreach ($re_route as $vr) {
|
|
|
|
if ($vr['project_id'] == $vp->id) {
|
|
|
|
$route = $vr['route'];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$lists[] = [
|
|
|
|
'id' => $vp->id,
|
|
|
|
'project' => $vp->project,
|
|
|
|
'domain' => $vp->domain,
|
|
|
|
'route' => $route
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return array_slice($lists, 0, $num, true);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|