Merge branch 'master' of http://47.244.231.31:8099/zhl/globalso-v6 into lyh-server
正在显示
6 个修改的文件
包含
81 行增加
和
3 行删除
| @@ -4,6 +4,7 @@ namespace App\Console\Commands\Sync; | @@ -4,6 +4,7 @@ namespace App\Console\Commands\Sync; | ||
| 4 | 4 | ||
| 5 | 5 | ||
| 6 | use App\Exceptions\InquiryFilterException; | 6 | use App\Exceptions\InquiryFilterException; |
| 7 | +use App\Models\Inquiry\InquiryRelateDomain; | ||
| 7 | use App\Models\Project\Project; | 8 | use App\Models\Project\Project; |
| 8 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | 9 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; |
| 9 | use App\Services\SyncSubmitTaskService; | 10 | use App\Services\SyncSubmitTaskService; |
| @@ -53,10 +54,18 @@ class SyncSubmitTask extends Command | @@ -53,10 +54,18 @@ class SyncSubmitTask extends Command | ||
| 53 | try { | 54 | try { |
| 54 | $project = Project::getProjectByDomain($task_info['data']['domain'] ?? ''); | 55 | $project = Project::getProjectByDomain($task_info['data']['domain'] ?? ''); |
| 55 | if(!$project){ | 56 | if(!$project){ |
| 56 | - throw new \Exception('项目不存在'); | 57 | + //是否有关联的域名 |
| 58 | + $relate_domain = InquiryRelateDomain::where('from_domain', $task_info['data']['domain'] ?? '')->value('to_domain'); | ||
| 59 | + if(!$relate_domain){ | ||
| 60 | + throw new \Exception('项目不存在1'); | ||
| 61 | + } | ||
| 62 | + $project = Project::getProjectByDomain($relate_domain); | ||
| 63 | + if(!$project){ | ||
| 64 | + throw new \Exception('项目不存在2'); | ||
| 65 | + } | ||
| 57 | } | 66 | } |
| 58 | $task_info->project_id = $project->id; | 67 | $task_info->project_id = $project->id; |
| 59 | - SyncSubmitTaskService::handler($task_info); | 68 | + SyncSubmitTaskService::handler($task_info, '', $relate_domain??''); |
| 60 | $task_info->status = 1; | 69 | $task_info->status = 1; |
| 61 | $task_info->save(); | 70 | $task_info->save(); |
| 62 | 71 |
| @@ -21,6 +21,8 @@ use Illuminate\Support\Facades\Cache; | @@ -21,6 +21,8 @@ use Illuminate\Support\Facades\Cache; | ||
| 21 | class BaseController extends Controller | 21 | class BaseController extends Controller |
| 22 | { | 22 | { |
| 23 | public $param; | 23 | public $param; |
| 24 | + public $request; | ||
| 25 | + | ||
| 24 | public function __construct(Request $request) | 26 | public function __construct(Request $request) |
| 25 | { | 27 | { |
| 26 | $this->request = $request; | 28 | $this->request = $request; |
| @@ -12,6 +12,7 @@ use App\Http\Logic\Bside\User\UserLoginLogic; | @@ -12,6 +12,7 @@ use App\Http\Logic\Bside\User\UserLoginLogic; | ||
| 12 | use App\Models\Ai\AiBlog; | 12 | use App\Models\Ai\AiBlog; |
| 13 | use App\Models\Blog\Blog; | 13 | use App\Models\Blog\Blog; |
| 14 | use App\Models\Domain\DomainInfo; | 14 | use App\Models\Domain\DomainInfo; |
| 15 | +use App\Models\Inquiry\InquiryRelateDomain; | ||
| 15 | use App\Models\News\News; | 16 | use App\Models\News\News; |
| 16 | use App\Models\Product\Category; | 17 | use App\Models\Product\Category; |
| 17 | use App\Models\Product\CategoryRelated; | 18 | use App\Models\Product\CategoryRelated; |
| @@ -463,4 +464,31 @@ class PrivateController extends BaseController | @@ -463,4 +464,31 @@ class PrivateController extends BaseController | ||
| 463 | $result = json_decode($json, true) ?: []; | 464 | $result = json_decode($json, true) ?: []; |
| 464 | return $this->success($result); | 465 | return $this->success($result); |
| 465 | } | 466 | } |
| 467 | + | ||
| 468 | + public function inquiry_relate_domain(Request $request){ | ||
| 469 | + $this->request->validate([ | ||
| 470 | + 'from_domain' => 'required', | ||
| 471 | + 'to_domain' => 'required', | ||
| 472 | + ]); | ||
| 473 | + $from_domain = trim($this->param['from_domain']); | ||
| 474 | + $to_domain = trim($this->param['to_domain']); | ||
| 475 | + | ||
| 476 | + $from_domain = parse_url($from_domain, PHP_URL_HOST) ?: $from_domain; | ||
| 477 | + $to_domain = parse_url($to_domain, PHP_URL_HOST) ?: $to_domain; | ||
| 478 | + | ||
| 479 | + $project = Project::getProjectByDomain($to_domain); | ||
| 480 | + if (empty($project)) { | ||
| 481 | + return $this->error('未找到被关联域名对应的项目!'); | ||
| 482 | + } | ||
| 483 | + | ||
| 484 | + $relate = InquiryRelateDomain::where('from_domain', $from_domain)->first(); | ||
| 485 | + if(!$relate){ | ||
| 486 | + $relate = new InquiryRelateDomain(); | ||
| 487 | + } | ||
| 488 | + $relate->from_domain = $from_domain; | ||
| 489 | + $relate->to_domain = $to_domain; | ||
| 490 | + $relate->save(); | ||
| 491 | + | ||
| 492 | + return $this->success($relate); | ||
| 493 | + } | ||
| 466 | } | 494 | } |
app/Models/Inquiry/InquiryRelateDomain.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Inquiry; | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +use App\Models\Base; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * Class InquiryRelateDomain | ||
| 10 | + * @package App\Models\Inquiry | ||
| 11 | + * @author zbj | ||
| 12 | + * @date 2025/4/12 | ||
| 13 | + */ | ||
| 14 | +class InquiryRelateDomain extends Base | ||
| 15 | +{ | ||
| 16 | + | ||
| 17 | + //设置关联表名 | ||
| 18 | + protected $table = 'gl_inquiry_relate_domain'; | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +} |
| @@ -42,9 +42,24 @@ class SyncSubmitTaskService | @@ -42,9 +42,24 @@ class SyncSubmitTaskService | ||
| 42 | * @author zbj | 42 | * @author zbj |
| 43 | * @date 2023/11/28 | 43 | * @date 2023/11/28 |
| 44 | */ | 44 | */ |
| 45 | - public static function handler($task, $date = '') | 45 | + public static function handler($task, $date = '', $relate_domain = '') |
| 46 | { | 46 | { |
| 47 | $data = $task['data']; | 47 | $data = $task['data']; |
| 48 | + | ||
| 49 | + //有关联域名 替换原数据url | ||
| 50 | + if($relate_domain){ | ||
| 51 | + $domain = $data['domain']; | ||
| 52 | + foreach ($data as $k=>&$item){ | ||
| 53 | + if($k == 'data'){ | ||
| 54 | + foreach ($item as &$v){ | ||
| 55 | + $v = str_replace($domain, $relate_domain, $v); | ||
| 56 | + } | ||
| 57 | + }else{ | ||
| 58 | + $item = str_replace($domain, $relate_domain, $item); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + } | ||
| 62 | + | ||
| 48 | $checkIpCountry = self::checkIpCountry($data['domain'], $data['ip'], $task['type']); | 63 | $checkIpCountry = self::checkIpCountry($data['domain'], $data['ip'], $task['type']); |
| 49 | 64 | ||
| 50 | $data['ip'] = $checkIpCountry['ip']; | 65 | $data['ip'] = $checkIpCountry['ip']; |
| @@ -68,4 +68,7 @@ Route::post('selfSiteVerify', [\App\Http\Controllers\Api\SelfSiteController::cla | @@ -68,4 +68,7 @@ Route::post('selfSiteVerify', [\App\Http\Controllers\Api\SelfSiteController::cla | ||
| 68 | //创建301跳转任务 | 68 | //创建301跳转任务 |
| 69 | Route::any('/addRedirect',[\App\Http\Controllers\Api\NoticeController::class,'addRedirect']); | 69 | Route::any('/addRedirect',[\App\Http\Controllers\Api\NoticeController::class,'addRedirect']); |
| 70 | 70 | ||
| 71 | +//关联域名 | ||
| 72 | +Route::post('/inquiry_relate_domain', [\App\Http\Controllers\Api\PrivateController::class, 'inquiry_relate_domain']); | ||
| 73 | + | ||
| 71 | 74 |
-
请 注册 或 登录 后发表评论