正在显示
3 个修改的文件
包含
128 行增加
和
4 行删除
| @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize; | @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Aside\Optimize; | ||
| 5 | use App\Enums\Common\Code; | 5 | use App\Enums\Common\Code; |
| 6 | use App\Http\Controllers\Aside\BaseController; | 6 | use App\Http\Controllers\Aside\BaseController; |
| 7 | use App\Http\Logic\Aside\Optimize\InquiryForwardLogic; | 7 | use App\Http\Logic\Aside\Optimize\InquiryForwardLogic; |
| 8 | +use Illuminate\Support\Facades\DB; | ||
| 8 | 9 | ||
| 9 | class InquiryForwardController extends BaseController | 10 | class InquiryForwardController extends BaseController |
| 10 | { | 11 | { |
| @@ -40,8 +41,8 @@ class InquiryForwardController extends BaseController | @@ -40,8 +41,8 @@ class InquiryForwardController extends BaseController | ||
| 40 | */ | 41 | */ |
| 41 | public function getInquiryType(InquiryForwardLogic $inquiryForwardLogic) | 42 | public function getInquiryType(InquiryForwardLogic $inquiryForwardLogic) |
| 42 | { | 43 | { |
| 43 | - $list = $inquiryForwardLogic->getType(); | ||
| 44 | - $this->response('success', Code::SUCCESS, $list); | 44 | + $lists = $inquiryForwardLogic->getType(); |
| 45 | + $this->response('success', Code::SUCCESS, $lists); | ||
| 45 | } | 46 | } |
| 46 | 47 | ||
| 47 | /** | 48 | /** |
| @@ -88,4 +89,44 @@ class InquiryForwardController extends BaseController | @@ -88,4 +89,44 @@ class InquiryForwardController extends BaseController | ||
| 88 | 'inquiry_date.required' => '发送时间不能为空', | 89 | 'inquiry_date.required' => '发送时间不能为空', |
| 89 | ]); | 90 | ]); |
| 90 | } | 91 | } |
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 根据国家获取随机ip | ||
| 95 | + * @param InquiryForwardLogic $inquiryForwardLogic | ||
| 96 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 97 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 98 | + * @author Akun | ||
| 99 | + * @date 2025/02/26 15:50 | ||
| 100 | + */ | ||
| 101 | + public function getInquiryIp(InquiryForwardLogic $inquiryForwardLogic) | ||
| 102 | + { | ||
| 103 | + $this->request->validate([ | ||
| 104 | + 'country' => 'required', | ||
| 105 | + ], [ | ||
| 106 | + 'country.required' => '国家不能为空', | ||
| 107 | + ]); | ||
| 108 | + | ||
| 109 | + $data = $inquiryForwardLogic->getIp(); | ||
| 110 | + $this->response('success', Code::SUCCESS, $data); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + /** | ||
| 114 | + * 关键词查询项目着陆页 | ||
| 115 | + * @param InquiryForwardLogic $inquiryForwardLogic | ||
| 116 | + * @author Akun | ||
| 117 | + * @date 2025/02/26 17:12 | ||
| 118 | + */ | ||
| 119 | + public function searchInquiryKeywords(InquiryForwardLogic $inquiryForwardLogic) | ||
| 120 | + { | ||
| 121 | + $this->request->validate([ | ||
| 122 | + 'keywords' => 'required', | ||
| 123 | + 'type' => 'required', | ||
| 124 | + ], [ | ||
| 125 | + 'keywords.required' => '关键词不能为空', | ||
| 126 | + 'type.required' => '搜索类型不能为空', | ||
| 127 | + ]); | ||
| 128 | + | ||
| 129 | + $lists = $inquiryForwardLogic->searchKeywords(); | ||
| 130 | + $this->response('success', Code::SUCCESS, $lists); | ||
| 131 | + } | ||
| 91 | } | 132 | } |
| @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside\Optimize; | @@ -5,6 +5,7 @@ namespace App\Http\Logic\Aside\Optimize; | ||
| 5 | use App\Http\Logic\Aside\BaseLogic; | 5 | use App\Http\Logic\Aside\BaseLogic; |
| 6 | use App\Models\Inquiry\InquiryInfo; | 6 | use App\Models\Inquiry\InquiryInfo; |
| 7 | use App\Models\Inquiry\InquiryProject; | 7 | use App\Models\Inquiry\InquiryProject; |
| 8 | +use App\Models\Inquiry\InquiryProjectRoute; | ||
| 8 | use App\Models\Inquiry\InquiryRelayDetail; | 9 | use App\Models\Inquiry\InquiryRelayDetail; |
| 9 | use Illuminate\Support\Facades\DB; | 10 | use Illuminate\Support\Facades\DB; |
| 10 | use Illuminate\Support\Facades\Log; | 11 | use Illuminate\Support\Facades\Log; |
| @@ -113,4 +114,84 @@ class InquiryForwardLogic extends BaseLogic | @@ -113,4 +114,84 @@ class InquiryForwardLogic extends BaseLogic | ||
| 113 | 114 | ||
| 114 | return $this->success(); | 115 | return $this->success(); |
| 115 | } | 116 | } |
| 117 | + | ||
| 118 | + /** | ||
| 119 | + * 获取随机ip | ||
| 120 | + * @return array | ||
| 121 | + * @throws \App\Exceptions\AsideGlobalException | ||
| 122 | + * @throws \App\Exceptions\BsideGlobalException | ||
| 123 | + * @author Akun | ||
| 124 | + * @date 2025/02/26 15:50 | ||
| 125 | + */ | ||
| 126 | + public function getIp() | ||
| 127 | + { | ||
| 128 | + $ip = DB::table('gl_xunpan_ipdata')->where('ip_area', $this->param['country'])->inRandomOrder()->value('ip'); | ||
| 129 | + if (!$ip) { | ||
| 130 | + $this->fail('当前国家无法获取随机ip'); | ||
| 131 | + } | ||
| 132 | + | ||
| 133 | + return $this->success(['ip' => $ip]); | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + /** | ||
| 137 | + * 关键词查询项目着陆页 | ||
| 138 | + * @return int|mixed | ||
| 139 | + * @author Akun | ||
| 140 | + * @date 2025/02/26 17:13 | ||
| 141 | + */ | ||
| 142 | + public function searchKeywords() | ||
| 143 | + { | ||
| 144 | + $num = $this->param['num'] ?? 3; | ||
| 145 | + | ||
| 146 | + $model = new InquiryProjectRoute(); | ||
| 147 | + if ($this->param['type'] == 1) { | ||
| 148 | + //使用全文索引搜索 | ||
| 149 | + $routeQuery = $model->select(['project_id', 'route'])->whereRaw("MATCH(title) AGAINST(? IN BOOLEAN MODE)", [$this->param['keywords']]); | ||
| 150 | + } else { | ||
| 151 | + //使用like查询 | ||
| 152 | + $routeQuery = $model->select(['project_id', 'route'])->where('title', 'like', '%' . $this->param['keywords'] . '%'); | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + $re_route = $routeQuery->inRandomOrder()->take(100)->get()->toArray(); | ||
| 156 | + | ||
| 157 | + $lists = []; | ||
| 158 | + if (count($re_route) > 0) { | ||
| 159 | + $project_ids = array_column($re_route, 'project_id'); | ||
| 160 | + $re_project = InquiryProject::select(['id', 'project', 'channel', 'domain'])->whereIn('id', $project_ids)->orderBy('recent_inquiry', 'asc')->get(); | ||
| 161 | + | ||
| 162 | + if ($re_project->count() > 0) { | ||
| 163 | + //根据代理商去重 | ||
| 164 | + $channel = []; | ||
| 165 | + foreach ($re_project as $vp) { | ||
| 166 | + $vp_channel = explode(',', $vp->channel); | ||
| 167 | + $has_channel = 0; | ||
| 168 | + foreach ($vp_channel as $vpc) { | ||
| 169 | + if (in_array($vpc, $channel)) { | ||
| 170 | + $has_channel = 1; | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + if ($has_channel == 0) { | ||
| 175 | + $channel = array_merge($channel, $vp_channel); | ||
| 176 | + | ||
| 177 | + $route = ''; | ||
| 178 | + foreach ($re_route as $vr) { | ||
| 179 | + if ($vr['project_id'] == $vp->id) { | ||
| 180 | + $route = $vr['route']; | ||
| 181 | + break; | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + $lists[] = [ | ||
| 185 | + 'id' => $vp->id, | ||
| 186 | + 'project' => $vp->project, | ||
| 187 | + 'domain' => $vp->domain, | ||
| 188 | + 'route' => $route | ||
| 189 | + ]; | ||
| 190 | + } | ||
| 191 | + } | ||
| 192 | + } | ||
| 193 | + } | ||
| 194 | + | ||
| 195 | + return array_slice($lists, 0, $num, true); | ||
| 196 | + } | ||
| 116 | } | 197 | } |
| @@ -343,8 +343,10 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -343,8 +343,10 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 343 | //手动转发询盘 | 343 | //手动转发询盘 |
| 344 | Route::prefix('inquiry_forward')->group(function () { | 344 | Route::prefix('inquiry_forward')->group(function () { |
| 345 | Route::any('/', [Aside\Optimize\InquiryForwardController::class, 'lists'])->name('admin.inquiry_lists'); | 345 | Route::any('/', [Aside\Optimize\InquiryForwardController::class, 'lists'])->name('admin.inquiry_lists'); |
| 346 | - Route::any('/getInquiryType', [Aside\Optimize\InquiryForwardController::class, 'getInquiryType'])->name('admin.inquiry_getInquiryType'); | ||
| 347 | - Route::any('/forwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'forwardInquiry'])->name('admin.inquiry_forwardInquiry'); | 346 | + Route::any('/getInquiryType', [Aside\Optimize\InquiryForwardController::class, 'getInquiryType'])->name('admin.inquiry_forward_getInquiryType'); |
| 347 | + Route::any('/forwardInquiry', [Aside\Optimize\InquiryForwardController::class, 'forwardInquiry'])->name('admin.inquiry_forward_forwardInquiry'); | ||
| 348 | + Route::any('/getInquiryIp', [Aside\Optimize\InquiryForwardController::class, 'getInquiryIp'])->name('admin.inquiry_forward_getInquiryIp'); | ||
| 349 | + Route::any('/searchInquiryKeywords', [Aside\Optimize\InquiryForwardController::class, 'searchInquiryKeywords'])->name('admin.inquiry_forward_searchInquiryKeywords'); | ||
| 348 | }); | 350 | }); |
| 349 | 351 | ||
| 350 | Route::prefix('custom_module')->group(function () { | 352 | Route::prefix('custom_module')->group(function () { |
-
请 注册 或 登录 后发表评论