正在显示
7 个修改的文件
包含
150 行增加
和
1 行删除
| @@ -791,3 +791,14 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){ | @@ -791,3 +791,14 @@ function check_remote_url_down($url,$project_id,$domain,$is_complete=0){ | ||
| 791 | return false; | 791 | return false; |
| 792 | } | 792 | } |
| 793 | } | 793 | } |
| 794 | + | ||
| 795 | +/** | ||
| 796 | + * 文本框转内容数组 | ||
| 797 | + * @author zbj | ||
| 798 | + * @date 2024/3/29 | ||
| 799 | + */ | ||
| 800 | +function textareaToArr($content, $separator = ','){ | ||
| 801 | + return array_values(array_filter(array_unique(array_map(function ($v){ | ||
| 802 | + return trim($v); | ||
| 803 | + },explode($separator, $content))))); | ||
| 804 | +} |
| @@ -952,4 +952,21 @@ class ProjectController extends BaseController | @@ -952,4 +952,21 @@ class ProjectController extends BaseController | ||
| 952 | $logic->saveInquiryFilterConfig($this->param); | 952 | $logic->saveInquiryFilterConfig($this->param); |
| 953 | $this->response('success'); | 953 | $this->response('success'); |
| 954 | } | 954 | } |
| 955 | + | ||
| 956 | + /** | ||
| 957 | + * 保存引流设置 | ||
| 958 | + * @author zbj | ||
| 959 | + * @date 2024/3/29 | ||
| 960 | + */ | ||
| 961 | + public function saveWebTrafficConfig(ProjectLogic $logic){ | ||
| 962 | + $this->request->validate([ | ||
| 963 | + 'project_id'=>'required', | ||
| 964 | + ],[ | ||
| 965 | + 'project_id.required' => '项目id不能为空', | ||
| 966 | + ]); | ||
| 967 | + $logic->saveWebTrafficConfig($this->param); | ||
| 968 | + $this->response('success'); | ||
| 969 | + } | ||
| 970 | + | ||
| 971 | + | ||
| 955 | } | 972 | } |
| @@ -11,9 +11,11 @@ use App\Jobs\CopyProjectJob; | @@ -11,9 +11,11 @@ use App\Jobs\CopyProjectJob; | ||
| 11 | use App\Models\Com\NoticeLog; | 11 | use App\Models\Com\NoticeLog; |
| 12 | use App\Models\Com\UpdateLog; | 12 | use App\Models\Com\UpdateLog; |
| 13 | use App\Models\Devops\ServerConfig; | 13 | use App\Models\Devops\ServerConfig; |
| 14 | +use App\Models\Inquiry\InquiryIP; | ||
| 14 | use App\Models\Project\InquiryFilterConfig; | 15 | use App\Models\Project\InquiryFilterConfig; |
| 15 | use App\Models\Project\MinorLanguages; | 16 | use App\Models\Project\MinorLanguages; |
| 16 | use App\Models\Project\ProjectRenew; | 17 | use App\Models\Project\ProjectRenew; |
| 18 | +use App\Models\Project\WebTrafficConfig; | ||
| 17 | use App\Models\Template\Setting; | 19 | use App\Models\Template\Setting; |
| 18 | use App\Models\User\ProjectMenu; | 20 | use App\Models\User\ProjectMenu; |
| 19 | use App\Models\User\ProjectRole; | 21 | use App\Models\User\ProjectRole; |
| @@ -69,7 +71,7 @@ class ProjectLogic extends BaseLogic | @@ -69,7 +71,7 @@ class ProjectLogic extends BaseLogic | ||
| 69 | * @time :2023/7/28 17:11 | 71 | * @time :2023/7/28 17:11 |
| 70 | */ | 72 | */ |
| 71 | public function getProjectInfo($id){ | 73 | public function getProjectInfo($id){ |
| 72 | - $info = $this->model->with(['payment', 'deploy_build', 'deploy_optimize', 'online_check', 'project_after','inquiry_filter_config'])->where(['id'=>$id])->first()->toArray(); | 74 | + $info = $this->model->with(['payment', 'deploy_build', 'deploy_optimize', 'online_check', 'project_after','inquiry_filter_config','web_traffic_config'])->where(['id'=>$id])->first()->toArray(); |
| 73 | $info['online_check']['name'] = (new Manage())->getName($info['online_check']['created_manage_id'] ?? 0); | 75 | $info['online_check']['name'] = (new Manage())->getName($info['online_check']['created_manage_id'] ?? 0); |
| 74 | $info['deploy_optimize']['minor_keywords'] = !empty($info['deploy_optimize']['minor_keywords']) ? json_decode($info['deploy_optimize']['minor_keywords']) : []; | 76 | $info['deploy_optimize']['minor_keywords'] = !empty($info['deploy_optimize']['minor_keywords']) ? json_decode($info['deploy_optimize']['minor_keywords']) : []; |
| 75 | $info['init_domain'] = $this->getInitDomain($info['serve_id'])['domain']; | 77 | $info['init_domain'] = $this->getInitDomain($info['serve_id'])['domain']; |
| @@ -785,4 +787,46 @@ class ProjectLogic extends BaseLogic | @@ -785,4 +787,46 @@ class ProjectLogic extends BaseLogic | ||
| 785 | return true; | 787 | return true; |
| 786 | } | 788 | } |
| 787 | 789 | ||
| 790 | + | ||
| 791 | + /** | ||
| 792 | + * 保存引流配置 | ||
| 793 | + * @param $config | ||
| 794 | + * @return array | ||
| 795 | + * @author zbj | ||
| 796 | + * @date 2024/3/29 | ||
| 797 | + */ | ||
| 798 | + public function saveWebTrafficConfig($config){ | ||
| 799 | + $config['main_countries'] = textareaToArr($config['main_countries']); | ||
| 800 | + $config['filter_countries'] = textareaToArr($config['filter_countries']); | ||
| 801 | + | ||
| 802 | + $ip_area = InquiryIP::getIpAreas(); | ||
| 803 | + | ||
| 804 | + foreach ($config['main_countries'] as $v) { | ||
| 805 | + if (!in_array($v, $ip_area)) { | ||
| 806 | + throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); | ||
| 807 | + } | ||
| 808 | + } | ||
| 809 | + foreach ($config['filter_countries'] as $v) { | ||
| 810 | + if (!in_array($v, $ip_area)) { | ||
| 811 | + throw new AsideGlobalException(Code::SYSTEM_ERROR, '[' . $v . ']不存在,请检查后再次提交'); | ||
| 812 | + } | ||
| 813 | + } | ||
| 814 | + | ||
| 815 | + | ||
| 816 | + $config['main_countries'] = json_encode($config['main_countries']); | ||
| 817 | + $config['filter_countries'] = json_encode($config['filter_countries']); | ||
| 818 | + | ||
| 819 | + $model = WebTrafficConfig::where('project_id', $config['project_id'])->first(); | ||
| 820 | + if (!$model) { | ||
| 821 | + $model = new WebTrafficConfig(); | ||
| 822 | + $model->add($config); | ||
| 823 | + } else { | ||
| 824 | + $model->edit($config, ['project_id' => $config['project_id']]); | ||
| 825 | + } | ||
| 826 | + | ||
| 827 | + Cache::forget(WebTrafficConfig::cacheKey($config['project_id'])); | ||
| 828 | + | ||
| 829 | + return $this->success(); | ||
| 830 | + } | ||
| 831 | + | ||
| 788 | } | 832 | } |
| @@ -13,4 +13,14 @@ use App\Models\Base; | @@ -13,4 +13,14 @@ use App\Models\Base; | ||
| 13 | class InquiryIP extends Base | 13 | class InquiryIP extends Base |
| 14 | { | 14 | { |
| 15 | protected $table = 'gl_xunpan_ipdata'; | 15 | protected $table = 'gl_xunpan_ipdata'; |
| 16 | + | ||
| 17 | + | ||
| 18 | + /** | ||
| 19 | + * @return mixed | ||
| 20 | + * @author zbj | ||
| 21 | + * @date 2024/3/29 | ||
| 22 | + */ | ||
| 23 | + public static function getIpAreas(){ | ||
| 24 | + return self::groupBy('ip_area')->pluck('ip_area')->toArray(); | ||
| 25 | + } | ||
| 16 | } | 26 | } |
| @@ -239,6 +239,17 @@ class Project extends Base | @@ -239,6 +239,17 @@ class Project extends Base | ||
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | /** | 241 | /** |
| 242 | + * 引流配置 | ||
| 243 | + * @return \Illuminate\Database\Eloquent\Relations\HasOne | ||
| 244 | + * @author zbj | ||
| 245 | + * @date 2024/3/29 | ||
| 246 | + */ | ||
| 247 | + public function web_traffic_config() | ||
| 248 | + { | ||
| 249 | + return self::hasOne(WebTrafficConfig::class, 'project_id', 'id'); | ||
| 250 | + } | ||
| 251 | + | ||
| 252 | + /** | ||
| 242 | * 域名 | 253 | * 域名 |
| 243 | * @return \Illuminate\Database\Eloquent\Relations\HasOne | 254 | * @return \Illuminate\Database\Eloquent\Relations\HasOne |
| 244 | * @author zbj | 255 | * @author zbj |
app/Models/Project/WebTrafficConfig.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Models\Project; | ||
| 4 | + | ||
| 5 | +use App\Models\Base; | ||
| 6 | +use Illuminate\Support\Facades\Cache; | ||
| 7 | + | ||
| 8 | +/** | ||
| 9 | + * 引流配置 | ||
| 10 | + * Class InquiryFilterConfig | ||
| 11 | + * @package App\Models\Project | ||
| 12 | + * @author zbj | ||
| 13 | + * @date 2024/3/29 | ||
| 14 | + */ | ||
| 15 | +class WebTrafficConfig extends Base | ||
| 16 | +{ | ||
| 17 | + //设置关联表名 | ||
| 18 | + protected $table = 'gl_project_web_traffic_config'; | ||
| 19 | + | ||
| 20 | + /** | ||
| 21 | + * @param $project_id | ||
| 22 | + * @return string | ||
| 23 | + * @author zbj | ||
| 24 | + * @date 2024/1/20 | ||
| 25 | + */ | ||
| 26 | + public static function cacheKey($project_id): string | ||
| 27 | + { | ||
| 28 | + return 'project_web_traffic_config_info' . $project_id; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * @param $project_id | ||
| 33 | + * @return mixed | ||
| 34 | + * @author zbj | ||
| 35 | + * @date 2024/1/20 | ||
| 36 | + */ | ||
| 37 | + public static function getCacheInfoByProjectId($project_id){ | ||
| 38 | + $info = Cache::get(self::cacheKey($project_id)); | ||
| 39 | + if (!$info) { | ||
| 40 | + $info = self::where('project_id', $project_id)->first(); | ||
| 41 | + Cache::put(self::cacheKey($project_id), $info, 2 * 3600); | ||
| 42 | + } | ||
| 43 | + return $info; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + public function getMainCountriesAttribute($value) | ||
| 47 | + { | ||
| 48 | + return $value ? implode(',', json_decode($value, true)) : ''; | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public function getFilterCountriesAttribute($value) | ||
| 52 | + { | ||
| 53 | + return $value ? implode(',', json_decode($value, true)) : ''; | ||
| 54 | + } | ||
| 55 | +} |
| @@ -186,6 +186,7 @@ Route::middleware(['aloginauth'])->group(function () { | @@ -186,6 +186,7 @@ Route::middleware(['aloginauth'])->group(function () { | ||
| 186 | Route::any('/languageLists', [Aside\Project\ProjectController::class, 'languageLists'])->name('admin.project_languageLists');//其他项目设置 | 186 | Route::any('/languageLists', [Aside\Project\ProjectController::class, 'languageLists'])->name('admin.project_languageLists');//其他项目设置 |
| 187 | Route::any('/countryLists', [Aside\Project\ProjectController::class, 'countryLists'])->name('admin.project_countryLists');//国家地区列表 | 187 | Route::any('/countryLists', [Aside\Project\ProjectController::class, 'countryLists'])->name('admin.project_countryLists');//国家地区列表 |
| 188 | Route::any('/saveInquiryFilterConfig', [Aside\Project\ProjectController::class, 'saveInquiryFilterConfig'])->name('admin.project_inquiry_filter_config_save');//保存询盘过滤配置 | 188 | Route::any('/saveInquiryFilterConfig', [Aside\Project\ProjectController::class, 'saveInquiryFilterConfig'])->name('admin.project_inquiry_filter_config_save');//保存询盘过滤配置 |
| 189 | + Route::any('/saveWebTrafficConfig', [Aside\Project\ProjectController::class, 'saveWebTrafficConfig'])->name('admin.project_web_traffic_config_save');//保存引流配置 | ||
| 189 | //获取关键词前缀和后缀 | 190 | //获取关键词前缀和后缀 |
| 190 | Route::prefix('keyword')->group(function () { | 191 | Route::prefix('keyword')->group(function () { |
| 191 | Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix'); | 192 | Route::any('/getKeywordPrefix', [Aside\Project\KeywordPrefixController::class, 'getKeywordPrefix'])->name('admin.keyword_getKeywordPrefix'); |
-
请 注册 或 登录 后发表评论