Merge remote-tracking branch 'origin/master' into zhl
正在显示
22 个修改的文件
包含
721 行增加
和
68 行删除
| @@ -89,9 +89,9 @@ class Count extends Command | @@ -89,9 +89,9 @@ class Count extends Command | ||
| 89 | DB::table('gl_count')->insert($data); | 89 | DB::table('gl_count')->insert($data); |
| 90 | } | 90 | } |
| 91 | }catch (\Exception $e){ | 91 | }catch (\Exception $e){ |
| 92 | - echo date('Y-m-d H:i:s') . ' error: ' . $v['test_domain'] . '->' . $e->getMessage() . PHP_EOL; | 92 | + echo date('Y-m-d H:i:s') . ' error: ' . '->' . $e->getMessage() . PHP_EOL; |
| 93 | } | 93 | } |
| 94 | - echo date('Y-m-d H:i:s') . ' end: ' . $v['test_domain'] . PHP_EOL; | 94 | + echo date('Y-m-d H:i:s') . ' end: ' . PHP_EOL; |
| 95 | echo $this->error; | 95 | echo $this->error; |
| 96 | } | 96 | } |
| 97 | 97 |
| @@ -171,7 +171,7 @@ class VideoTask extends Command | @@ -171,7 +171,7 @@ class VideoTask extends Command | ||
| 171 | */ | 171 | */ |
| 172 | public function getProjectKeyword($number) | 172 | public function getProjectKeyword($number) |
| 173 | { | 173 | { |
| 174 | - $keyword_arr_id = Keyword::where('video', null)->whereNotNull('keyword_content')->pluck('id')->toArray(); | 174 | + $keyword_arr_id = Keyword::where('video', null)->where('title', 'not like', '%-tag%')->whereNotNull('keyword_content')->pluck('id')->toArray(); |
| 175 | $keyword_id = array_rand($keyword_arr_id, $number); | 175 | $keyword_id = array_rand($keyword_arr_id, $number); |
| 176 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); | 176 | $keyword = Keyword::whereIn("id", $keyword_id)->get(); |
| 177 | return $keyword; | 177 | return $keyword; |
| @@ -299,9 +299,20 @@ class VideoTask extends Command | @@ -299,9 +299,20 @@ class VideoTask extends Command | ||
| 299 | if($logoDom != null){ | 299 | if($logoDom != null){ |
| 300 | $logo = $logoDom->src; | 300 | $logo = $logoDom->src; |
| 301 | } | 301 | } |
| 302 | - $bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0); | ||
| 303 | - if($bgDom != null){ | ||
| 304 | - $bg = $bgDom->src; | 302 | + $elements = $dom->find('.section-banner-wrap-block'); |
| 303 | + if (count($elements) >= 2) { | ||
| 304 | + foreach ($elements as $v){ | ||
| 305 | + $image = $v->find('img', 0); | ||
| 306 | + if($image != null){ | ||
| 307 | + break; | ||
| 308 | + } | ||
| 309 | + } | ||
| 310 | + } else { | ||
| 311 | + | ||
| 312 | + $image = $dom->find('.section-banner-wrap-block',0)->find('img', 0); | ||
| 313 | + } | ||
| 314 | + if($image != null){ | ||
| 315 | + $bg = $image->src; | ||
| 305 | } | 316 | } |
| 306 | $dom->clear(); | 317 | $dom->clear(); |
| 307 | } catch (\Exception $e) { | 318 | } catch (\Exception $e) { |
| @@ -85,7 +85,7 @@ class RecommendedSuppliers extends Command | @@ -85,7 +85,7 @@ class RecommendedSuppliers extends Command | ||
| 85 | public function savePurchaser($project_id,$keyword,$row = 10){ | 85 | public function savePurchaser($project_id,$keyword,$row = 10){ |
| 86 | $url = 'https://admin.hagro.cn/api/company_list'; | 86 | $url = 'https://admin.hagro.cn/api/company_list'; |
| 87 | $data = [ | 87 | $data = [ |
| 88 | - 'prod_desc'=>$keyword = 'led', | 88 | + 'prod_desc'=>$keyword, |
| 89 | 'total'=>$row ?? 10, | 89 | 'total'=>$row ?? 10, |
| 90 | ]; | 90 | ]; |
| 91 | ksort($data); | 91 | ksort($data); |
| @@ -266,7 +266,7 @@ class Demo extends Command | @@ -266,7 +266,7 @@ class Demo extends Command | ||
| 266 | // } | 266 | // } |
| 267 | public function handle(){ | 267 | public function handle(){ |
| 268 | $domainModel = new DomainInfo(); | 268 | $domainModel = new DomainInfo(); |
| 269 | - $domainInfo = $domainModel->read(['project_id'=>1]); | 269 | + $domainInfo = $domainModel->read(['project_id'=>45]); |
| 270 | if($domainInfo === false){ | 270 | if($domainInfo === false){ |
| 271 | dd('11111'); | 271 | dd('11111'); |
| 272 | } | 272 | } |
| @@ -277,12 +277,25 @@ class Demo extends Command | @@ -277,12 +277,25 @@ class Demo extends Command | ||
| 277 | if($logoDom != null){ | 277 | if($logoDom != null){ |
| 278 | $logo = $logoDom->src; | 278 | $logo = $logoDom->src; |
| 279 | } | 279 | } |
| 280 | - $bgDom = $dom->find('.section-banner-wrap-block',0)->find('img', 0); | ||
| 281 | - if($bgDom != null){ | ||
| 282 | - $bg = $bgDom->src; | 280 | + $elements = $dom->find('.section-banner-wrap-block'); |
| 281 | + if (count($elements) >= 2) { | ||
| 282 | + foreach ($elements as $v){ | ||
| 283 | + $image = $v->find('img', 0); | ||
| 284 | + if($image != null){ | ||
| 285 | + break; | ||
| 286 | + } | ||
| 287 | + } | ||
| 288 | + } else { | ||
| 289 | + $image = $elements->find('img', 0); | ||
| 290 | + } | ||
| 291 | + if($image != null){ | ||
| 292 | + $bg = $image->src; | ||
| 293 | + } | ||
| 294 | + if($image != null){ | ||
| 295 | + $bg = $image->src; | ||
| 283 | } | 296 | } |
| 284 | // return $logo; | 297 | // return $logo; |
| 285 | - dd(['logo'=>$logo ?? '','ng'=>$bg ?? '']); | 298 | + dd(['logo'=>$logo ?? '','bg'=>$bg ?? '']); |
| 286 | // $projectModel = new Project(); | 299 | // $projectModel = new Project(); |
| 287 | // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); | 300 | // $list = $projectModel->list(['delete_status'=>0,'type'=>['!=',0]]); |
| 288 | // foreach ($list as $v1){ | 301 | // foreach ($list as $v1){ |
| @@ -665,23 +665,24 @@ class ProjectUpdate extends Command | @@ -665,23 +665,24 @@ class ProjectUpdate extends Command | ||
| 665 | foreach ($item['extend'] as $ke => $ve) { | 665 | foreach ($item['extend'] as $ke => $ve) { |
| 666 | $extend = $extend_model->read(['title' => $ke]); | 666 | $extend = $extend_model->read(['title' => $ke]); |
| 667 | if ($extend) { | 667 | if ($extend) { |
| 668 | - $extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]); | ||
| 669 | - if (!$extend_info) { | ||
| 670 | - if ($extend['type'] == 3) { | ||
| 671 | - $gallery = []; | ||
| 672 | - if (is_array($ve)) { | ||
| 673 | - foreach ($ve as $ve_img) { | ||
| 674 | - $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; | ||
| 675 | - } | ||
| 676 | - } else { | ||
| 677 | - $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]; | 668 | + if ($extend['type'] == 3) { |
| 669 | + $gallery = []; | ||
| 670 | + if (is_array($ve)) { | ||
| 671 | + foreach ($ve as $ve_img) { | ||
| 672 | + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve_img, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]; | ||
| 678 | } | 673 | } |
| 679 | - $value = Arr::a2s($gallery); | ||
| 680 | - } elseif ($extend['type'] == 4) { | ||
| 681 | - $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url)]); | ||
| 682 | } else { | 674 | } else { |
| 683 | - $value = $ve; | 675 | + $gallery[] = ['title' => '', 'description' => '', 'url' => $this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]; |
| 684 | } | 676 | } |
| 677 | + $value = Arr::a2s($gallery); | ||
| 678 | + } elseif ($extend['type'] == 4) { | ||
| 679 | + $value = Arr::a2s([$this->source_download($ve, $project_id, $domain_arr['host'], $web_url_domain, $home_url, 1)]); | ||
| 680 | + } else { | ||
| 681 | + $value = $ve; | ||
| 682 | + } | ||
| 683 | + | ||
| 684 | + $extend_info = $extend_info_model->read(['key' => $extend['key'], 'content_id' => $id]); | ||
| 685 | + if (!$extend_info) { | ||
| 685 | $extend_info_model->add([ | 686 | $extend_info_model->add([ |
| 686 | 'key' => $extend['key'], | 687 | 'key' => $extend['key'], |
| 687 | 'type' => $extend['type'], | 688 | 'type' => $extend['type'], |
| @@ -690,6 +691,8 @@ class ProjectUpdate extends Command | @@ -690,6 +691,8 @@ class ProjectUpdate extends Command | ||
| 690 | 'module_id' => $custom_info['id'], | 691 | 'module_id' => $custom_info['id'], |
| 691 | 'values' => $value, | 692 | 'values' => $value, |
| 692 | ]); | 693 | ]); |
| 694 | + } else { | ||
| 695 | + $extend_info_model->edit(['type' => $extend['type'], 'values' => $value], ['key' => $extend['key'], 'content_id' => $id]); | ||
| 693 | } | 696 | } |
| 694 | } | 697 | } |
| 695 | } | 698 | } |
| @@ -939,7 +942,7 @@ class ProjectUpdate extends Command | @@ -939,7 +942,7 @@ class ProjectUpdate extends Command | ||
| 939 | } | 942 | } |
| 940 | 943 | ||
| 941 | //资源下载 | 944 | //资源下载 |
| 942 | - protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url) | 945 | + protected function source_download($url, $project_id, $domain, $web_url_domain, $home_url, $same_name = 0) |
| 943 | { | 946 | { |
| 944 | if (!$url) { | 947 | if (!$url) { |
| 945 | return ''; | 948 | return ''; |
| @@ -961,7 +964,7 @@ class ProjectUpdate extends Command | @@ -961,7 +964,7 @@ class ProjectUpdate extends Command | ||
| 961 | $path = '/' . $path; | 964 | $path = '/' . $path; |
| 962 | } | 965 | } |
| 963 | $url_complete = ($scheme ?: 'https') . '://' . $domain . $path; | 966 | $url_complete = ($scheme ?: 'https') . '://' . $domain . $path; |
| 964 | - $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); | 967 | + $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete, '', '', $same_name); |
| 965 | 968 | ||
| 966 | if ($new_url) { | 969 | if ($new_url) { |
| 967 | CollectSource::insert([ | 970 | CollectSource::insert([ |
| @@ -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'=>969]); | 58 | + $list = $projectModel->list(['id'=>645]); |
| 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; |
| @@ -280,9 +280,11 @@ class WebTraffic extends Command | @@ -280,9 +280,11 @@ class WebTraffic extends Command | ||
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | /** | 282 | /** |
| 283 | - * 引流的项目 | 283 | + * 非俄语站的引流的项目 |
| 284 | */ | 284 | */ |
| 285 | protected function getProjectList($type, $page){ | 285 | protected function getProjectList($type, $page){ |
| 286 | + $ru_lang_id = WebLanguage::getIdByLang('ru'); | ||
| 287 | + | ||
| 286 | //推广项目 | 288 | //推广项目 |
| 287 | $list = Project::with('domainInfo') | 289 | $list = Project::with('domainInfo') |
| 288 | ->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id') | 290 | ->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id') |
| @@ -291,6 +293,7 @@ class WebTraffic extends Command | @@ -291,6 +293,7 @@ class WebTraffic extends Command | ||
| 291 | ->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE) | 293 | ->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE) |
| 292 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) | 294 | ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) |
| 293 | ->where('gl_project.is_upgrade', 0) //非升级项目 | 295 | ->where('gl_project.is_upgrade', 0) //非升级项目 |
| 296 | + ->where('gl_project.main_lang_id', '<>', $ru_lang_id) //非俄语站 | ||
| 294 | ->where(function ($query) use ($type) { | 297 | ->where(function ($query) use ($type) { |
| 295 | if($type == 1){ | 298 | if($type == 1){ |
| 296 | //1-3个月项目 | 299 | //1-3个月项目 |
| @@ -307,7 +310,7 @@ class WebTraffic extends Command | @@ -307,7 +310,7 @@ class WebTraffic extends Command | ||
| 307 | $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | 310 | $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); |
| 308 | $query->where('pdo.start_date', '<', $startTime); | 311 | $query->where('pdo.start_date', '<', $startTime); |
| 309 | } | 312 | } |
| 310 | - })->select(['pdo.project_id','gl_project.main_lang_id'])->forPage($page, 500)->get(); | 313 | + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); |
| 311 | //其他地方在引流的域名 | 314 | //其他地方在引流的域名 |
| 312 | $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); | 315 | $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); |
| 313 | $data = []; | 316 | $data = []; |
app/Console/Commands/WebTrafficRussia.php
0 → 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +namespace App\Console\Commands; | ||
| 4 | + | ||
| 5 | +use App\Helper\Arr; | ||
| 6 | +use App\Models\Product\Category; | ||
| 7 | +use App\Models\Product\Product; | ||
| 8 | +use App\Models\Project\OnlineCheck; | ||
| 9 | +use App\Models\Project\Project; | ||
| 10 | +use App\Models\Template\BCustomTemplate; | ||
| 11 | +use App\Models\WebSetting\WebLanguage; | ||
| 12 | +use App\Services\ProjectServer; | ||
| 13 | +use Carbon\Carbon; | ||
| 14 | +use GuzzleHttp\Client; | ||
| 15 | +use GuzzleHttp\Promise\Utils; | ||
| 16 | +use Illuminate\Console\Command; | ||
| 17 | +use Illuminate\Support\Facades\DB; | ||
| 18 | +use Illuminate\Support\Facades\Log; | ||
| 19 | +use Illuminate\Support\Str; | ||
| 20 | + | ||
| 21 | +/** | ||
| 22 | + * 俄语站网站引流 | ||
| 23 | + * Class Traffic | ||
| 24 | + * @package App\Console\Commands | ||
| 25 | + * @author zbj | ||
| 26 | + * @date 2023/5/18 | ||
| 27 | + */ | ||
| 28 | +class WebTrafficRussia extends Command | ||
| 29 | +{ | ||
| 30 | + /** | ||
| 31 | + * The name and signature of the console command. | ||
| 32 | + * | ||
| 33 | + * @var string | ||
| 34 | + */ | ||
| 35 | + protected $signature = 'web_traffic_russia {type}'; | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * The console command description. | ||
| 39 | + * | ||
| 40 | + * @var string | ||
| 41 | + */ | ||
| 42 | + protected $description = '俄语站网站引流'; | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * Create a new command instance. | ||
| 46 | + * | ||
| 47 | + * @return void | ||
| 48 | + */ | ||
| 49 | + public function __construct() | ||
| 50 | + { | ||
| 51 | + parent::__construct(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * 国家概率 | ||
| 56 | + * @var array | ||
| 57 | + */ | ||
| 58 | + protected $country_ratio = [ | ||
| 59 | + '俄罗斯' => 75, | ||
| 60 | + '白俄罗斯' => 6, | ||
| 61 | + '哈萨克斯坦' => 6, | ||
| 62 | + '乌兹别克斯坦' => 2, | ||
| 63 | + '塔吉克斯坦' => 2, | ||
| 64 | + '土耳其' => 2, | ||
| 65 | + '吉尔吉斯坦' => 1, | ||
| 66 | + '土库曼斯坦' => 1, | ||
| 67 | + '乌克兰' => 1, | ||
| 68 | + '亚美尼亚' => 2, | ||
| 69 | + '阿塞拜疆' => 2, | ||
| 70 | + '摩尔多瓦' => 2, | ||
| 71 | + '格鲁吉亚' => 2, | ||
| 72 | + '美国' => 1, | ||
| 73 | + '德国' => 1, | ||
| 74 | + '法国' => 1, | ||
| 75 | + '意大利' => 1, | ||
| 76 | + '加拿大' => 1, | ||
| 77 | + '西班牙' => 1, | ||
| 78 | + '葡萄牙' => 1, | ||
| 79 | + '韩国' => 1, | ||
| 80 | + '日本' => 1, | ||
| 81 | + '印度' => 1, | ||
| 82 | + '菲律宾' => 1, | ||
| 83 | + '越南' => 1, | ||
| 84 | + '荷兰' => 1, | ||
| 85 | + '瑞典' => 1, | ||
| 86 | + '泰国' => 1, | ||
| 87 | + '英国' => 1, | ||
| 88 | + ]; | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * google域名后缀 | ||
| 92 | + * @var string[] | ||
| 93 | + */ | ||
| 94 | + protected $suffix = [ | ||
| 95 | + 'co.jp' => '日本', | ||
| 96 | + 'com.tr' => '土耳其', | ||
| 97 | + 'nl' => '荷兰', | ||
| 98 | + 'ru' => '俄罗斯', | ||
| 99 | + 'fr' => '法国', | ||
| 100 | + 'co.kr' => '韩国', | ||
| 101 | + 'fi' => '芬兰', | ||
| 102 | + 'be' => '比利时', | ||
| 103 | + 'lt' => '立陶宛', | ||
| 104 | + 'es' => '西班牙', | ||
| 105 | + 'it' => '意大利', | ||
| 106 | + 'com.au' => '澳大利亚', | ||
| 107 | + 'no' => '挪威', | ||
| 108 | + 'al' => '阿尔巴尼亚', | ||
| 109 | + 'pt' => '葡萄牙', | ||
| 110 | + 'lv' => '拉脱维亚', | ||
| 111 | + 'hu' => '匈牙利', | ||
| 112 | + 'cz' => '捷克', | ||
| 113 | + 'de' => '德国', | ||
| 114 | + 'ca' => '加拿大', | ||
| 115 | + 'co.in' => '印度', | ||
| 116 | + 'co.uk' => '英国', | ||
| 117 | + 'com.vn' => '越南', | ||
| 118 | + 'com.br' => '巴西', | ||
| 119 | + 'co.il' => '以色列', | ||
| 120 | + 'pl' => '波兰', | ||
| 121 | + 'com.eg' => '埃及', | ||
| 122 | + 'co.th' => '泰国', | ||
| 123 | + 'sk' => '斯洛伐克', | ||
| 124 | + 'ro' => '罗马尼亚', | ||
| 125 | + 'com.mx' => '墨西哥', | ||
| 126 | + 'com.my' => '马来西亚', | ||
| 127 | + 'com.pk' => '巴基斯坦', | ||
| 128 | + 'co.nz' => '新西兰', | ||
| 129 | + 'co.za' => '南非', | ||
| 130 | + 'com.ar' => '阿根廷', | ||
| 131 | + 'com.kw' => '科威特', | ||
| 132 | + 'com.sg' => '新加坡', | ||
| 133 | + 'com.co' => '哥伦比亚', | ||
| 134 | + 'co.id' => '印度尼西亚', | ||
| 135 | + 'gr' => '希腊', | ||
| 136 | + 'bg' => '保加利亚', | ||
| 137 | + 'mn' => '蒙古', | ||
| 138 | + 'dk' => '丹麦', | ||
| 139 | + 'com.sa' => '沙特阿拉伯', | ||
| 140 | + 'com.pe' => '秘鲁', | ||
| 141 | + 'com.ph' => '菲律宾', | ||
| 142 | + 'com.ua' => '乌克兰', | ||
| 143 | + 'ge' => '格鲁吉亚', | ||
| 144 | + 'ae' => '阿拉伯联合酋长国', | ||
| 145 | + 'tn' => '突尼斯', | ||
| 146 | + ]; | ||
| 147 | + | ||
| 148 | + /** | ||
| 149 | + * 概率值 | ||
| 150 | + * @var int[] | ||
| 151 | + */ | ||
| 152 | + protected $sjjg = [360, 640];//访问间隔占比 访问|不访问 比非俄语站降一般 | ||
| 153 | + //访问页面类型占比 产品详情页、单页|产品分类页 | ||
| 154 | + protected $ymzb = [ | ||
| 155 | + 'urls_cats' => 700, | ||
| 156 | + 'urls_details' => 300 | ||
| 157 | + ]; | ||
| 158 | + protected $sdzb = [600, 200, 150, 50]; //访问页面深度占比 1页|2页|3-6页|7-11页 | ||
| 159 | + protected $yddzb = [1 => 700, 2 => 300]; //移动端占比 pc|mobile | ||
| 160 | + //模拟访问来源占比 (美国) | ||
| 161 | + protected $lyzb = [ | ||
| 162 | + 'https://www.google.com/' => 630, | ||
| 163 | + 'http://www.google.com/' => 30, | ||
| 164 | + 'http://www.bing.com/' => 20, | ||
| 165 | + 'https://www.bing.com/' => 5, | ||
| 166 | + 'https://www.youtube.com/' => 5, | ||
| 167 | + 'https://search.yahoo.com/' => 5, | ||
| 168 | + 'https://www.facebook.com/' => 5, | ||
| 169 | + ]; | ||
| 170 | + | ||
| 171 | + //俄语 | ||
| 172 | + protected $eylyzb = [ | ||
| 173 | + 'https://www.yandex.com/' => 630, | ||
| 174 | + 'https://www.google.com/' => 30, | ||
| 175 | + 'http://www.google.com/' => 30, | ||
| 176 | + 'http://www.bing.com/' => 20, | ||
| 177 | + 'https://www.bing.com/' => 5, | ||
| 178 | + 'https://www.youtube.com/' => 5, | ||
| 179 | + 'https://search.yahoo.com/' => 5, | ||
| 180 | + 'https://www.facebook.com/' => 5, | ||
| 181 | + ]; | ||
| 182 | + | ||
| 183 | + protected $otherzb = [700, 300]; //模拟访问来源占比 (非美国) google.com|google.其他后缀 | ||
| 184 | + | ||
| 185 | + protected $pc_ua = [ | ||
| 186 | + 0 => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11', | ||
| 187 | + 1 => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36', | ||
| 188 | + 2 => 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1' | ||
| 189 | + ]; | ||
| 190 | + | ||
| 191 | + protected $mobile_ua = [ | ||
| 192 | + 0 => 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko; googleweblight) Chrome/38.0.1025.166 Mobile Safari/535.19', | ||
| 193 | + ]; | ||
| 194 | + | ||
| 195 | + /** | ||
| 196 | + * @return bool | ||
| 197 | + */ | ||
| 198 | + public function handle() | ||
| 199 | + { | ||
| 200 | + try { | ||
| 201 | + $type = $this->argument('type'); | ||
| 202 | + | ||
| 203 | + $this->sleep($type); | ||
| 204 | + | ||
| 205 | + $page = 1; | ||
| 206 | + while (true){ | ||
| 207 | + $project_list = $this->getProjectList($type, $page); | ||
| 208 | + if(!$project_list){ | ||
| 209 | + break; | ||
| 210 | + } | ||
| 211 | + $need_project = []; | ||
| 212 | + foreach ($project_list as $project) { | ||
| 213 | + //随机引流间隔 | ||
| 214 | + $res_sjjg = $this->get_rand($this->sjjg); | ||
| 215 | + if ($res_sjjg == 1) { | ||
| 216 | + continue; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + $project_urls = $this->getProductUrls($project['project_id']); | ||
| 220 | + $project_urls['home'] = $project['domain']; | ||
| 221 | + //随机访问页面 | ||
| 222 | + $project['visit_urls'] = $this->getVisitUrls($project_urls); | ||
| 223 | + //随机客户端 | ||
| 224 | + $project['device_port'] = $this->get_rand($this->yddzb); | ||
| 225 | + $project['user_agent'] = $project['device_port'] == 1 ? Arr::random($this->pc_ua) : Arr::random($this->mobile_ua); | ||
| 226 | + | ||
| 227 | + $need_project[] = $project; | ||
| 228 | + } | ||
| 229 | + //随机访问ip | ||
| 230 | + $ips = $this->getIpAreas(count($need_project)); | ||
| 231 | + | ||
| 232 | + //特殊日期 降访问率 | ||
| 233 | + foreach ($need_project as $project_key => $project){ | ||
| 234 | + $diff = $ips[$project_key]['diff']; | ||
| 235 | + //当地时间 | ||
| 236 | + $w = date('w', strtotime($diff . 'hour')); | ||
| 237 | + $date = date('m-d', strtotime($diff . 'hour')); | ||
| 238 | + //元旦节和圣诞节按照周六的比例处理 | ||
| 239 | + if(in_array($date, ['01-01', '12-25'])){ | ||
| 240 | + $w = 6; | ||
| 241 | + } | ||
| 242 | + switch ($w){ | ||
| 243 | + case 0: | ||
| 244 | + //周日降70-80% | ||
| 245 | + $rate = rand(70, 80) * 10; | ||
| 246 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 247 | + break; | ||
| 248 | + case 5: | ||
| 249 | + //周5降30-40% | ||
| 250 | + $rate = rand(30, 40) * 10; | ||
| 251 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 252 | + break; | ||
| 253 | + case 6: | ||
| 254 | + //周6降60-70% | ||
| 255 | + $rate = rand(60, 70) * 10; | ||
| 256 | + $res = $this->get_rand([1000-$rate, $rate]); | ||
| 257 | + break; | ||
| 258 | + default: | ||
| 259 | + $res = 0; | ||
| 260 | + } | ||
| 261 | + //不访问 | ||
| 262 | + if($res == 1){ | ||
| 263 | + unset($need_project[$project_key]); | ||
| 264 | + unset($ips[$project_key]); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + | ||
| 268 | + //最多10层深度 | ||
| 269 | + $client = new Client(['verify' => false]); | ||
| 270 | + for ($j = 0; $j < 10; $j++) { | ||
| 271 | + for ($j = 0; $j < 10; $j++) { | ||
| 272 | + //并发请求 | ||
| 273 | + $promises = []; | ||
| 274 | + foreach ($need_project as $project_key => $project) { | ||
| 275 | + if (empty($project['visit_urls'][$j])) { | ||
| 276 | + continue; | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + $data = [ | ||
| 280 | + 'ip' => $ips[$project_key]['ip'], | ||
| 281 | + 'url' => $project['visit_urls'][$j], | ||
| 282 | + 'device_port' => $project['device_port'], | ||
| 283 | + 'referrer_url' => $this->getReferer($ips[$project_key]['ip_area'], $project['lang']), | ||
| 284 | + 'user_agent' => $project['user_agent'], | ||
| 285 | + ]; | ||
| 286 | + Log::channel('traffic')->info('ru_traffic project_id:' . $project['project_id'], $data); | ||
| 287 | + $promises[] = $client->postAsync($project['domain'] . 'api/traffic_visit', ['form_params' => $data]); | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + if($promises){ | ||
| 291 | + Utils::settle($promises)->wait(); | ||
| 292 | + //每个深度随机等待 | ||
| 293 | + sleep(rand(2, 10)); | ||
| 294 | + } | ||
| 295 | + } | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + $page++; | ||
| 299 | + } | ||
| 300 | + }catch (\Exception $e){ | ||
| 301 | + Log::channel('traffic')->error("ru:line" . $e->getLine() . ',error:' . $e->getMessage()); | ||
| 302 | + } | ||
| 303 | + } | ||
| 304 | + | ||
| 305 | + /** | ||
| 306 | + * 不同项目 休眠 | ||
| 307 | + */ | ||
| 308 | + protected function sleep($type){ | ||
| 309 | + if($type == 1){ //1-3个月的项目 | ||
| 310 | + sleep(rand(5,480)); | ||
| 311 | + }elseif($type == 2){ //4-8个月的项目 | ||
| 312 | + sleep(rand(5,240)); | ||
| 313 | + }elseif($type == 3){ // 大于9个月的项目 | ||
| 314 | + sleep(rand(5,120)); | ||
| 315 | + } | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + /** | ||
| 319 | + * 俄语站引流的项目 | ||
| 320 | + */ | ||
| 321 | + protected function getProjectList($type, $page){ | ||
| 322 | + $ru_lang_id = WebLanguage::getIdByLang('ru'); | ||
| 323 | + | ||
| 324 | + //推广项目 | ||
| 325 | + $list = Project::with('domainInfo') | ||
| 326 | + ->leftJoin('gl_project_deploy_optimize as pdo', 'pdo.project_id', '=', 'gl_project.id') | ||
| 327 | + ->leftJoin('gl_project_online_check as poc', 'poc.project_id', '=', 'gl_project.id') | ||
| 328 | + ->where('pdo.domain', '>', 0) | ||
| 329 | + ->where('poc.qa_status', OnlineCheck::STATUS_ONLINE_TRUE) | ||
| 330 | + ->whereIn('gl_project.type', [Project::TYPE_TWO, Project::TYPE_FOUR]) | ||
| 331 | + ->where('gl_project.is_upgrade', 0) //非升级项目 | ||
| 332 | + ->where('gl_project.main_lang_id', $ru_lang_id)// 俄语站 | ||
| 333 | + ->where(function ($query) use ($type) { | ||
| 334 | + if($type == 1){ | ||
| 335 | + //1-3个月项目 | ||
| 336 | + $startTime = Carbon::now()->addMonths(-4)->toDateString(); | ||
| 337 | + $endTime = Carbon::now()->addMonths(-1)->toDateString(); | ||
| 338 | + $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 339 | + }elseif($type == 2){ | ||
| 340 | + //4-8个月项目 | ||
| 341 | + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 342 | + $endTime = Carbon::now()->addMonths(-4)->endOfDay()->toDateTimeString(); | ||
| 343 | + $query->whereBetween('pdo.start_date', [$startTime,$endTime]); | ||
| 344 | + }else{ | ||
| 345 | + //大于9个月项目 | ||
| 346 | + $startTime = Carbon::now()->addMonths(-9)->startOfDay()->toDateTimeString(); | ||
| 347 | + $query->where('pdo.start_date', '<', $startTime); | ||
| 348 | + } | ||
| 349 | + })->select(['pdo.project_id','gl_project.main_lang_id','gl_project.id'])->forPage($page, 500)->get(); | ||
| 350 | + //其他地方在引流的域名 | ||
| 351 | + $other = DB::connection('projects_mysql')->table('projects')->where('switch', 1)->pluck('domain')->toArray(); | ||
| 352 | + $data = []; | ||
| 353 | + foreach ($list as $project) { | ||
| 354 | + $lang = WebLanguage::getLangById($project['main_lang_id']??1)['short']; | ||
| 355 | + if(empty($project->domainInfo['domain'])){ | ||
| 356 | + continue; | ||
| 357 | + } | ||
| 358 | + //其他地方在引流就不再引流了 | ||
| 359 | + if(in_array($project->domainInfo['domain'], $other)){ | ||
| 360 | + continue; | ||
| 361 | + } | ||
| 362 | + $data[] = [ | ||
| 363 | + 'project_id' => $project['project_id'], | ||
| 364 | + 'domain' => 'https://' . $project->domainInfo['domain'] . '/', | ||
| 365 | + 'lang' => $lang | ||
| 366 | + ]; | ||
| 367 | + } | ||
| 368 | + return $data; | ||
| 369 | + } | ||
| 370 | + | ||
| 371 | + /** | ||
| 372 | + * 获取产品分类、单页和详情链接 | ||
| 373 | + */ | ||
| 374 | + protected function getProductUrls($project_id){ | ||
| 375 | + ProjectServer::useProject($project_id); | ||
| 376 | + //已发布产品分类页面 | ||
| 377 | + $data['urls_cats'] = DB::connection('custom_mysql')->table('gl_product_category') | ||
| 378 | + ->where('project_id', $project_id)->where('status', Category::STATUS_ACTIVE) | ||
| 379 | + ->whereNull('deleted_at') | ||
| 380 | + ->pluck('route','id')->toArray(); | ||
| 381 | + | ||
| 382 | + //已发布单页面 | ||
| 383 | + $data['urls_page'] = []; | ||
| 384 | +// $data['urls_page'] = DB::connection('custom_mysql')->table('gl_web_custom_template') | ||
| 385 | +// ->where('project_id', $project_id)->where('url', '<>', '404')->where('status', BCustomTemplate::STATUS_ACTIVE)->pluck('url', 'id')->toArray(); | ||
| 386 | + | ||
| 387 | + //已发布产品详情页 | ||
| 388 | + $data['urls_details'] = DB::connection('custom_mysql')->table('gl_product') | ||
| 389 | + ->where('project_id', $project_id)->where('status', Product::STATUS_ON) | ||
| 390 | + ->whereNull('deleted_at') | ||
| 391 | + ->pluck('route', 'id')->toArray(); | ||
| 392 | + | ||
| 393 | + $data['urls_cats'] = array_merge($data['urls_cats'], $data['urls_page']); | ||
| 394 | + if(empty($data['urls_cats'])){ | ||
| 395 | + $data['urls_cats'] = $data['urls_details']; | ||
| 396 | + } | ||
| 397 | + DB::disconnect('custom_mysql'); | ||
| 398 | + return $data; | ||
| 399 | + } | ||
| 400 | + | ||
| 401 | + /** | ||
| 402 | + * 获取地区IP | ||
| 403 | + */ | ||
| 404 | + protected function getIpAreas($num) | ||
| 405 | + { | ||
| 406 | + //本地时间为7-23点的地区 | ||
| 407 | + $h = date('H'); | ||
| 408 | + $areas = []; | ||
| 409 | + $list = DB::table('gl_area_timezone')->whereIn('name', array_keys($this->country_ratio))->get(); | ||
| 410 | + $time_zones = []; | ||
| 411 | + foreach ($list as $v) { | ||
| 412 | + $v = (array)$v; | ||
| 413 | + $country_hour = $h + $v['diff']; | ||
| 414 | + if ($country_hour < 0) { | ||
| 415 | + $country_hour = 24 + $country_hour; | ||
| 416 | + } | ||
| 417 | + if ($country_hour >= 7 && $country_hour < 23) { | ||
| 418 | + $areas[] = $v['name']; | ||
| 419 | + $time_zones[$v['name']] = $v['diff']; | ||
| 420 | + } | ||
| 421 | + } | ||
| 422 | + //不在时区的国家概率去掉 | ||
| 423 | + $country_ratio = $this->country_ratio; | ||
| 424 | + foreach ($country_ratio as $k => $v){ | ||
| 425 | + if(!in_array($k, array_keys($time_zones))){ | ||
| 426 | + unset($country_ratio[$k]); | ||
| 427 | + } | ||
| 428 | + } | ||
| 429 | + | ||
| 430 | + $data = []; | ||
| 431 | + for ($i=0;$i<$num;$i++){ | ||
| 432 | + //ip国家占比 | ||
| 433 | + $ip_area = $this->get_rand($this->country_ratio); | ||
| 434 | + $res = DB::table('gl_xunpan_ipdata')->where('ip_area', $ip_area)->inRandomOrder()->first(); | ||
| 435 | + $res = (array)$res; | ||
| 436 | + $res['diff'] = $time_zones[$res['ip_area']]; | ||
| 437 | + $data[] = $res; | ||
| 438 | + } | ||
| 439 | + return $data; | ||
| 440 | + } | ||
| 441 | + | ||
| 442 | + /** | ||
| 443 | + * 概率算法 | ||
| 444 | + */ | ||
| 445 | + protected function get_rand($proArr) { | ||
| 446 | + $result = ''; | ||
| 447 | + $proSum = array_sum($proArr); | ||
| 448 | + foreach ($proArr as $key => $proCur) { | ||
| 449 | + $randNum = mt_rand(1, $proSum); | ||
| 450 | + if ($randNum <= $proCur) { | ||
| 451 | + $result = $key; | ||
| 452 | + break; | ||
| 453 | + } else { | ||
| 454 | + $proSum -= $proCur; | ||
| 455 | + } | ||
| 456 | + } | ||
| 457 | + unset ($proArr); | ||
| 458 | + return $result; | ||
| 459 | + } | ||
| 460 | + | ||
| 461 | + /** | ||
| 462 | + * 根据随机访问深度 随机获取访问页面 | ||
| 463 | + */ | ||
| 464 | + protected function getVisitUrls($project_urls){ | ||
| 465 | + //没有分类页 就只访问首页 | ||
| 466 | + if(!$project_urls['urls_cats']){ | ||
| 467 | + $url[] = $project_urls['home']; | ||
| 468 | + return $url; | ||
| 469 | + } | ||
| 470 | + //随机访问深度 | ||
| 471 | + $res_sdzb = $this->get_rand($this->sdzb); | ||
| 472 | + //随机访问页面类型 | ||
| 473 | + $res_ymzb = $this->get_rand($this->ymzb); | ||
| 474 | + | ||
| 475 | + $all_url = array_merge($project_urls['urls_cats'],$project_urls['urls_details']); | ||
| 476 | + if(!$all_url){ | ||
| 477 | + $url[] = $project_urls['home']; | ||
| 478 | + return $url; | ||
| 479 | + } | ||
| 480 | + | ||
| 481 | + $url = []; | ||
| 482 | + if($res_sdzb == 0){//深度一页 | ||
| 483 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb]) : ''; | ||
| 484 | + }elseif($res_sdzb == 1){//深度两页 | ||
| 485 | + $url[] = $project_urls['home']; | ||
| 486 | + $url[] = $project_urls[$res_ymzb] ? Arr::random($project_urls[$res_ymzb]) : ''; | ||
| 487 | + }elseif($res_sdzb == 2){//深度3-6页 | ||
| 488 | + $yms = rand(2,5); //随机页面数 | ||
| 489 | + $url = Arr::random($all_url, $yms); | ||
| 490 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 491 | + }elseif($res_sdzb == 3){//深度7-11页 | ||
| 492 | + $yms = rand(6,10); //随机页面数 | ||
| 493 | + $url = Arr::random($all_url, $yms); | ||
| 494 | + $url = Arr::prepend($url, $project_urls['home']);//首页加到最前面去 | ||
| 495 | + } | ||
| 496 | + foreach ($url as &$v){ | ||
| 497 | + if(!Str::contains($v, $project_urls['home'])){ | ||
| 498 | + if (FALSE === strpos($v, '.htm')) { | ||
| 499 | + $v .= '/'; | ||
| 500 | + } | ||
| 501 | + $v = $project_urls['home'] . $v; | ||
| 502 | + } | ||
| 503 | + } | ||
| 504 | + return array_unique(array_filter($url)); | ||
| 505 | + } | ||
| 506 | + | ||
| 507 | + /** | ||
| 508 | + * 获取访问来路 | ||
| 509 | + */ | ||
| 510 | + protected function getReferer($ip_area, $lang){ | ||
| 511 | + | ||
| 512 | + if($lang == 'ru'){ | ||
| 513 | + return $this->get_rand($this->eylyzb); | ||
| 514 | + } | ||
| 515 | + | ||
| 516 | + if($ip_area == '美国'){ | ||
| 517 | + $referer = $this->get_rand($this->lyzb); | ||
| 518 | + }else{ | ||
| 519 | + $referer = 'https://www.google.com/'; | ||
| 520 | + | ||
| 521 | + $suffix = array_search($ip_area, $this->suffix); | ||
| 522 | + if($suffix){ | ||
| 523 | + $res_qtzb = $this->get_rand($this->otherzb); | ||
| 524 | + if($res_qtzb == 1){ | ||
| 525 | + $referer = 'https://www.google.'.$suffix.'/'; | ||
| 526 | + } | ||
| 527 | + } | ||
| 528 | + } | ||
| 529 | + return $referer; | ||
| 530 | + } | ||
| 531 | +} |
| @@ -30,6 +30,9 @@ class Kernel extends ConsoleKernel | @@ -30,6 +30,9 @@ class Kernel extends ConsoleKernel | ||
| 30 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 | 30 | $schedule->command('web_traffic 1')->everyThirtyMinutes(); // 引流 1-3个月的项目,半小时一次 |
| 31 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 | 31 | $schedule->command('web_traffic 2')->cron('*/18 * * * *'); // 引流 4-8个月的项目,18分钟一次 |
| 32 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 | 32 | $schedule->command('web_traffic 3')->cron('*/12 * * * *'); // 引流 大于9个月的项目,12分钟一次 |
| 33 | + $schedule->command('web_traffic_russia 1')->everyThirtyMinutes(); // 俄语站引流 1-3个月的项目,半小时一次 | ||
| 34 | + $schedule->command('web_traffic_russia 2')->cron('*/18 * * * *'); // 俄语站引流 4-8个月的项目,18分钟一次 | ||
| 35 | + $schedule->command('web_traffic_russia 3')->cron('*/12 * * * *'); // 俄语站引流 大于9个月的项目,12分钟一次 | ||
| 33 | $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次 | 36 | $schedule->command('sync_channel')->dailyAt('06:00')->withoutOverlapping(1); // 渠道信息,每天执行一次 |
| 34 | // $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录 | 37 | // $schedule->command('month_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计记录 |
| 35 | $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 | 38 | $schedule->command('forward_count')->monthlyOn(1,'01:00')->withoutOverlapping(1);//没月月初1号执行月统计转发询盘记录 |
| @@ -45,7 +48,7 @@ class Kernel extends ConsoleKernel | @@ -45,7 +48,7 @@ class Kernel extends ConsoleKernel | ||
| 45 | 48 | ||
| 46 | $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 | 49 | $schedule->command('recommended_suppliers')->dailyAt('03:00')->withoutOverlapping(1); //每天凌晨1点执行一次生成推荐商 |
| 47 | // 每日推送视频任务 | 50 | // 每日推送视频任务 |
| 48 | - $schedule->command('video_task')->dailyAt('03:30')->withoutOverlapping(1); | 51 | + $schedule->command('video_task')->dailyAt('02:30')->withoutOverlapping(1); |
| 49 | // 每日推送已完成视频任务项目生成对应界面 | 52 | // 每日推送已完成视频任务项目生成对应界面 |
| 50 | $schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1); | 53 | $schedule->command('notice_c')->dailyAt('04:00')->withoutOverlapping(1); |
| 51 | } | 54 | } |
| @@ -29,7 +29,7 @@ class KeywordsController extends BaseController | @@ -29,7 +29,7 @@ class KeywordsController extends BaseController | ||
| 29 | ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray(); | 29 | ->orWhere('main_keywords', 'like' , '%'.$this->map['search'].'%')->pluck('project_id')->toArray(); |
| 30 | $projectModel = new Project(); | 30 | $projectModel = new Project(); |
| 31 | $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build') | 31 | $lists = $projectModel->formatQuery(['id'=>['in',$ids]])->with('payment')->with('deploy_build') |
| 32 | - ->with('deploy_optimize')->get()->toArray(); | 32 | + ->with('deploy_optimize')->with('domainInfo')->get()->toArray(); |
| 33 | $this->response('success',Code::SUCCESS,$lists); | 33 | $this->response('success',Code::SUCCESS,$lists); |
| 34 | } | 34 | } |
| 35 | } | 35 | } |
| @@ -239,7 +239,7 @@ class OptimizeController extends BaseController | @@ -239,7 +239,7 @@ class OptimizeController extends BaseController | ||
| 239 | } | 239 | } |
| 240 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ | 240 | if(isset($this->map['channel_id']) && !empty($this->map['channel_id'])){ |
| 241 | $query->where(function ($subQuery) { | 241 | $query->where(function ($subQuery) { |
| 242 | - $subQuery->orWhere('gl_project.channel','like','%"zone_id": "'.$this->map['channel_id'].'"%') | 242 | + $subQuery->orWhere('gl_project.channel','like','%"channel_id": "'.$this->map['channel_id'].'"%') |
| 243 | ->orWhere('gl_project.channel','like','%"zone_id": '.$this->map['channel_id'].'%'); | 243 | ->orWhere('gl_project.channel','like','%"zone_id": '.$this->map['channel_id'].'%'); |
| 244 | }); | 244 | }); |
| 245 | } | 245 | } |
| @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController | @@ -30,6 +30,7 @@ class ProjectKeywordController extends BaseController | ||
| 30 | } | 30 | } |
| 31 | $data['search_keywords'] = $info['search_keywords']; | 31 | $data['search_keywords'] = $info['search_keywords']; |
| 32 | $data['customer_keywords'] = $info['customer_keywords']; | 32 | $data['customer_keywords'] = $info['customer_keywords']; |
| 33 | + $data['brand_keyword'] = $info['brand_keyword']; | ||
| 33 | $this->response('success',Code::SUCCESS,$data); | 34 | $this->response('success',Code::SUCCESS,$data); |
| 34 | } | 35 | } |
| 35 | 36 |
| @@ -34,7 +34,8 @@ class SuppliersController extends BaseController | @@ -34,7 +34,8 @@ class SuppliersController extends BaseController | ||
| 34 | public function recommendedPurchaser(){ | 34 | public function recommendedPurchaser(){ |
| 35 | $purchaserModel = new Purchaser(); | 35 | $purchaserModel = new Purchaser(); |
| 36 | $data = []; | 36 | $data = []; |
| 37 | - $lists = $purchaserModel->list(['project_id'=>$this->user['project_id']]); | 37 | + $this->map['project_id'] = $this->user['project_id']; |
| 38 | + $lists = $purchaserModel->list($this->map); | ||
| 38 | if(!empty($lists)){ | 39 | if(!empty($lists)){ |
| 39 | foreach ($lists as $v){ | 40 | foreach ($lists as $v){ |
| 40 | $resultData = json_decode($v['data']); | 41 | $resultData = json_decode($v['data']); |
| @@ -49,6 +50,19 @@ class SuppliersController extends BaseController | @@ -49,6 +50,19 @@ class SuppliersController extends BaseController | ||
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | /** | 52 | /** |
| 53 | + * @remark :获取关键字 | ||
| 54 | + * @name :getKeyword | ||
| 55 | + * @author :lyh | ||
| 56 | + * @method :post | ||
| 57 | + * @time :2024/3/14 14:46 | ||
| 58 | + */ | ||
| 59 | + public function getKeyword(){ | ||
| 60 | + $purchaserModel = new Purchaser(); | ||
| 61 | + $keywordList = $purchaserModel->select('keyword')->groupBy('keyword')->where('project_id', $this->user['project_id'])->get()->toArray(); | ||
| 62 | + $this->response('success',Code::SUCCESS,$keywordList); | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + /** | ||
| 52 | * @remark :请求黑格公共方法 | 66 | * @remark :请求黑格公共方法 |
| 53 | * @name :_action | 67 | * @name :_action |
| 54 | * @author :lyh | 68 | * @author :lyh |
| @@ -200,6 +214,8 @@ class SuppliersController extends BaseController | @@ -200,6 +214,8 @@ class SuppliersController extends BaseController | ||
| 200 | $action_name = 'trade_detail'; | 214 | $action_name = 'trade_detail'; |
| 201 | $param = [ | 215 | $param = [ |
| 202 | 'prod_desc'=>$this->param['prod_desc'] ?? '', | 216 | 'prod_desc'=>$this->param['prod_desc'] ?? '', |
| 217 | + 'page'=>$this->page, | ||
| 218 | + 'page_size'=>$this->row, | ||
| 203 | ]; | 219 | ]; |
| 204 | $res = $this->_action($api_url,$action_name,$param); | 220 | $res = $this->_action($api_url,$action_name,$param); |
| 205 | $this->response('success',Code::SUCCESS,$res); | 221 | $this->response('success',Code::SUCCESS,$res); |
| @@ -49,6 +49,10 @@ class LoginLogic extends BaseLogic | @@ -49,6 +49,10 @@ class LoginLogic extends BaseLogic | ||
| 49 | if (Manage::STATUS_DISABLE == $manage->status) { | 49 | if (Manage::STATUS_DISABLE == $manage->status) { |
| 50 | $this->fail('帐号已被禁用'); | 50 | $this->fail('帐号已被禁用'); |
| 51 | } | 51 | } |
| 52 | + $hrStatus = ManageHr::where('manage_id', $manage['id'])->value('status')?:1; | ||
| 53 | + if($hrStatus != ManageHr::STATUS_ONE){ | ||
| 54 | + $this->fail('当前员工已离职'); | ||
| 55 | + } | ||
| 52 | $type = 1;//账号密码登录 | 56 | $type = 1;//账号密码登录 |
| 53 | if (!Hash::check($this->param['password'], $manage->password)) { | 57 | if (!Hash::check($this->param['password'], $manage->password)) { |
| 54 | //验证验证码 | 58 | //验证验证码 |
| @@ -61,7 +65,6 @@ class LoginLogic extends BaseLogic | @@ -61,7 +65,6 @@ class LoginLogic extends BaseLogic | ||
| 61 | //生成新token | 65 | //生成新token |
| 62 | $token = md5(uniqid().$manage['id']); | 66 | $token = md5(uniqid().$manage['id']); |
| 63 | unset($manage['password']); | 67 | unset($manage['password']); |
| 64 | - Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6); | ||
| 65 | //更新用户信息 | 68 | //更新用户信息 |
| 66 | $manage->token = $token; | 69 | $manage->token = $token; |
| 67 | $res = $manage->save(); | 70 | $res = $manage->save(); |
| @@ -73,6 +76,7 @@ class LoginLogic extends BaseLogic | @@ -73,6 +76,7 @@ class LoginLogic extends BaseLogic | ||
| 73 | $manage['special'] = $this->getSpecialMenu($manage['id']); | 76 | $manage['special'] = $this->getSpecialMenu($manage['id']); |
| 74 | //岗位 | 77 | //岗位 |
| 75 | $manage['entry_position'] = ManageHr::where('manage_id', $manage['id'])->value('entry_position')?:0; | 78 | $manage['entry_position'] = ManageHr::where('manage_id', $manage['id'])->value('entry_position')?:0; |
| 79 | + Cache::add(Common::MANAGE_TOKEN . $token,$manage,3600 * 6); | ||
| 76 | return $this->success($manage->makeVisible('token')->toArray()); | 80 | return $this->success($manage->makeVisible('token')->toArray()); |
| 77 | } | 81 | } |
| 78 | 82 |
| @@ -33,6 +33,15 @@ class OnlineCheckLogic extends BaseLogic | @@ -33,6 +33,15 @@ class OnlineCheckLogic extends BaseLogic | ||
| 33 | //获取项目优化人员 | 33 | //获取项目优化人员 |
| 34 | $optimizeModel = new DeployOptimize(); | 34 | $optimizeModel = new DeployOptimize(); |
| 35 | $optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]); | 35 | $optimizeInfo = $optimizeModel->read(['project_id'=>$this->param['id']]); |
| 36 | + if(!empty($this->manager['special'])){ | ||
| 37 | + foreach ($this->manager['special'] as $value){ | ||
| 38 | + if($value['name'] == 'examine'){ | ||
| 39 | + $info['qa_mid'] = $this->manager['id']; | ||
| 40 | + $optimizeInfo['optimist_mid'] = $this->manager['id']; | ||
| 41 | + $optimizeInfo['assist_mid'] = $this->manager['id']; | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + } | ||
| 36 | //查看当前用户是否有权限审核 | 45 | //查看当前用户是否有权限审核 |
| 37 | if($this->param['type'] == 'optimist'){ | 46 | if($this->param['type'] == 'optimist'){ |
| 38 | if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){ | 47 | if(($optimizeInfo['optimist_mid'] != $this->manager['id']) && ($optimizeInfo['assist_mid'] != $this->manager['id'])){ |
| @@ -161,7 +161,6 @@ class ProjectLogic extends BaseLogic | @@ -161,7 +161,6 @@ class ProjectLogic extends BaseLogic | ||
| 161 | DB::rollBack(); | 161 | DB::rollBack(); |
| 162 | $this->fail('保存失败,请联系管理员'); | 162 | $this->fail('保存失败,请联系管理员'); |
| 163 | } | 163 | } |
| 164 | - | ||
| 165 | return $this->success(); | 164 | return $this->success(); |
| 166 | } | 165 | } |
| 167 | 166 | ||
| @@ -565,6 +564,9 @@ class ProjectLogic extends BaseLogic | @@ -565,6 +564,9 @@ class ProjectLogic extends BaseLogic | ||
| 565 | case Project::TYPE_ONE: | 564 | case Project::TYPE_ONE: |
| 566 | return Zone::pluck('title', 'id')->toArray(); | 565 | return Zone::pluck('title', 'id')->toArray(); |
| 567 | case Project::TYPE_TWO: | 566 | case Project::TYPE_TWO: |
| 567 | + if(isset($param['alias'])){ | ||
| 568 | + return Channel::where('alias', 'like' ,'%'.$param['alias'].'%')->pluck('alias', 'id')->toArray(); | ||
| 569 | + } | ||
| 568 | return Channel::where('zone_id', $param['zone_id']??0)->pluck('alias', 'id')->toArray(); | 570 | return Channel::where('zone_id', $param['zone_id']??0)->pluck('alias', 'id')->toArray(); |
| 569 | case Project::TYPE_THREE: | 571 | case Project::TYPE_THREE: |
| 570 | return User::where('channel_id', $param['channel_id']??0)->pluck('name', 'id')->toArray(); | 572 | return User::where('channel_id', $param['channel_id']??0)->pluck('name', 'id')->toArray(); |
| @@ -778,7 +780,7 @@ class ProjectLogic extends BaseLogic | @@ -778,7 +780,7 @@ class ProjectLogic extends BaseLogic | ||
| 778 | $token = $common->encrypt($param); | 780 | $token = $common->encrypt($param); |
| 779 | $res = Http::withoutVerifying()->get($url, ['token' => $token])->json(); | 781 | $res = Http::withoutVerifying()->get($url, ['token' => $token])->json(); |
| 780 | if(empty($res['code']) || $res['code'] != 200){ | 782 | if(empty($res['code']) || $res['code'] != 200){ |
| 781 | - $this->fail('ProjectToHagro error'); | 783 | + $this->fail($res['msg']); |
| 782 | } | 784 | } |
| 783 | return true; | 785 | return true; |
| 784 | } | 786 | } |
| @@ -46,7 +46,7 @@ class BTemplateModuleProjectLogic extends BaseLogic | @@ -46,7 +46,7 @@ class BTemplateModuleProjectLogic extends BaseLogic | ||
| 46 | public function moduleProjectSave(){ | 46 | public function moduleProjectSave(){ |
| 47 | try { | 47 | try { |
| 48 | $this->param['operator_id'] = $this->user['id']; | 48 | $this->param['operator_id'] = $this->user['id']; |
| 49 | - $this->param['project_id'] = $this->user['project_id']; | 49 | + $this->param['project_id'] = isset($this->param['project_id']) ? $this->param['project_id'] : $this->user['project_id']; |
| 50 | $this->model->add($this->param); | 50 | $this->model->add($this->param); |
| 51 | }catch (\Exception $e){ | 51 | }catch (\Exception $e){ |
| 52 | $this->fail('系统错误,请联系管理员'); | 52 | $this->fail('系统错误,请联系管理员'); |
| @@ -34,7 +34,7 @@ class TranslateLogic extends BaseLogic | @@ -34,7 +34,7 @@ class TranslateLogic extends BaseLogic | ||
| 34 | if($this->param['url'] == 'All'){ | 34 | if($this->param['url'] == 'All'){ |
| 35 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); | 35 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); |
| 36 | if(!empty($info) && !empty($info['data'])){ | 36 | if(!empty($info) && !empty($info['data'])){ |
| 37 | - $translateInfo = json_decode($info['data']); | 37 | + $translateInfo = json_decode($info['data'],true); |
| 38 | foreach ($translateInfo as $k => $v){ | 38 | foreach ($translateInfo as $k => $v){ |
| 39 | $data[] = [$k=>$v]; | 39 | $data[] = [$k=>$v]; |
| 40 | } | 40 | } |
| @@ -47,26 +47,18 @@ class TranslateLogic extends BaseLogic | @@ -47,26 +47,18 @@ class TranslateLogic extends BaseLogic | ||
| 47 | $languageInfo = $this->getLanguage($this->param['language_id']); | 47 | $languageInfo = $this->getLanguage($this->param['language_id']); |
| 48 | // 原始校对内容 | 48 | // 原始校对内容 |
| 49 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); | 49 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); |
| 50 | - //获取当前URl的所有文本内容 | ||
| 51 | - $text_array = $this->getUrlRead($url); | ||
| 52 | - // 原始校对程序 | ||
| 53 | - $old_key = [];//key值组成数据 | ||
| 54 | if($info !== false){ | 50 | if($info !== false){ |
| 55 | - $data_read = json_decode($info['data']); | 51 | + $data_read = json_decode($info['data'],true); |
| 56 | foreach ($data_read as $k => $v){ | 52 | foreach ($data_read as $k => $v){ |
| 57 | -// if(!in_array($k,$text_array)){ | ||
| 58 | -// $arr2[] = $k; | ||
| 59 | -// } | ||
| 60 | -// $old_key[] = $k; | ||
| 61 | $data[] = [$k => $v]; | 53 | $data[] = [$k => $v]; |
| 62 | } | 54 | } |
| 55 | + return $this->success($data); | ||
| 63 | }else{ | 56 | }else{ |
| 64 | - $arr2 = array_values(array_diff($text_array, $old_key)); | ||
| 65 | - } | ||
| 66 | - if(!empty($arr2)){ | 57 | + //获取当前URl的所有文本内容 |
| 58 | + $text_array = $this->getUrlRead($url); | ||
| 67 | $i = 0; | 59 | $i = 0; |
| 68 | TranslateText: | 60 | TranslateText: |
| 69 | - $translate_list = Translate::tran($arr2, $languageInfo['short']); | 61 | + $translate_list = Translate::tran($text_array, $languageInfo['short']); |
| 70 | if(empty($translate_list)){ | 62 | if(empty($translate_list)){ |
| 71 | if ($i < 3) { | 63 | if ($i < 3) { |
| 72 | $i++; | 64 | $i++; |
| @@ -74,21 +66,57 @@ class TranslateLogic extends BaseLogic | @@ -74,21 +66,57 @@ class TranslateLogic extends BaseLogic | ||
| 74 | } | 66 | } |
| 75 | $this->fail('翻译失败,请稍后重试!'); | 67 | $this->fail('翻译失败,请稍后重试!'); |
| 76 | } | 68 | } |
| 77 | - if(count($arr2) == 1){ | 69 | + if(count($text_array) == 1){ |
| 78 | $data[] = [ | 70 | $data[] = [ |
| 79 | - $arr2[0]=>$translate_list | 71 | + $text_array[0]=>$translate_list |
| 80 | ]; | 72 | ]; |
| 81 | }else{ | 73 | }else{ |
| 82 | - foreach ($arr2 as $k => $v){ | 74 | + foreach ($text_array as $k => $v){ |
| 83 | $data[] = [ | 75 | $data[] = [ |
| 84 | $v=>$translate_list[$k] | 76 | $v=>$translate_list[$k] |
| 85 | ]; | 77 | ]; |
| 86 | } | 78 | } |
| 87 | } | 79 | } |
| 80 | + return $this->success($data); | ||
| 88 | } | 81 | } |
| 89 | - return $this->success($data); | ||
| 90 | } | 82 | } |
| 91 | 83 | ||
| 84 | + // $old_key = [];//key值组成数据 | ||
| 85 | + // if($info !== false){ | ||
| 86 | + // $data_read = json_decode($info['data']); | ||
| 87 | + // foreach ($data_read as $k => $v){ | ||
| 88 | + //// if(!in_array($k,$text_array)){ | ||
| 89 | + //// $arr2[] = $k; | ||
| 90 | + //// } | ||
| 91 | + //// $old_key[] = $k; | ||
| 92 | + // $data[] = [$k => $v]; | ||
| 93 | + // } | ||
| 94 | + // }else{ | ||
| 95 | + // $arr2 = array_values(array_diff($text_array, $old_key)); | ||
| 96 | + // } | ||
| 97 | + // if(!empty($arr2)){ | ||
| 98 | + // $i = 0; | ||
| 99 | + // TranslateText: | ||
| 100 | + // $translate_list = Translate::tran($arr2, $languageInfo['short']); | ||
| 101 | + // if(empty($translate_list)){ | ||
| 102 | + // if ($i < 3) { | ||
| 103 | + // $i++; | ||
| 104 | + // goto TranslateText; | ||
| 105 | + // } | ||
| 106 | + // $this->fail('翻译失败,请稍后重试!'); | ||
| 107 | + // } | ||
| 108 | + // if(count($arr2) == 1){ | ||
| 109 | + // $data[] = [ | ||
| 110 | + // $arr2[0]=>$translate_list | ||
| 111 | + // ]; | ||
| 112 | + // }else{ | ||
| 113 | + // foreach ($arr2 as $k => $v){ | ||
| 114 | + // $data[] = [ | ||
| 115 | + // $v=>$translate_list[$k] | ||
| 116 | + // ]; | ||
| 117 | + // } | ||
| 118 | + // } | ||
| 119 | + // } | ||
| 92 | 120 | ||
| 93 | /** | 121 | /** |
| 94 | * @remark :获取图片列表 | 122 | * @remark :获取图片列表 |
| @@ -102,7 +130,7 @@ class TranslateLogic extends BaseLogic | @@ -102,7 +130,7 @@ class TranslateLogic extends BaseLogic | ||
| 102 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); | 130 | $info = $this->model->read(['url'=>$this->param['url'],'language_id'=>$this->param['language_id'],'type'=>$this->param['type']]); |
| 103 | $data = []; | 131 | $data = []; |
| 104 | if(!empty($info) && !empty($info['data'])){ | 132 | if(!empty($info) && !empty($info['data'])){ |
| 105 | - $translateInfo = json_decode($info['data']); | 133 | + $translateInfo = json_decode($info['data'],true); |
| 106 | foreach ($translateInfo as $k => $v){ | 134 | foreach ($translateInfo as $k => $v){ |
| 107 | $data[] = [$k=>$v]; | 135 | $data[] = [$k=>$v]; |
| 108 | } | 136 | } |
| @@ -123,7 +151,7 @@ class TranslateLogic extends BaseLogic | @@ -123,7 +151,7 @@ class TranslateLogic extends BaseLogic | ||
| 123 | } | 151 | } |
| 124 | $new_list = $this->getUrlImageRead($url); | 152 | $new_list = $this->getUrlImageRead($url); |
| 125 | $old_list = []; | 153 | $old_list = []; |
| 126 | - $data_read = json_decode($info['data']); | 154 | + $data_read = json_decode($info['data'],true); |
| 127 | foreach ($data_read as $k=>$v){ | 155 | foreach ($data_read as $k=>$v){ |
| 128 | $old_list[] = $k; | 156 | $old_list[] = $k; |
| 129 | $data[] = [ | 157 | $data[] = [ |
| @@ -254,10 +282,10 @@ class TranslateLogic extends BaseLogic | @@ -254,10 +282,10 @@ class TranslateLogic extends BaseLogic | ||
| 254 | 'language_id'=>$this->param['language_id'], | 282 | 'language_id'=>$this->param['language_id'], |
| 255 | 'alias'=>$this->param['alias'], | 283 | 'alias'=>$this->param['alias'], |
| 256 | ]; | 284 | ]; |
| 257 | - $param['data'] = json_encode($data); | 285 | + $param['data'] = json_encode($data,true); |
| 258 | $this->model->add($param); | 286 | $this->model->add($param); |
| 259 | }else{ | 287 | }else{ |
| 260 | - $data = json_encode($data); | 288 | + $data = json_encode($data,true); |
| 261 | $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]); | 289 | $this->model->edit(['data'=>$data],['language_id'=>$this->param['language_id'],'url'=>$this->param['url'],'type'=>$this->param['type']]); |
| 262 | } | 290 | } |
| 263 | }catch (\Exception $e){ | 291 | }catch (\Exception $e){ |
| @@ -227,9 +227,10 @@ class Project extends Base | @@ -227,9 +227,10 @@ class Project extends Base | ||
| 227 | */ | 227 | */ |
| 228 | public function domainInfo() | 228 | public function domainInfo() |
| 229 | { | 229 | { |
| 230 | - return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'project_id')->select('project_id', 'domain');; | 230 | + return self::hasOne(\App\Models\Domain\DomainInfo::class, 'project_id', 'id')->select('project_id', 'domain'); |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | + | ||
| 233 | public function setLevelAttribute($value) | 234 | public function setLevelAttribute($value) |
| 234 | { | 235 | { |
| 235 | $this->attributes['level'] = Arr::arrToSet($value); | 236 | $this->attributes['level'] = Arr::arrToSet($value); |
| @@ -321,12 +322,16 @@ class Project extends Base | @@ -321,12 +322,16 @@ class Project extends Base | ||
| 321 | $project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id'); | 322 | $project_id = DeployBuild::where('test_domain', 'https://' . $domain . '/')->value('project_id'); |
| 322 | //是否正式域名 | 323 | //是否正式域名 |
| 323 | if (!$project_id) { | 324 | if (!$project_id) { |
| 324 | - //是否小语种域名 | 325 | + //是否小语种域名或amp站域名 |
| 325 | $domainPrefix = explode(".",$domain); | 326 | $domainPrefix = explode(".",$domain); |
| 326 | if (!empty($domainPrefix)){ | 327 | if (!empty($domainPrefix)){ |
| 327 | - $isLang = Translate::getTls($domainPrefix[0]); | ||
| 328 | - if ($isLang) { | 328 | + if($domainPrefix[0] == 'm'){ |
| 329 | $domain = "www.".$domainPrefix[1].".".$domainPrefix[2]; | 329 | $domain = "www.".$domainPrefix[1].".".$domainPrefix[2]; |
| 330 | + }else{ | ||
| 331 | + $isLang = Translate::getTls($domainPrefix[0]); | ||
| 332 | + if ($isLang) { | ||
| 333 | + $domain = "www.".$domainPrefix[1].".".$domainPrefix[2]; | ||
| 334 | + } | ||
| 330 | } | 335 | } |
| 331 | } | 336 | } |
| 332 | $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id'); | 337 | $project_id = \App\Models\Domain\DomainInfo::where('domain', $domain)->value('project_id'); |
| @@ -32,4 +32,20 @@ class WebLanguage extends Base | @@ -32,4 +32,20 @@ class WebLanguage extends Base | ||
| 32 | } | 32 | } |
| 33 | return $lang; | 33 | return $lang; |
| 34 | } | 34 | } |
| 35 | + | ||
| 36 | + /** | ||
| 37 | + * @param $lang | ||
| 38 | + * @return mixed | ||
| 39 | + * @author zbj | ||
| 40 | + * @date 2023/12/11 | ||
| 41 | + */ | ||
| 42 | + public static function getIdByLang($lang){ | ||
| 43 | + $cache_key = 'lang_id_'.$lang; | ||
| 44 | + $id = Cache::get($cache_key); | ||
| 45 | + if(!$id){ | ||
| 46 | + $id = self::where('short', $lang)->value('id'); | ||
| 47 | + Cache::put($cache_key, $id, 7200); | ||
| 48 | + } | ||
| 49 | + return $id; | ||
| 50 | + } | ||
| 35 | } | 51 | } |
| @@ -72,17 +72,24 @@ class CosService | @@ -72,17 +72,24 @@ class CosService | ||
| 72 | * @param $file_url | 72 | * @param $file_url |
| 73 | * @param $key | 73 | * @param $key |
| 74 | * @param $body_str | 74 | * @param $body_str |
| 75 | + * @param int $same_name 是否保持名称一直 | ||
| 75 | * @return string | 76 | * @return string |
| 76 | * @author Akun | 77 | * @author Akun |
| 77 | * @date 2023/09/21 9:39 | 78 | * @date 2023/09/21 9:39 |
| 78 | */ | 79 | */ |
| 79 | - public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='') | 80 | + public static function uploadRemote($project_id,$image_type,$file_url,$key='',$body_str='',$same_name=0) |
| 80 | { | 81 | { |
| 81 | if(!$key){ | 82 | if(!$key){ |
| 82 | $url_arr = parse_url($file_url); | 83 | $url_arr = parse_url($file_url); |
| 83 | - $ext = explode('.',$url_arr['path']); | ||
| 84 | 84 | ||
| 85 | - $filename = uniqid().rand(10000,99999).'.'.end($ext); | 85 | + if($same_name){ |
| 86 | + $path_arr = explode('/',$url_arr['path']); | ||
| 87 | + $filename = end($path_arr); | ||
| 88 | + }else{ | ||
| 89 | + $ext = explode('.',$url_arr['path']); | ||
| 90 | + | ||
| 91 | + $filename = uniqid().rand(10000,99999).'.'.end($ext); | ||
| 92 | + } | ||
| 86 | 93 | ||
| 87 | $uploads = config('upload.default_file'); | 94 | $uploads = config('upload.default_file'); |
| 88 | $path = $uploads['path_b'].'/'.$project_id.'/'.$image_type.'/'.date('Y-m'); | 95 | $path = $uploads['path_b'].'/'.$project_id.'/'.$image_type.'/'.date('Y-m'); |
| @@ -32,6 +32,7 @@ Route::middleware(['bloginauth'])->group(function () { | @@ -32,6 +32,7 @@ Route::middleware(['bloginauth'])->group(function () { | ||
| 32 | Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail'); | 32 | Route::any('/trade_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'trade_detail'])->name('suppliers_trade_detail'); |
| 33 | Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail'); | 33 | Route::any('/bill_detail',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'bill_detail'])->name('suppliers_bill_detail'); |
| 34 | Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product'); | 34 | Route::any('/import_product',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'import_product'])->name('suppliers_import_product'); |
| 35 | + Route::any('/getKeyword',[\App\Http\Controllers\Bside\Suppliers\SuppliersController::class, 'getKeyword'])->name('suppliers_getKeyword'); | ||
| 35 | }); | 36 | }); |
| 36 | //用户相关路由 | 37 | //用户相关路由 |
| 37 | Route::prefix('user')->group(function () { | 38 | Route::prefix('user')->group(function () { |
-
请 注册 或 登录 后发表评论