Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate
正在显示
14 个修改的文件
包含
201 行增加
和
29 行删除
| @@ -84,6 +84,10 @@ class ProjectImport extends Command | @@ -84,6 +84,10 @@ class ProjectImport extends Command | ||
| 84 | 'http' => [ | 84 | 'http' => [ |
| 85 | 'method' => 'GET', | 85 | 'method' => 'GET', |
| 86 | 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' | 86 | 'header' => 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246' |
| 87 | + ], | ||
| 88 | + 'ssl' => [ | ||
| 89 | + 'verify_peer' => false, | ||
| 90 | + 'verify_peer_name' => false | ||
| 87 | ] | 91 | ] |
| 88 | ]; | 92 | ]; |
| 89 | $file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts)); | 93 | $file_handle = fopen($task->file_url, 'r', null, stream_context_create($opts)); |
| @@ -7,7 +7,9 @@ use App\Exceptions\InquiryFilterException; | @@ -7,7 +7,9 @@ use App\Exceptions\InquiryFilterException; | ||
| 7 | use App\Services\SyncSubmitTaskService; | 7 | use App\Services\SyncSubmitTaskService; |
| 8 | use Illuminate\Console\Command; | 8 | use Illuminate\Console\Command; |
| 9 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; | 9 | use App\Models\SyncSubmitTask\SyncSubmitTask as SyncSubmitTaskModel; |
| 10 | +use Illuminate\Support\Facades\DB; | ||
| 10 | use Illuminate\Support\Facades\Redis; | 11 | use Illuminate\Support\Facades\Redis; |
| 12 | +use Illuminate\Support\Facades\Schema; | ||
| 11 | use Illuminate\Support\Str; | 13 | use Illuminate\Support\Str; |
| 12 | 14 | ||
| 13 | /** | 15 | /** |
| @@ -25,9 +27,17 @@ class SyncSubmitTask extends Command | @@ -25,9 +27,17 @@ class SyncSubmitTask extends Command | ||
| 25 | 27 | ||
| 26 | public function handle() | 28 | public function handle() |
| 27 | { | 29 | { |
| 30 | + $backup = false; | ||
| 28 | while (true) { | 31 | while (true) { |
| 29 | $task_id = $this->getTaskId(); | 32 | $task_id = $this->getTaskId(); |
| 33 | + if ($task_id > 2000000) { | ||
| 34 | + $backup = true; | ||
| 35 | + } | ||
| 30 | if (empty($task_id)) { | 36 | if (empty($task_id)) { |
| 37 | + if ($backup) { | ||
| 38 | + $this->backup(); | ||
| 39 | + $backup = false; | ||
| 40 | + } | ||
| 31 | sleep(5); | 41 | sleep(5); |
| 32 | continue; | 42 | continue; |
| 33 | } | 43 | } |
| @@ -43,7 +53,7 @@ class SyncSubmitTask extends Command | @@ -43,7 +53,7 @@ class SyncSubmitTask extends Command | ||
| 43 | $task_info->save(); | 53 | $task_info->save(); |
| 44 | 54 | ||
| 45 | $this->output('任务完成'); | 55 | $this->output('任务完成'); |
| 46 | - } catch (InquiryFilterException $e){ | 56 | + } catch (InquiryFilterException $e) { |
| 47 | $task_info->status = 1; | 57 | $task_info->status = 1; |
| 48 | $task_info->is_filtered = 1; | 58 | $task_info->is_filtered = 1; |
| 49 | $task_info->remark = $e->getMessage(); | 59 | $task_info->remark = $e->getMessage(); |
| @@ -65,11 +75,12 @@ class SyncSubmitTask extends Command | @@ -65,11 +75,12 @@ class SyncSubmitTask extends Command | ||
| 65 | } | 75 | } |
| 66 | } | 76 | } |
| 67 | 77 | ||
| 68 | - public function getTaskId(){ | 78 | + public function getTaskId() |
| 79 | + { | ||
| 69 | $task_id = Redis::rpop('sync_submit_task'); | 80 | $task_id = Redis::rpop('sync_submit_task'); |
| 70 | if (empty($task_id)) { | 81 | if (empty($task_id)) { |
| 71 | - $ids = SyncSubmitTaskModel::where('status', 0)->pluck('id'); | ||
| 72 | - foreach($ids as $id){ | 82 | + $ids = SyncSubmitTaskModel::where('status', 0)->limit(100)->pluck('id'); |
| 83 | + foreach ($ids as $id) { | ||
| 73 | Redis::lpush('sync_submit_task', $id); | 84 | Redis::lpush('sync_submit_task', $id); |
| 74 | } | 85 | } |
| 75 | $task_id = Redis::rpop('sync_submit_task'); | 86 | $task_id = Redis::rpop('sync_submit_task'); |
| @@ -86,4 +97,30 @@ class SyncSubmitTask extends Command | @@ -86,4 +97,30 @@ class SyncSubmitTask extends Command | ||
| 86 | return true; | 97 | return true; |
| 87 | } | 98 | } |
| 88 | 99 | ||
| 100 | + /** | ||
| 101 | + * 备份数据 | ||
| 102 | + * @author zbj | ||
| 103 | + * @date 2024/1/23 | ||
| 104 | + */ | ||
| 105 | + public function backup() | ||
| 106 | + { | ||
| 107 | + DB::beginTransaction(); | ||
| 108 | + try { | ||
| 109 | + $table = (new SyncSubmitTaskModel())->getTable(); | ||
| 110 | + $new_table = $table . '_backup_' . date('Ymd'); | ||
| 111 | + | ||
| 112 | + //重命名当前表 | ||
| 113 | + Schema::rename($table, $new_table); | ||
| 114 | + //克隆表数据 | ||
| 115 | + DB::statement('CREATE TABLE ' . $table . ' LIKE ' . $new_table); | ||
| 116 | + | ||
| 117 | + DB::commit(); | ||
| 118 | + | ||
| 119 | + $this->output('数据备份成功'); | ||
| 120 | + } catch (\Exception $e) { | ||
| 121 | + $this->output('数据备份失败' . $e->getMessage()); | ||
| 122 | + DB::rollBack(); | ||
| 123 | + } | ||
| 124 | + return true; | ||
| 125 | + } | ||
| 89 | } | 126 | } |
| @@ -55,7 +55,7 @@ class UpdateRoute extends Command | @@ -55,7 +55,7 @@ class UpdateRoute extends Command | ||
| 55 | */ | 55 | */ |
| 56 | public function handle(){ | 56 | public function handle(){ |
| 57 | $projectModel = new Project(); | 57 | $projectModel = new Project(); |
| 58 | - $list = $projectModel->list(['id'=>433]); | 58 | + $list = $projectModel->list(['id'=>627]); |
| 59 | $data = []; | 59 | $data = []; |
| 60 | foreach ($list as $v){ | 60 | foreach ($list as $v){ |
| 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; | 61 | echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; |
| @@ -116,6 +116,7 @@ class UpdateRoute extends Command | @@ -116,6 +116,7 @@ class UpdateRoute extends Command | ||
| 116 | if(!empty($v['route'])){ | 116 | if(!empty($v['route'])){ |
| 117 | $tag = "-tag"; | 117 | $tag = "-tag"; |
| 118 | if (!(substr($v['route'], -strlen($tag)) === $tag)) { | 118 | if (!(substr($v['route'], -strlen($tag)) === $tag)) { |
| 119 | + echo date('Y-m-d H:i:s') . '拼接 :'.$v['id'] . PHP_EOL; | ||
| 119 | // $route = Translate::tran($v['route'], 'en').$tag; | 120 | // $route = Translate::tran($v['route'], 'en').$tag; |
| 120 | // 如果不是以 '-tag' 结尾,则拼接上 '-tag' | 121 | // 如果不是以 '-tag' 结尾,则拼接上 '-tag' |
| 121 | $route = $v['route'].$tag; | 122 | $route = $v['route'].$tag; |
| @@ -33,7 +33,11 @@ class CustomModuleController extends BaseController | @@ -33,7 +33,11 @@ class CustomModuleController extends BaseController | ||
| 33 | * @time :2023/12/4 15:43 | 33 | * @time :2023/12/4 15:43 |
| 34 | */ | 34 | */ |
| 35 | public function lists(){ | 35 | public function lists(){ |
| 36 | - ProjectServer::useProject($this->param['project_id']); | 36 | + |
| 37 | + $result = ProjectServer::useProject($this->param['project_id']); | ||
| 38 | + if($result === false){ | ||
| 39 | + $this->response('success'); | ||
| 40 | + } | ||
| 37 | $customModule = new CustomModule(); | 41 | $customModule = new CustomModule(); |
| 38 | $this->map['status'] = 0; | 42 | $this->map['status'] = 0; |
| 39 | $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order = ['topping_time','sort','id']); | 43 | $lists = $customModule->lists($this->map,$this->page,$this->row,$this->order = ['topping_time','sort','id']); |
| @@ -184,7 +184,7 @@ class OptimizeController extends BaseController | @@ -184,7 +184,7 @@ class OptimizeController extends BaseController | ||
| 184 | if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){ | 184 | if(isset($this->map['online_updated_at']) && !empty($this->map['online_updated_at'])){ |
| 185 | $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); | 185 | $query = $query->whereBetween('gl_project_deploy_optimize.updated_at', $this->map['online_updated_at']); |
| 186 | } | 186 | } |
| 187 | - if(isset($this->map['special']) && !empty($this->map['special'])){ | 187 | + if(isset($this->map['special'])){ |
| 188 | $query = $query->where('gl_project_deploy_optimize.special','like','%'.$this->map['special'].'%'); | 188 | $query = $query->where('gl_project_deploy_optimize.special','like','%'.$this->map['special'].'%'); |
| 189 | } | 189 | } |
| 190 | if(isset($this->map['manager_mid']) && !empty($this->map['manager_mid'])){ | 190 | if(isset($this->map['manager_mid']) && !empty($this->map['manager_mid'])){ |
| @@ -193,7 +193,7 @@ class OptimizeController extends BaseController | @@ -193,7 +193,7 @@ class OptimizeController extends BaseController | ||
| 193 | if(isset($this->map['optimize_manager_mid']) && !empty($this->map['optimize_manager_mid'])){ | 193 | if(isset($this->map['optimize_manager_mid']) && !empty($this->map['optimize_manager_mid'])){ |
| 194 | $query = $query->where('gl_project_deploy_optimize.manager_mid','like','%'.$this->map['optimize_manager_mid'].'%'); | 194 | $query = $query->where('gl_project_deploy_optimize.manager_mid','like','%'.$this->map['optimize_manager_mid'].'%'); |
| 195 | } | 195 | } |
| 196 | - if(isset($this->map['is_upgrade']) && !empty($this->map['is_upgrade'])){ | 196 | + if(isset($this->map['is_upgrade'])){ |
| 197 | $query = $query->where('gl_project.is_upgrade',$this->map['is_upgrade']); | 197 | $query = $query->where('gl_project.is_upgrade',$this->map['is_upgrade']); |
| 198 | } | 198 | } |
| 199 | if(isset($this->map['optimize_tech_mid']) && !empty($this->map['optimize_tech_mid'])){ | 199 | if(isset($this->map['optimize_tech_mid']) && !empty($this->map['optimize_tech_mid'])){ |
| @@ -70,4 +70,21 @@ class ExtendController extends BaseController | @@ -70,4 +70,21 @@ class ExtendController extends BaseController | ||
| 70 | $extendLogic->extendDel(); | 70 | $extendLogic->extendDel(); |
| 71 | $this->response('success'); | 71 | $this->response('success'); |
| 72 | } | 72 | } |
| 73 | + | ||
| 74 | + | ||
| 75 | + /** | ||
| 76 | + * 可搜索的字段列表 | ||
| 77 | + * @author zbj | ||
| 78 | + * @date 2024/1/22 | ||
| 79 | + */ | ||
| 80 | + public function search_filed(){ | ||
| 81 | + $map = [ | ||
| 82 | + 'title' => '产品标题', | ||
| 83 | + 'intro' => '短描述', | ||
| 84 | + ]; | ||
| 85 | + //文本框类型扩展字段 | ||
| 86 | + $extends = Extend::where('type', 1)->pluck('title', 'key')->toArray(); | ||
| 87 | + $data = array_merge($map, $extends); | ||
| 88 | + $this->response('success',Code::SUCCESS,$data); | ||
| 89 | + } | ||
| 73 | } | 90 | } |
| @@ -243,10 +243,8 @@ class ProductController extends BaseController | @@ -243,10 +243,8 @@ class ProductController extends BaseController | ||
| 243 | }else{ | 243 | }else{ |
| 244 | $v['status_text'] = ''; | 244 | $v['status_text'] = ''; |
| 245 | } | 245 | } |
| 246 | - //获取当前用户选择的模版 | ||
| 247 | - $v['video'] = json_decode($v['video'] ?? ''); | ||
| 248 | $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL); | 246 | $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL); |
| 249 | - $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id']); | 247 | + $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_DETAIL,$template_id,$v['id'] ?? 0); |
| 250 | $v['url'] = $this->user['domain'].$v['route']; | 248 | $v['url'] = $this->user['domain'].$v['route']; |
| 251 | //获取当前数据扩展字段及值 | 249 | //获取当前数据扩展字段及值 |
| 252 | $v['extend'] = $this->getExtendInfo($v['id']); | 250 | $v['extend'] = $this->getExtendInfo($v['id']); |
| @@ -329,7 +329,8 @@ class ProjectLogic extends BaseLogic | @@ -329,7 +329,8 @@ class ProjectLogic extends BaseLogic | ||
| 329 | $config['filter_emails'] = Arr::a2s(!empty($config['filter_emails']) ? $config['filter_emails'] : []); | 329 | $config['filter_emails'] = Arr::a2s(!empty($config['filter_emails']) ? $config['filter_emails'] : []); |
| 330 | $config['filter_mobiles'] = Arr::a2s(!empty($config['filter_mobiles']) ? $config['filter_mobiles'] : []); | 330 | $config['filter_mobiles'] = Arr::a2s(!empty($config['filter_mobiles']) ? $config['filter_mobiles'] : []); |
| 331 | $config['filter_names'] = Arr::a2s(!empty($config['filter_names']) ? $config['filter_names'] : []); | 331 | $config['filter_names'] = Arr::a2s(!empty($config['filter_names']) ? $config['filter_names'] : []); |
| 332 | - | 332 | + $config['black_ips'] = $config['black_ips'] ?? ''; |
| 333 | + | ||
| 333 | $model = InquiryFilterConfig::where('project_id', $config['project_id'])->first(); | 334 | $model = InquiryFilterConfig::where('project_id', $config['project_id'])->first(); |
| 334 | if(!$model){ | 335 | if(!$model){ |
| 335 | $model = new InquiryFilterConfig(); | 336 | $model = new InquiryFilterConfig(); |
| @@ -264,38 +264,42 @@ class ProductLogic extends BaseLogic | @@ -264,38 +264,42 @@ class ProductLogic extends BaseLogic | ||
| 264 | */ | 264 | */ |
| 265 | public function handleSaveParam(&$param){ | 265 | public function handleSaveParam(&$param){ |
| 266 | //产品图 | 266 | //产品图 |
| 267 | - if(isset($param['gallery']) && !empty($param['gallery'])){ | 267 | + if(isset($param['gallery'])){ |
| 268 | foreach ($param['gallery'] as $k => $v){ | 268 | foreach ($param['gallery'] as $k => $v){ |
| 269 | $v['url'] = str_replace_url($v['url']); | 269 | $v['url'] = str_replace_url($v['url']); |
| 270 | $param['gallery'][$k] = $v; | 270 | $param['gallery'][$k] = $v; |
| 271 | } | 271 | } |
| 272 | $param['thumb'] = Arr::a2s($param['gallery'][0] ?? []); | 272 | $param['thumb'] = Arr::a2s($param['gallery'][0] ?? []); |
| 273 | $param['gallery'] = Arr::a2s($param['gallery'] ?? []); | 273 | $param['gallery'] = Arr::a2s($param['gallery'] ?? []); |
| 274 | - }else{ | ||
| 275 | - $param['gallery'] = Arr::a2s([]); | ||
| 276 | - $param['thumb'] = Arr::a2s([]); | ||
| 277 | } | 274 | } |
| 278 | - if(isset($param['video']) && !empty($param['video'])){ | 275 | + if(isset($param['files'])){ |
| 276 | + foreach ($param['files'] as $k => $v){ | ||
| 277 | + $v['url'] = str_replace_url($v['url']); | ||
| 278 | + $param['files'][$k] = $v; | ||
| 279 | + } | ||
| 280 | + $param['files'] = Arr::a2s($param['files'] ?? []); | ||
| 281 | + } | ||
| 282 | + if(isset($param['video'])){ | ||
| 283 | + foreach ($param['video'] as $k => $v){ | ||
| 284 | + $v['url'] = str_replace_url($v['url']); | ||
| 285 | + $param['video'][$k] = $v; | ||
| 286 | + } | ||
| 279 | $param['video'] = Arr::a2s($param['video'] ?? []); | 287 | $param['video'] = Arr::a2s($param['video'] ?? []); |
| 280 | - }else{ | ||
| 281 | - $param['video'] = Arr::a2s([]); | ||
| 282 | } | 288 | } |
| 283 | - $param['attrs'] = Arr::a2s($param['attrs'] ?? []); | ||
| 284 | - $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); | ||
| 285 | - if(isset($param['keyword_id']) && !empty($param['keyword_id'])){ | 289 | + if(isset($param['keyword_id'])){ |
| 286 | $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; | 290 | $param['keyword_id'] = ','.Arr::arrToSet($param['keyword_id']).','; |
| 287 | } | 291 | } |
| 292 | + $param['attrs'] = Arr::a2s($param['attrs'] ?? []); | ||
| 293 | + $param['attr_id'] = Arr::arrToSet($param['attr_id'] ?? ''); | ||
| 288 | $param['describe'] = Arr::a2s($param['describe'] ?? []); | 294 | $param['describe'] = Arr::a2s($param['describe'] ?? []); |
| 289 | $param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? ''); | 295 | $param['describe_id'] = Arr::arrToSet($param['describe_id'] ?? ''); |
| 290 | $param['seo_mate'] = Arr::a2s($param['seo_mate'] ?? ''); | 296 | $param['seo_mate'] = Arr::a2s($param['seo_mate'] ?? ''); |
| 291 | $param['related_product_id'] = Arr::arrToSet($param['related_product_id'] ?? ''); | 297 | $param['related_product_id'] = Arr::arrToSet($param['related_product_id'] ?? ''); |
| 292 | - if(isset($param['icon']) && !empty($param['icon'])){ | 298 | + if(isset($param['icon'])){ |
| 293 | foreach ($param['icon'] as $k1 => $v1){ | 299 | foreach ($param['icon'] as $k1 => $v1){ |
| 294 | $param['icon'][$k1] = str_replace_url($v1); | 300 | $param['icon'][$k1] = str_replace_url($v1); |
| 295 | } | 301 | } |
| 296 | $param['icon'] = Arr::a2s($param['icon'] ?? []); | 302 | $param['icon'] = Arr::a2s($param['icon'] ?? []); |
| 297 | - }else{ | ||
| 298 | - $param['icon'] = Arr::a2s([]); | ||
| 299 | } | 303 | } |
| 300 | $param['created_uid'] = $this->user['id']; | 304 | $param['created_uid'] = $this->user['id']; |
| 301 | return $param; | 305 | return $param; |
| @@ -37,6 +37,13 @@ class WebSettingReceivingLogic extends BaseLogic | @@ -37,6 +37,13 @@ class WebSettingReceivingLogic extends BaseLogic | ||
| 37 | try { | 37 | try { |
| 38 | $this->model->del(['project_id'=>$this->user['project_id']]); | 38 | $this->model->del(['project_id'=>$this->user['project_id']]); |
| 39 | foreach ($this->param['data'] as $k => $v){ | 39 | foreach ($this->param['data'] as $k => $v){ |
| 40 | + if($v['type'] == 2){ | ||
| 41 | + // 使用正则表达式匹配中国大陆手机号 | ||
| 42 | + $pattern = '/^1[3456789]\d{9}$/'; | ||
| 43 | + if (!preg_match($pattern, $v['values'])) { | ||
| 44 | + continue; | ||
| 45 | + } | ||
| 46 | + } | ||
| 40 | $v['project_id'] = $this->user['project_id']; | 47 | $v['project_id'] = $this->user['project_id']; |
| 41 | $v['created_at'] = date('Y-m-d H:i:s'); | 48 | $v['created_at'] = date('Y-m-d H:i:s'); |
| 42 | $v['updated_at'] = date('Y-m-d H:i:s'); | 49 | $v['updated_at'] = date('Y-m-d H:i:s'); |
| @@ -166,6 +166,46 @@ class Product extends Base | @@ -166,6 +166,46 @@ class Product extends Base | ||
| 166 | } | 166 | } |
| 167 | 167 | ||
| 168 | /** | 168 | /** |
| 169 | + * @remark :下载文件 | ||
| 170 | + * @name :getFilesAttribute | ||
| 171 | + * @author :lyh | ||
| 172 | + * @method :post | ||
| 173 | + * @time :2024/1/23 14:29 | ||
| 174 | + */ | ||
| 175 | + public function getFilesAttribute($value){ | ||
| 176 | + if(!empty($value)){ | ||
| 177 | + $value = Arr::s2a($value); | ||
| 178 | + foreach ($value as $k => $v){ | ||
| 179 | + if(!empty($v['url'])){ | ||
| 180 | + $v['url'] = getImageUrl($v['url']); | ||
| 181 | + } | ||
| 182 | + $value[$k] = $v; | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + return $value; | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + /** | ||
| 189 | + * @remark :视频 | ||
| 190 | + * @name :getVideoAttribute | ||
| 191 | + * @author :lyh | ||
| 192 | + * @method :post | ||
| 193 | + * @time :2024/1/23 14:31 | ||
| 194 | + */ | ||
| 195 | + public function getVideoAttribute($value){ | ||
| 196 | + if(!empty($value)){ | ||
| 197 | + $value = Arr::s2a($value); | ||
| 198 | + foreach ($value as $k => $v){ | ||
| 199 | + if(!empty($v['url'])){ | ||
| 200 | + $v['url'] = getImageUrl($v['url']); | ||
| 201 | + } | ||
| 202 | + $value[$k] = $v; | ||
| 203 | + } | ||
| 204 | + } | ||
| 205 | + return $value; | ||
| 206 | + } | ||
| 207 | + | ||
| 208 | + /** | ||
| 169 | * @remark :图标获取器 | 209 | * @remark :图标获取器 |
| 170 | * @name :getGalleryAttribute | 210 | * @name :getGalleryAttribute |
| 171 | * @author :lyh | 211 | * @author :lyh |
app/Services/AmazonS3Service.php
0 → 100644
| 1 | +<?php | ||
| 2 | +/** | ||
| 3 | + * @remark :上传文件与图片到亚马逊 | ||
| 4 | + * @name :AmazonS3Service.php | ||
| 5 | + * @author :lyh | ||
| 6 | + * @method :post | ||
| 7 | + * @time :2024/1/23 9:17 | ||
| 8 | + */ | ||
| 9 | + | ||
| 10 | +namespace App\Services; | ||
| 11 | + | ||
| 12 | +use Aws\S3\S3Client; | ||
| 13 | +use Aws\S3\Exception\S3Exception; | ||
| 14 | +class AmazonS3Service | ||
| 15 | +{ | ||
| 16 | + // 替换为你自己的 AWS 访问密钥、区域和存储桶名称 | ||
| 17 | + protected $s3; | ||
| 18 | + protected $accessKeyId = '';//key | ||
| 19 | + protected $secretAccessKey = '';//密匙 | ||
| 20 | + protected $region = '';//地址 | ||
| 21 | + protected $bucket = '';//桶子 | ||
| 22 | + | ||
| 23 | + public function __construct() | ||
| 24 | + { | ||
| 25 | + // 创建 S3 客户端 | ||
| 26 | + $this->s3 = new S3Client([ | ||
| 27 | + 'version' => 'latest', | ||
| 28 | + 'region' => $this->region, | ||
| 29 | + 'credentials' => [ | ||
| 30 | + 'key' => $this->accessKeyId, | ||
| 31 | + 'secret' => $this->secretAccessKey, | ||
| 32 | + ], | ||
| 33 | + ]); | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @remark :上传图片与文件 | ||
| 38 | + * @name :uploadImage | ||
| 39 | + * @author :lyh | ||
| 40 | + * @method :post | ||
| 41 | + * @time :2024/1/23 9:20 | ||
| 42 | + */ | ||
| 43 | + public function uploadFiles($localFilePath, $s3Key) | ||
| 44 | + { | ||
| 45 | + try { | ||
| 46 | + $result = $this->s3->putObject([ | ||
| 47 | + 'Bucket' => $this->bucket, | ||
| 48 | + 'Key' => $s3Key, | ||
| 49 | + 'SourceFile' => $localFilePath, | ||
| 50 | + 'ACL' => 'public-read', // 设置图片为公共可读,可根据需求修改 | ||
| 51 | + ]); | ||
| 52 | + return $result['ObjectURL']; | ||
| 53 | + } catch (S3Exception $e) { | ||
| 54 | + return false; | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | +} |
| @@ -47,7 +47,9 @@ class SyncSubmitTaskService | @@ -47,7 +47,9 @@ class SyncSubmitTaskService | ||
| 47 | return false; | 47 | return false; |
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | - ProjectServer::useProject($project['id']); | 50 | + if(!ProjectServer::useProject($project['id'])){ |
| 51 | + return false; | ||
| 52 | + } | ||
| 51 | 53 | ||
| 52 | $action = $task['type']; | 54 | $action = $task['type']; |
| 53 | $handler = new self(); | 55 | $handler = new self(); |
| @@ -133,7 +135,6 @@ class SyncSubmitTaskService | @@ -133,7 +135,6 @@ class SyncSubmitTaskService | ||
| 133 | * @date 2023/11/30 | 135 | * @date 2023/11/30 |
| 134 | */ | 136 | */ |
| 135 | public static function checkIpCountry($domain, $ip, $type){ | 137 | public static function checkIpCountry($domain, $ip, $type){ |
| 136 | - $domain = 'https://demo.globalso.site/'; | ||
| 137 | $project = Project::getProjectByDomain($domain); | 138 | $project = Project::getProjectByDomain($domain); |
| 138 | if(empty($project)){ | 139 | if(empty($project)){ |
| 139 | throw new InquiryFilterException('项目不存在'); | 140 | throw new InquiryFilterException('项目不存在'); |
| @@ -210,11 +211,11 @@ class SyncSubmitTaskService | @@ -210,11 +211,11 @@ class SyncSubmitTaskService | ||
| 210 | if($config['filter_referers']){ | 211 | if($config['filter_referers']){ |
| 211 | //只比较path路径 | 212 | //只比较path路径 |
| 212 | $paths = array_map(function ($v){ | 213 | $paths = array_map(function ($v){ |
| 213 | - return parse_url(Url::to($v), PHP_URL_PATH); | 214 | + return trim(parse_url(Url::to($v), PHP_URL_PATH), '/'); |
| 214 | },$config['filter_referers']); | 215 | },$config['filter_referers']); |
| 215 | 216 | ||
| 216 | //后端获取的referer | 217 | //后端获取的referer |
| 217 | - if(in_array(parse_url($data['referer'], PHP_URL_PATH), $paths)){ | 218 | + if(in_array(trim(parse_url($data['referer'], PHP_URL_PATH), '/'), $paths)){ |
| 218 | throw new InquiryFilterException( '过滤来源链接:' . $data['referer']); | 219 | throw new InquiryFilterException( '过滤来源链接:' . $data['referer']); |
| 219 | } | 220 | } |
| 220 | //前端获取的referer | 221 | //前端获取的referer |
| @@ -251,6 +251,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -251,6 +251,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 251 | Route::any('extend', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'lists'])->name('product_extend'); | 251 | Route::any('extend', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'lists'])->name('product_extend'); |
| 252 | Route::any('extend/save', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'save'])->name('product_extend_save'); | 252 | Route::any('extend/save', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'save'])->name('product_extend_save'); |
| 253 | Route::any('extend/del', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'del'])->name('product_extend_del'); | 253 | Route::any('extend/del', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'del'])->name('product_extend_del'); |
| 254 | + Route::any('extend/search_filed', [\App\Http\Controllers\Bside\Product\ExtendController::class, 'search_filed'])->name('product_extend_search_filed'); | ||
| 254 | }); | 255 | }); |
| 255 | 256 | ||
| 256 | 257 |
-
请 注册 或 登录 后发表评论