作者 张关杰

Merge branch 'develop' of http://47.244.231.31:8099/zhl/globalso-v6 into bate

@@ -7,6 +7,7 @@ use App\Models\ProjectAssociation\ProjectAssociation; @@ -7,6 +7,7 @@ use App\Models\ProjectAssociation\ProjectAssociation;
7 use App\Services\CosService; 7 use App\Services\CosService;
8 use Barryvdh\DomPDF\Facade\Pdf; 8 use Barryvdh\DomPDF\Facade\Pdf;
9 use Illuminate\Console\Command; 9 use Illuminate\Console\Command;
  10 +use Illuminate\Support\Facades\DB;
10 11
11 class GeneratePdfData extends Command 12 class GeneratePdfData extends Command
12 { 13 {
@@ -66,6 +67,8 @@ class GeneratePdfData extends Command @@ -66,6 +67,8 @@ class GeneratePdfData extends Command
66 sleep(60); 67 sleep(60);
67 return 0; 68 return 0;
68 } 69 }
  70 + DB::beginTransaction();
  71 + try {
69 $pdfFile = new PdfFile(); 72 $pdfFile = new PdfFile();
70 $bool = $pdfFile->saveData(['pid' => $list->id]); 73 $bool = $pdfFile->saveData(['pid' => $list->id]);
71 if (!$bool) { 74 if (!$bool) {
@@ -74,7 +77,12 @@ class GeneratePdfData extends Command @@ -74,7 +77,12 @@ class GeneratePdfData extends Command
74 } 77 }
75 $list->m_status = $month; 78 $list->m_status = $month;
76 $list->save(); 79 $list->save();
77 - $this->info('生成v6绑定的aicc用户的pdf备用数据添加成功'); 80 + DB::commit();
  81 + $this->info('生成v6绑定的aicc用户的pdf备用数据添加成功 - ' . $list->id);
  82 + } catch (\Exception $exception) {
  83 + DB::rollBack();
  84 + $this->error('生成v6绑定的aicc用户的pdf备用数据添加失败 - ' . $list->id);
  85 + }
78 return 0; 86 return 0;
79 } 87 }
80 } 88 }
@@ -5,9 +5,11 @@ namespace App\Console\Commands\GeneratePDF; @@ -5,9 +5,11 @@ namespace App\Console\Commands\GeneratePDF;
5 use App\Models\File\PdfFile; 5 use App\Models\File\PdfFile;
6 use App\Models\ProjectAssociation\ProjectAssociation; 6 use App\Models\ProjectAssociation\ProjectAssociation;
7 use App\Services\CosService; 7 use App\Services\CosService;
  8 +use App\Services\ProjectServer;
8 use Barryvdh\DomPDF\Facade\Pdf; 9 use Barryvdh\DomPDF\Facade\Pdf;
9 use Illuminate\Console\Command; 10 use Illuminate\Console\Command;
10 use Illuminate\Http\File; 11 use Illuminate\Http\File;
  12 +use Illuminate\Support\Facades\DB;
11 13
12 class ProjectFilePDF extends Command 14 class ProjectFilePDF extends Command
13 { 15 {
@@ -48,7 +50,6 @@ class ProjectFilePDF extends Command @@ -48,7 +50,6 @@ class ProjectFilePDF extends Command
48 50
49 public function handle() 51 public function handle()
50 { 52 {
51 -  
52 // 开始时间 53 // 开始时间
53 $startTime = microtime(true); 54 $startTime = microtime(true);
54 55
@@ -105,6 +106,12 @@ class ProjectFilePDF extends Command @@ -105,6 +106,12 @@ class ProjectFilePDF extends Command
105 $friend_id = $isExists->friend_id; 106 $friend_id = $isExists->friend_id;
106 // todo 根据项目查询数据 107 // todo 根据项目查询数据
107 $project_data = []; 108 $project_data = [];
  109 + //获取当前数据详情
  110 + $res = ProjectServer::useProject($project_id);
  111 + if ($res) {
  112 + $project_data = [];
  113 + }
  114 + DB::disconnect('custom_mysql');
108 $html = $this->html($project_data); 115 $html = $this->html($project_data);
109 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id); 116 $filename = hash('md5', $this->time . '-' . $project_id . '-' . $friend_id . '-' . $user_id);
110 117
@@ -169,7 +176,14 @@ class ProjectFilePDF extends Command @@ -169,7 +176,14 @@ class ProjectFilePDF extends Command
169 */ 176 */
170 protected function html($item) 177 protected function html($item)
171 { 178 {
172 - $font_path = storage_path('fonts\msyh.ttf');  
173 - return '<html><head><title>Laravel</title><meta http-equiv=\'Content-Type\' content=\'text/html; charset=utf-8\'/><style>body{ font-family: \'msyh\'; } @font-face { font-family: \'msyh\'; font-style: normal; font-weight: normal; src: url(' . $font_path . ') format(\'truetype\'); }</style></head><body><div class=\'container\'><div class=\'content\'><p style=\'font-family: msyh, DejaVu Sans,sans-serif;\'>献给母亲的爱</p><div style=\'font-family: msyh, DejaVu Sans,sans-serif;\' class=\'title\'>Laravel 5中文测试sdsd</div><div class=\'title\'>测试三askjdhfkjasdhf</div></div></div></body></html>'; 179 + $html = @file_get_contents(dirname(__FILE__) . '/pdf_template.html');
  180 + if (empty($html)) {
  181 + return '';
  182 + }
  183 + $rep = [
  184 + 'ENTRY_NAME' => '测试项目',
  185 + 'NUMBER' => 1000,
  186 + ];
  187 + return str_replace(array_keys($rep), array_values($rep), $html);
174 } 188 }
175 } 189 }
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +<head>
  4 + <meta charset="UTF-8">
  5 + <title>网站数据</title>
  6 + <style>
  7 + @font-face {
  8 + font-family: 'msyh';
  9 + font-style: normal;
  10 + font-weight: normal;
  11 + src: url(../../../../storage/fonts/msyh.ttf) format('truetype');
  12 + }
  13 + body {
  14 + font-family: 'msyh';
  15 + }
  16 +
  17 + </style>
  18 +</head>
  19 +<body>
  20 + 项目名称:ENTRY_NAME<br>
  21 + 数量:NUMBER
  22 +</body>
  23 +</html>
@@ -55,7 +55,7 @@ class InitProject extends Command @@ -55,7 +55,7 @@ class InitProject extends Command
55 $project = Project::find($item['data']['project_id']); 55 $project = Project::find($item['data']['project_id']);
56 $project_logic = new ProjectLogic(); 56 $project_logic = new ProjectLogic();
57 //初始化数据库 57 //初始化数据库
58 - if(!empty($project['mysql_id'])){ 58 + if(!empty($project['mysql_id']) && ($project['type'] == 1)){
59 $project_logic->initializationMysql($project['id']); 59 $project_logic->initializationMysql($project['id']);
60 } 60 }
61 //初始账号 61 //初始账号
@@ -7,6 +7,7 @@ use App\Helper\SemrushApi; @@ -7,6 +7,7 @@ use App\Helper\SemrushApi;
7 use App\Models\Domain\DomainInfo; 7 use App\Models\Domain\DomainInfo;
8 use App\Models\RankData\ExternalLinks as ExternalLinksModel; 8 use App\Models\RankData\ExternalLinks as ExternalLinksModel;
9 use App\Models\Project\DeployOptimize; 9 use App\Models\Project\DeployOptimize;
  10 +use App\Utils\HttpUtils;
10 use App\Utils\LogUtils; 11 use App\Utils\LogUtils;
11 12
12 /** 13 /**
@@ -40,9 +41,12 @@ class ExternalLinks extends BaseCommands @@ -40,9 +41,12 @@ class ExternalLinks extends BaseCommands
40 $error = 0; 41 $error = 0;
41 $semrushApi = new SemrushApi(); 42 $semrushApi = new SemrushApi();
42 //有排名api编号的项目 43 //有排名api编号的项目
43 - $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 44 + $list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
44 LogUtils::info('start rank_data_external_links:' . count($list)); 45 LogUtils::info('start rank_data_external_links:' . count($list));
45 - foreach ($list as $project_id => $domain) { 46 + foreach ($list as $item) {
  47 + $project_id = $item['project_id'];
  48 + $api_no = $item['api_no'];
  49 + $domain = $item['domain'];
46 if(!$domain){ 50 if(!$domain){
47 continue; 51 continue;
48 } 52 }
@@ -54,6 +58,16 @@ class ExternalLinks extends BaseCommands @@ -54,6 +58,16 @@ class ExternalLinks extends BaseCommands
54 $model = new ExternalLinksModel(); 58 $model = new ExternalLinksModel();
55 } 59 }
56 60
  61 +
  62 + //5.0
  63 + try {
  64 + $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
  65 + $data = Arr::s2a($data);
  66 + }catch (\Exception $e){
  67 + $data = [];
  68 + }
  69 +
  70 + if(!$data){
57 //外链数据 71 //外链数据
58 $domain = (new DomainInfo())->getDomain($domain); 72 $domain = (new DomainInfo())->getDomain($domain);
59 $res = $semrushApi->backlinks_overview($domain); 73 $res = $semrushApi->backlinks_overview($domain);
@@ -63,6 +77,7 @@ class ExternalLinks extends BaseCommands @@ -63,6 +77,7 @@ class ExternalLinks extends BaseCommands
63 } 77 }
64 78
65 $data = $this->_data($project_id, $res['total']); 79 $data = $this->_data($project_id, $res['total']);
  80 + }
66 81
67 $model->project_id = $project_id; 82 $model->project_id = $project_id;
68 $model->total = $data['total']; 83 $model->total = $data['total'];
@@ -2,10 +2,12 @@ @@ -2,10 +2,12 @@
2 2
3 namespace App\Console\Commands\RankData; 3 namespace App\Console\Commands\RankData;
4 4
  5 +use App\Helper\Arr;
5 use App\Helper\SemrushApi; 6 use App\Helper\SemrushApi;
6 use App\Models\Domain\DomainInfo; 7 use App\Models\Domain\DomainInfo;
7 use App\Models\RankData\RecommDomain as RecommDomainModel; 8 use App\Models\RankData\RecommDomain as RecommDomainModel;
8 use App\Models\Project\DeployOptimize; 9 use App\Models\Project\DeployOptimize;
  10 +use App\Utils\HttpUtils;
9 use App\Utils\LogUtils; 11 use App\Utils\LogUtils;
10 12
11 /** 13 /**
@@ -39,9 +41,12 @@ class RecommDomain extends BaseCommands @@ -39,9 +41,12 @@ class RecommDomain extends BaseCommands
39 $error = 0; 41 $error = 0;
40 $semrushApi = new SemrushApi(); 42 $semrushApi = new SemrushApi();
41 //有排名api编号的项目 43 //有排名api编号的项目
42 - $list = DeployOptimize::where('api_no', '>', 0)->pluck('domain', 'project_id')->toArray(); 44 + $list = DeployOptimize::where('api_no', '>', 0)->select('domain', 'api_no', 'project_id')->get()->toArray();
43 LogUtils::info('start rank_data_recomm_domain:' . count($list)); 45 LogUtils::info('start rank_data_recomm_domain:' . count($list));
44 - foreach ($list as $project_id => $domain) { 46 + foreach ($list as $item) {
  47 + $project_id = $item['project_id'];
  48 + $api_no = $item['api_no'];
  49 + $domain = $item['domain'];
45 if(!$domain){ 50 if(!$domain){
46 continue; 51 continue;
47 } 52 }
@@ -53,9 +58,20 @@ class RecommDomain extends BaseCommands @@ -53,9 +58,20 @@ class RecommDomain extends BaseCommands
53 $model = new RecommDomainModel(); 58 $model = new RecommDomainModel();
54 } 59 }
55 60
  61 + //5.0
  62 + try {
  63 + $data = HttpUtils::get("https://www.quanqiusou.cn/semrush-api/data_json/{$api_no}.json", []);
  64 + $data = Arr::s2a($data)['list'];
  65 + }catch (\Exception $e){
  66 + $data = [];
  67 + }
  68 +
  69 + if(!$data){
56 //外链引荐域名 70 //外链引荐域名
57 $domain = (new DomainInfo())->getDomain($domain); 71 $domain = (new DomainInfo())->getDomain($domain);
58 $data = $semrushApi->backlinks_refdomains($domain); 72 $data = $semrushApi->backlinks_refdomains($domain);
  73 + }
  74 +
59 if (!$data) { 75 if (!$data) {
60 $error++; 76 $error++;
61 continue; 77 continue;
@@ -138,7 +138,7 @@ class HtmlCollect extends Command @@ -138,7 +138,7 @@ class HtmlCollect extends Command
138 } 138 }
139 139
140 140
141 - $update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('project_id', 'asc')->first(); 141 + $update_log = UpdateLog::where('status', UpdateLog::STATUS_COM)->where('collect_status', UpdateLog::COLLECT_STATUS_UN)->orderBy('updated_at', 'asc')->first();
142 if (!$update_log) { 142 if (!$update_log) {
143 return false; 143 return false;
144 } 144 }
@@ -292,7 +292,7 @@ class ProjectUpdate extends Command @@ -292,7 +292,7 @@ class ProjectUpdate extends Command
292 'route' => $route 292 'route' => $route
293 ]); 293 ]);
294 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id); 294 $this->set_map($route, RouteMap::SOURCE_PRODUCT, $id, $project_id);
295 - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $link_type, $language_list, $page_list); 295 + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PRODUCT, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
296 } else { 296 } else {
297 $id = $product['id']; 297 $id = $product['id'];
298 $model->edit([ 298 $model->edit([
@@ -418,7 +418,7 @@ class ProjectUpdate extends Command @@ -418,7 +418,7 @@ class ProjectUpdate extends Command
418 ]); 418 ]);
419 $this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id); 419 $this->set_map($route, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $project_id);
420 420
421 - CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $link_type, $language_list, $page_list); 421 + CollectTask::_insert($item['url'], $project_id, $api_type == 'news' ? RouteMap::SOURCE_NEWS : RouteMap::SOURCE_BLOG, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
422 } else { 422 } else {
423 $id = $news['id']; 423 $id = $news['id'];
424 $model->edit([ 424 $model->edit([
@@ -483,7 +483,7 @@ class ProjectUpdate extends Command @@ -483,7 +483,7 @@ class ProjectUpdate extends Command
483 ]); 483 ]);
484 $this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id); 484 $this->set_map($route, RouteMap::SOURCE_PAGE, $id, $project_id);
485 485
486 - CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $link_type, $language_list, $page_list); 486 + CollectTask::_insert($item['url'], $project_id, RouteMap::SOURCE_PAGE, $id, $domain_arr['host'], $link_type, $language_list, $page_list);
487 } else { 487 } else {
488 $id = $custom['id']; 488 $id = $custom['id'];
489 $model->edit([ 489 $model->edit([
@@ -527,7 +527,7 @@ class ProjectUpdate extends Command @@ -527,7 +527,7 @@ class ProjectUpdate extends Command
527 return $task_id; 527 return $task_id;
528 } 528 }
529 529
530 - $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('project_id', 'asc')->limit(20)->get(); 530 + $task_list = UpdateLog::where('status', UpdateLog::STATUS_UN)->orderBy('sort', 'asc')->orderBy('updated_at', 'asc')->limit(20)->get();
531 if ($task_list->count() == 0) { 531 if ($task_list->count() == 0) {
532 return false; 532 return false;
533 } 533 }
@@ -689,8 +689,6 @@ class ProjectUpdate extends Command @@ -689,8 +689,6 @@ class ProjectUpdate extends Command
689 $host = $arr['host'] ?? ''; 689 $host = $arr['host'] ?? '';
690 $path = $arr['path'] ?? ''; 690 $path = $arr['path'] ?? '';
691 691
692 - $url_complete = ($scheme ?: 'https') . '://' . $domain . $path;  
693 -  
694 if ( 692 if (
695 (empty($scheme) || $scheme == 'https' || $scheme == 'http') 693 (empty($scheme) || $scheme == 'https' || $scheme == 'http')
696 && (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false)) 694 && (empty($host) || (strpos($web_url_domain, $host) !== false) || (strpos($home_url, $host) !== false))
@@ -698,6 +696,10 @@ class ProjectUpdate extends Command @@ -698,6 +696,10 @@ class ProjectUpdate extends Command
698 ) { 696 ) {
699 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first(); 697 $source = CollectSource::where('project_id', $project_id)->where('origin', $url)->first();
700 if (!$source) { 698 if (!$source) {
  699 + if (empty($scheme) && empty($host) && substr($path, 0, 1) != '/') {
  700 + $path = '/' . $path;
  701 + }
  702 + $url_complete = ($scheme ?: 'https') . '://' . $domain . $path;
701 $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete); 703 $new_url = CosService::uploadRemote($project_id, 'image_product', $url_complete);
702 704
703 if ($new_url) { 705 if ($new_url) {
@@ -717,7 +719,7 @@ class ProjectUpdate extends Command @@ -717,7 +719,7 @@ class ProjectUpdate extends Command
717 return getImageUrl($source['target']); 719 return getImageUrl($source['target']);
718 } 720 }
719 } else { 721 } else {
720 - return $url_complete; 722 + return ($scheme ?: 'https') . '://' . ($host ?: $domain) . $path;
721 } 723 }
722 } 724 }
723 725
@@ -12,6 +12,8 @@ namespace App\Console\Commands; @@ -12,6 +12,8 @@ namespace App\Console\Commands;
12 use App\Models\Blog\Blog; 12 use App\Models\Blog\Blog;
13 use App\Models\Blog\BlogCategory; 13 use App\Models\Blog\BlogCategory;
14 use App\Models\CustomModule\CustomModule; 14 use App\Models\CustomModule\CustomModule;
  15 +use App\Models\CustomModule\CustomModuleCategory;
  16 +use App\Models\CustomModule\CustomModuleContent;
15 use App\Models\News\News; 17 use App\Models\News\News;
16 use App\Models\News\NewsCategory; 18 use App\Models\News\NewsCategory;
17 use App\Models\Product\Category; 19 use App\Models\Product\Category;
@@ -57,31 +59,85 @@ class UpdateMainHtml extends Command @@ -57,31 +59,85 @@ class UpdateMainHtml extends Command
57 */ 59 */
58 public function handle(){ 60 public function handle(){
59 $projectModel = new Project(); 61 $projectModel = new Project();
60 - $list = $projectModel->list(['type'=>['!=',0]]); 62 + $list = $projectModel->list(['id'=>99]);
61 foreach ($list as $v){ 63 foreach ($list as $v){
62 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 64 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
63 ProjectServer::useProject($v['id']); 65 ProjectServer::useProject($v['id']);
64 - $this->initModule($v['id']); 66 + $this->editRoute();
65 DB::disconnect('custom_mysql'); 67 DB::disconnect('custom_mysql');
66 } 68 }
67 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL; 69 echo date('Y-m-d H:i:s') . 'end' . PHP_EOL;
68 } 70 }
69 71
70 - public function initModule($project_id){  
71 - $moduleModel = new CustomModule();  
72 - $info = $moduleModel->read(['route'=>'video']);  
73 - if($info === false){  
74 - $info = $moduleModel->read(['name'=>'视频模块']);  
75 - if($info === false){  
76 - $data = [  
77 - 'name'=>'视频模块',  
78 - 'project_id'=>$project_id,  
79 - 'route'=>'video', 72 + /**
  73 + * @remark :所有博客数据添加到自定义模块
  74 + * @name :setBlogCustom
  75 + * @author :lyh
  76 + * @method :post
  77 + * @time :2024/1/5 10:21
  78 + */
  79 + public function setBlogCustom(){
  80 + $data = [];
  81 + $blogCategoryModel = new BlogCategory();
  82 + $list = $blogCategoryModel->list(['status'=>0]);
  83 + foreach ($list as $v){
  84 + echo date('Y-m-d H:i:s') . '博客分类id:'.$v['id'] . PHP_EOL;
  85 + $data[] = [
  86 + 'name'=>$v['name'],
  87 + 'route'=>$v['alias'],
  88 + 'project_id'=>99,
  89 + 'operator_id'=>366,
  90 + 'seo_title'=>$v['seo_title'],
  91 + 'seo_keywords'=>$v['seo_keywords'],
  92 + 'seo_description'=>$v['seo_des'],
  93 + 'created_at'=>$v['created_at'],
  94 + 'updated_at'=>$v['updated_at'],
  95 + 'module_id'=>7
80 ]; 96 ];
81 - $moduleModel->add($data);  
82 } 97 }
  98 + $cate = new CustomModuleCategory();
  99 + $cate->insert($data);
83 } 100 }
  101 +
  102 + /**
  103 + * @remark :所有博客数据添加到自定义模块
  104 + * @name :setBlogCustom
  105 + * @author :lyh
  106 + * @method :post
  107 + * @time :2024/1/5 10:21
  108 + */
  109 + public function setBlogCustomContent(){
  110 + $data = [];
  111 + $blogModel = new Blog();
  112 + $list = $blogModel->list(['status'=>1]);
  113 + foreach ($list as $v){
  114 + echo date('Y-m-d H:i:s') . '博客分类id:'.$v['id'] . PHP_EOL;
  115 + $data[] = [
  116 + 'name'=>$v['name'],
  117 + 'content'=>$v['text'],
  118 + 'remark'=>$v['remark'],
  119 + 'route'=>$v['url'],
  120 + 'image'=>$v['image'],
  121 + 'project_id'=>99,
  122 + 'operator_id'=>366,
  123 + 'seo_title'=>$v['seo_title'],
  124 + 'seo_keywords'=>$v['seo_keywords'],
  125 + 'seo_description'=>$v['seo_description'],
  126 + 'created_at'=>$v['created_at'],
  127 + 'updated_at'=>$v['updated_at'],
  128 + 'module_id'=>7,
  129 + 'category_id'=>$v['category_id']
  130 + ];
  131 + }
  132 + $content = new CustomModuleContent();
  133 + $content->insert($data);
84 return true; 134 return true;
85 } 135 }
86 136
  137 + public function editRoute(){
  138 + $routeMap = new RouteMap();
  139 + $routeMap->edit(['source'=>RouteMap::SOURCE_MODULE,'blog'=>''],['source'=>'blog']);
  140 + $routeMap->edit(['source'=>RouteMap::SOURCE_MODULE_CATE,'blog'=>''],['source'=>'blog_category']);
  141 + return true;
  142 + }
87 } 143 }
@@ -10,11 +10,6 @@ @@ -10,11 +10,6 @@
10 namespace App\Console\Commands; 10 namespace App\Console\Commands;
11 11
12 use App\Helper\Arr; 12 use App\Helper\Arr;
13 -use App\Models\Blog\Blog;  
14 -use App\Models\Blog\BlogCategory;  
15 -use App\Models\News\News;  
16 -use App\Models\News\NewsCategory;  
17 -use App\Models\Product\Category;  
18 use App\Models\Product\CategoryRelated; 13 use App\Models\Product\CategoryRelated;
19 use App\Models\Product\Keyword; 14 use App\Models\Product\Keyword;
20 use App\Models\Product\Product; 15 use App\Models\Product\Product;
@@ -56,7 +51,7 @@ class UpdateRoute extends Command @@ -56,7 +51,7 @@ class UpdateRoute extends Command
56 */ 51 */
57 public function handle(){ 52 public function handle(){
58 $projectModel = new Project(); 53 $projectModel = new Project();
59 - $list = $projectModel->list(['id'=>['in',[475]]]); 54 + $list = $projectModel->list(['id'=>475]);
60 foreach ($list as $v){ 55 foreach ($list as $v){
61 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL; 56 echo date('Y-m-d H:i:s') . 'project_id:'.$v['id'] . PHP_EOL;
62 ProjectServer::useProject($v['id']); 57 ProjectServer::useProject($v['id']);
@@ -168,7 +163,7 @@ class UpdateRoute extends Command @@ -168,7 +163,7 @@ class UpdateRoute extends Command
168 */ 163 */
169 public function getProductCategory(){ 164 public function getProductCategory(){
170 $product = new Product(); 165 $product = new Product();
171 - $num = 35; 166 + $num = 30;
172 while ($num > 0){ 167 while ($num > 0){
173 $list = $product->lists(['status'=>1],$num,1000); 168 $list = $product->lists(['status'=>1],$num,1000);
174 foreach ($list['list'] as $k => $v){ 169 foreach ($list['list'] as $k => $v){
@@ -230,5 +225,4 @@ class UpdateRoute extends Command @@ -230,5 +225,4 @@ class UpdateRoute extends Command
230 return true; 225 return true;
231 } 226 }
232 227
233 -  
234 } 228 }
@@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel
18 // $schedule->command('inspire')->hourly(); 18 // $schedule->command('inspire')->hourly();
19 $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长 19 $schedule->command('remain_day')->dailyAt('03:00')->withoutOverlapping(1); // 项目剩余服务时长
20 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务 20 $schedule->command('rank_data_task')->everyMinute()->withoutOverlapping(1); // 排名数据更新任务
21 - $schedule->command('rank_data')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次 21 + $schedule->command('rank_data')->dailyAt('07:00')->withoutOverlapping(1); // 排名数据,每天凌晨执行一次
22 $schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次 22 $schedule->command('rank_data_speed')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-测速数据,每周一凌晨执行一次
23 $schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次 23 $schedule->command('rank_data_external_links')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-外链,每周一凌晨执行一次
24 $schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次 24 $schedule->command('rank_data_indexed_pages')->dailyAt('01:00')->withoutOverlapping(1); // 排名数据-页面收录,每周一凌晨执行一次
@@ -103,7 +103,7 @@ class QuanqiusouApi @@ -103,7 +103,7 @@ class QuanqiusouApi
103 Cache::put($key, $res, 2 * 3600); 103 Cache::put($key, $res, 2 * 3600);
104 } 104 }
105 } catch (\Exception | GuzzleException $e) { 105 } catch (\Exception | GuzzleException $e) {
106 - errorLog('获取谷歌排名数据失败', $api_no, $e); 106 + errorLog('获取谷歌排名数据失败', [$api_no], $e);
107 return false; 107 return false;
108 } 108 }
109 } 109 }
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/1/4
  6 + * Time: 16:25
  7 + */
  8 +namespace App\Http\Controllers\Api;
  9 +
  10 +use App\Http\Controllers\Controller;
  11 +
  12 +/**
  13 + * Class BaseController
  14 + * @package App\Http\Controllers\Api
  15 + */
  16 +class BaseController extends Controller
  17 +{
  18 + /**
  19 + * @param array $data
  20 + * @param string $message
  21 + * @param int $status
  22 + * @return false|string
  23 + */
  24 + protected function success($data = [], $message = 'success', $status = 200)
  25 + {
  26 + $array = compact('status', 'message', 'data');
  27 + return json_encode($array, JSON_UNESCAPED_UNICODE);
  28 + }
  29 +
  30 + /**
  31 + * @param string $message
  32 + * @param int $status
  33 + * @param array $data
  34 + * @return false|string
  35 + */
  36 + protected function error($message = 'error', $status = 400, $data = [])
  37 + {
  38 + $array = compact('status', 'message', 'data');
  39 + return json_encode($array, JSON_UNESCAPED_UNICODE);
  40 + }
  41 +}
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/01/04
  6 + * Time: 16:08
  7 + */
  8 +namespace App\Http\Controllers\Api;
  9 +
  10 +use App\Models\Visit\SyncSubmitTask;
  11 +use App\Models\Visit\Visit;
  12 +use Illuminate\Http\Request;
  13 +
  14 +/**
  15 + * Class NoticeController
  16 + * @package App\Http\Controllers\Api
  17 + */
  18 +class NoticeController extends BaseController
  19 +{
  20 + /**
  21 + * 网站引流
  22 + * FIXME 当前接口给内部引流用, 使用简易接口, 后期需要添加完整校验机制以及多数据接口
  23 + * @param Request $request
  24 + * @return false|string
  25 + */
  26 + public function trafficVisit(Request $request)
  27 + {
  28 + $ip = $request->input('ip');
  29 + $url = $request->input('url');
  30 + $device_port = intval($request->input('device_port'));
  31 + $referrer_url = $request->input('referrer_url');
  32 + $user_agent = $request->input('user_agent');
  33 +
  34 + // 数据占时不入库, 些日志分析数据
  35 + file_put_contents(storage_path('logs/trafficVisit.log'), var_export($request->all(), true) . PHP_EOL, FILE_APPEND);
  36 +// return $this->success([]);
  37 +
  38 + if (empty($ip))
  39 + return $this->error('IP不能为空');
  40 + if (empty($url))
  41 + return $this->error('访问链接不能为空');
  42 + if (empty($user_agent))
  43 + return $this->error('请求头信息user_agent不能为空');
  44 +
  45 + $url_array = parse_url($url);
  46 + $array = [
  47 + 'ip' => $ip,
  48 + 'domain' => $url_array['host'] ?? '',
  49 + 'referer' => $referrer_url,
  50 + 'user_agent' => $user_agent,
  51 + 'data' => [
  52 + 'url' => $url,
  53 + 'domain' => empty($url_array['host']) ? '' : $url_array['scheme'] . '://' . $url_array['host'],
  54 + 'device_port' => in_array($device_port, array_keys(Visit::deviceMap())) ? $device_port : Visit::DEVICE_PC,
  55 + 'referrer_url' => $referrer_url
  56 + ]
  57 + ];
  58 + SyncSubmitTask::createTask($array, SyncSubmitTask::TYPE_VISIT);
  59 + return $this->success([]);
  60 + }
  61 +}
@@ -12,6 +12,8 @@ namespace App\Http\Controllers\Aside\Com; @@ -12,6 +12,8 @@ namespace App\Http\Controllers\Aside\Com;
12 use App\Helper\Common; 12 use App\Helper\Common;
13 use App\Http\Controllers\Bside\BaseController; 13 use App\Http\Controllers\Bside\BaseController;
14 use App\Models\Com\UpdateLog; 14 use App\Models\Com\UpdateLog;
  15 +use App\Models\Com\UpdateOldInfo;
  16 +use App\Models\Domain\DomainInfo;
15 use App\Models\Project\ProjectUpdateTdk; 17 use App\Models\Project\ProjectUpdateTdk;
16 use App\Services\ProjectServer; 18 use App\Services\ProjectServer;
17 use Illuminate\Support\Facades\DB; 19 use Illuminate\Support\Facades\DB;
@@ -66,7 +68,7 @@ class UpdateController extends BaseController @@ -66,7 +68,7 @@ class UpdateController extends BaseController
66 68
67 $project = ProjectServer::useProject($this->param['project_id']); 69 $project = ProjectServer::useProject($this->param['project_id']);
68 70
69 - if(!$project){ 71 + if (!$project) {
70 $this->fail('项目不存在'); 72 $this->fail('项目不存在');
71 } 73 }
72 74
@@ -74,9 +76,26 @@ class UpdateController extends BaseController @@ -74,9 +76,26 @@ class UpdateController extends BaseController
74 $this->fail('非升级无法进行采集操作'); 76 $this->fail('非升级无法进行采集操作');
75 } 77 }
76 78
  79 + $test_domain = $this->param['test_domain'] ?? '';
  80 + if ($test_domain) {
  81 + $test_domain_arr = parse_url($test_domain);
  82 + $test_domain = $test_domain_arr['host'] ?? '';
  83 + }
  84 +
  85 + //查看项目是否已上线
  86 + $domain_info = DomainInfo::where('project_id', $this->param['project_id'])->first();
  87 +
  88 + if ($domain_info && !$test_domain) {
  89 + $this->fail('已上线项目需填写采集的测试站域名');
  90 + }
  91 +
77 try { 92 try {
78 DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'"); 93 DB::connection('custom_mysql')->statement("DELETE FROM `gl_collect_source` WHERE `origin` LIKE '%.css%' OR `origin` LIKE '%.js%'");
  94 + if ($domain_info) {
  95 + DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0,`domain` = '" . $test_domain . "' WHERE `language` = ''");
  96 + } else {
79 DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''"); 97 DB::connection('custom_mysql')->statement("UPDATE `gl_collect_task` SET `status` = 0 WHERE `language` = ''");
  98 + }
80 } catch (\Exception $e) { 99 } catch (\Exception $e) {
81 errorLog('重新采集升级项目数据', $this->param, $e); 100 errorLog('重新采集升级项目数据', $this->param, $e);
82 101
@@ -87,9 +106,9 @@ class UpdateController extends BaseController @@ -87,9 +106,9 @@ class UpdateController extends BaseController
87 DB::disconnect('custom_mysql'); 106 DB::disconnect('custom_mysql');
88 107
89 $update = ['collect_status' => 0]; 108 $update = ['collect_status' => 0];
90 -// if ($this->param['type'] == 2) {  
91 -// $update['status'] = 0;  
92 -// } 109 + if ($this->param['type'] == 2 && !$domain_info) {
  110 + $update['status'] = 0;
  111 + }
93 112
94 UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update); 113 UpdateLog::where('project_id', $this->param['project_id'])->whereIn('api_type', ['post', 'page', 'news', 'blog'])->update($update);
95 114
@@ -3,6 +3,7 @@ @@ -3,6 +3,7 @@
3 namespace App\Http\Controllers\Aside\Optimize; 3 namespace App\Http\Controllers\Aside\Optimize;
4 4
5 use App\Enums\Common\Code; 5 use App\Enums\Common\Code;
  6 +use App\Helper\Arr;
6 use App\Http\Controllers\Aside\BaseController; 7 use App\Http\Controllers\Aside\BaseController;
7 use App\Http\Logic\Aside\Optimize\OptimizeLogic; 8 use App\Http\Logic\Aside\Optimize\OptimizeLogic;
8 use App\Http\Logic\Aside\Project\ProjectLogic; 9 use App\Http\Logic\Aside\Project\ProjectLogic;
@@ -47,6 +48,7 @@ class OptimizeController extends BaseController @@ -47,6 +48,7 @@ class OptimizeController extends BaseController
47 $data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']); 48 $data = $rankDataModel->read(['project_id'=>$v['id'],'lang'=>''],['first_page_num','indexed_pages_num']);
48 $v['first_page_num'] = $data['first_page_num'] ?? 0; 49 $v['first_page_num'] = $data['first_page_num'] ?? 0;
49 $v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0; 50 $v['indexed_pages_num'] = $data['indexed_pages_num'] ?? 0;
  51 + $v['g'] = $this->getGNum($v['id']);
50 $v = $this->handleParam($v); 52 $v = $this->handleParam($v);
51 $lists['list'][$k] = $v; 53 $lists['list'][$k] = $v;
52 } 54 }
@@ -55,6 +57,27 @@ class OptimizeController extends BaseController @@ -55,6 +57,27 @@ class OptimizeController extends BaseController
55 } 57 }
56 58
57 /** 59 /**
  60 + * @remark :统计数量
  61 + * @name :getGNum
  62 + * @author :lyh
  63 + * @method :post
  64 + * @time :2024/1/6 11:12
  65 + */
  66 + public function getGNum($project_id){
  67 + $num = 0;
  68 + $list = RankData::where('project_id', $project_id)->where('lang', '')->value('data') ?: [];
  69 + if(!empty($list)){
  70 + foreach ($list as $v) {
  71 + $last = Arr::last($v);
  72 + if(isset($last['g']) && ($last['g'] == 1)){
  73 + $num = $num+1;
  74 + }
  75 + }
  76 + }
  77 + return $num;
  78 + }
  79 +
  80 + /**
58 * @remark :参数处理 81 * @remark :参数处理
59 * @name :handleParam 82 * @name :handleParam
60 * @author :lyh 83 * @author :lyh
@@ -212,8 +212,8 @@ class ProofreadingController extends BaseController @@ -212,8 +212,8 @@ class ProofreadingController extends BaseController
212 $data[] = $trimmedString; 212 $data[] = $trimmedString;
213 } 213 }
214 $data = array_values($data); 214 $data = array_values($data);
215 - $uniqueArray = array_unique($data);  
216 - $data = array_values($uniqueArray); 215 +// $uniqueArray = array_unique($data);
  216 +// $data = array_values($uniqueArray);
217 return $data; 217 return $data;
218 } 218 }
219 219
@@ -85,7 +85,6 @@ class FileController @@ -85,7 +85,6 @@ class FileController
85 'file.required'=>'必须填写', 85 'file.required'=>'必须填写',
86 ]); 86 ]);
87 $files = $this->request->file('file'); 87 $files = $this->request->file('file');
88 -  
89 if (empty($files)) { 88 if (empty($files)) {
90 $this->response('没有上传的文件!'); 89 $this->response('没有上传的文件!');
91 } 90 }
@@ -306,6 +305,7 @@ class FileController @@ -306,6 +305,7 @@ class FileController
306 public function setUrl(){ 305 public function setUrl(){
307 //A端上传 306 //A端上传
308 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){ 307 if(isset($this->param['refer_type']) && $this->param['refer_type'] == 1){
  308 + @file_put_contents(storage_path('logs/lyh_error.log'), var_export('进入222', true) . PHP_EOL, FILE_APPEND);
309 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m'); 309 $this->path = $this->uploads['path_a'].'/'.$this->file_type[$this->param['refer']].'/'.date('Y-m');
310 }else{ 310 }else{
311 //B端上传,upload_method 为 1时 强制上传到本地 311 //B端上传,upload_method 为 1时 强制上传到本地
@@ -264,12 +264,36 @@ class InitHtmlLogic extends BaseLogic @@ -264,12 +264,36 @@ class InitHtmlLogic extends BaseLogic
264 if($info === false){ 264 if($info === false){
265 $html = ''; 265 $html = '';
266 }else{ 266 }else{
  267 + $type = $this->getCustomizedType($this->param['type'],$is_list);
  268 + $commonTemplateModel = new BTemplateCommon();
  269 + $commonInfo = $commonTemplateModel->read(['template_id' => 0,'type'=>$type]);
  270 + if($commonInfo !== false){
  271 + $info['main_html'] = $this->handleAllHtml($commonInfo,$info['main_html']);
  272 + }
267 $html = $info['main_html']; 273 $html = $info['main_html'];
268 } 274 }
  275 + //更新头部底部
269 return $this->success(['html'=>$html]); 276 return $this->success(['html'=>$html]);
270 } 277 }
271 278
272 /** 279 /**
  280 + * @remark :返回整个html截取代码
  281 + * @name :handleAllHtml
  282 + * @author :lyh
  283 + * @method :post
  284 + * @time :2023/12/13 15:39
  285 + */
  286 + public function handleAllHtml($commonInfo,$html){
  287 + if(!empty($commonInfo)){
  288 + $html = preg_replace('/<header\b[^>]*>(.*?)<\/header>/s', $commonInfo['head_html'], $html);
  289 + $html = preg_replace('/<footer\b[^>]*>(.*?)<\/footer>/s', $commonInfo['footer_html'], $html);
  290 + $html = preg_replace('/<style id="globalsojs-header">(.*?)<\/style>/s', $commonInfo['head_css'], $html);
  291 + $html = preg_replace('/<style id="globalsojs-footer">(.*?)<\/style>/s', $commonInfo['footer_css'], $html);
  292 + }
  293 + return $html;
  294 + }
  295 +
  296 + /**
273 * @remark :保存定制html 297 * @remark :保存定制html
274 * @name :saveHtml 298 * @name :saveHtml
275 * @author :lyh 299 * @author :lyh
@@ -292,6 +316,8 @@ class InitHtmlLogic extends BaseLogic @@ -292,6 +316,8 @@ class InitHtmlLogic extends BaseLogic
292 }else{ 316 }else{
293 $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]); 317 $bTemplateMainModel->edit(['main_html'=>$this->param['html']],['id'=>$mainInfo['id']]);
294 } 318 }
  319 + //更新头部底部
  320 + $this->saveCustomizeCommon($this->param['html'],$this->param['type'],$is_list);
295 }catch (\Exception $exception){ 321 }catch (\Exception $exception){
296 $this->fail('保存失败,请联系开发人员'); 322 $this->fail('保存失败,请联系开发人员');
297 } 323 }
@@ -299,6 +325,68 @@ class InitHtmlLogic extends BaseLogic @@ -299,6 +325,68 @@ class InitHtmlLogic extends BaseLogic
299 } 325 }
300 326
301 /** 327 /**
  328 + * @remark :定制代码更新头部信息
  329 + * @name :saveCustomizeCommon
  330 + * @author :lyh
  331 + * @method :post
  332 + * @time :2024/1/6 10:29
  333 + */
  334 + public function saveCustomizeCommon($html,$source,$is_list){
  335 + $type = $this->getCustomizedType($source,$is_list);
  336 + $templateCommonModel = new BTemplateCommon();
  337 + $commonInfo = $templateCommonModel->read(['template_id'=>0,'type'=>$type]);//查看当前头部是否存在
  338 + $handleInfo = $this->handleCommonParam($html);
  339 + if($commonInfo === false){
  340 + $data = [
  341 + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
  342 + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
  343 + 'type'=>$type,'template_id'=>0, 'project_id'=>$this->user['project_id'],
  344 + ];
  345 + $templateCommonModel->add($data);
  346 + }else{
  347 + $data = [
  348 + 'head_html'=>$handleInfo['head_html'], 'head_css'=>$handleInfo['head_css'],
  349 + 'footer_html'=>$handleInfo['footer_html'], 'footer_css'=>$handleInfo['footer_css'],
  350 + ];
  351 + $templateCommonModel->edit($data,['id'=>$commonInfo['id']]);
  352 + }
  353 + return $this->success();
  354 + }
  355 +
  356 + /**
  357 + * @remark :定制页面头部类型---根据source获取type类型
  358 + * @name :getType
  359 + * @author :lyh
  360 + * @method :post
  361 + * @time :2023/11/16 11:20
  362 + */
  363 + public function getCustomizedType($source,$is_list){
  364 + $type = BTemplate::TYPE_HOME;
  365 + if($source == BTemplate::SOURCE_PRODUCT){
  366 + if($is_list == BTemplate::IS_LIST){
  367 + $type = BTemplate::TYPE_PRODUCT_LIST;
  368 + }else{
  369 + $type = BTemplate::TYPE_PRODUCT_DETAIL;
  370 + }
  371 + }
  372 + if($source == BTemplate::SOURCE_BLOG){
  373 + if($is_list == BTemplate::IS_LIST){
  374 + $type = BTemplate::TYPE_BLOG_LIST;
  375 + }else{
  376 + $type = BTemplate::TYPE_BLOG_DETAIL;
  377 + }
  378 + }
  379 + if($source == BTemplate::SOURCE_NEWS){
  380 + if($is_list == BTemplate::IS_LIST){
  381 + $type = BTemplate::TYPE_NEWS_LIST;
  382 + }else{
  383 + $type = BTemplate::TYPE_NEWS_DETAIL;
  384 + }
  385 + }
  386 + return $type;
  387 + }
  388 +
  389 + /**
302 * @remark :前端获取设置模块(侧边栏) 390 * @remark :前端获取设置模块(侧边栏)
303 * @name :getInitModuleMain 391 * @name :getInitModuleMain
304 * @author :lyh 392 * @author :lyh
@@ -371,7 +371,7 @@ class RankDataLogic extends BaseLogic @@ -371,7 +371,7 @@ class RankDataLogic extends BaseLogic
371 if (!$model || $model->updated_date != date('Y-m-d') || $force) { 371 if (!$model || $model->updated_date != date('Y-m-d') || $force) {
372 $res = $api->getGoogleRank($api_no, 0, 7, $force); 372 $res = $api->getGoogleRank($api_no, 0, 7, $force);
373 if (!$res) { 373 if (!$res) {
374 - throw new \Exception('接口数据获取失败'); 374 + throw new \Exception("接口数据获取失败,api_no:{$api_no}");
375 } 375 }
376 //收录数 376 //收录数
377 $indexed_pages_num = $site_res[$api_no] ?? 0; 377 $indexed_pages_num = $site_res[$api_no] ?? 0;
@@ -384,7 +384,7 @@ class RankDataLogic extends BaseLogic @@ -384,7 +384,7 @@ class RankDataLogic extends BaseLogic
384 if (!$model || $model->updated_date != date('Y-m-d') || $force) { 384 if (!$model || $model->updated_date != date('Y-m-d') || $force) {
385 $res = $api->getGoogleRank($api_no, 1, 7, $force); 385 $res = $api->getGoogleRank($api_no, 1, 7, $force);
386 if (!$res) { 386 if (!$res) {
387 - throw new \Exception('接口数据获取失败'); 387 + throw new \Exception("接口数据获取失败,api_no:{$api_no},lang");
388 } 388 }
389 $data = []; 389 $data = [];
390 //不同的小语种取出来 390 //不同的小语种取出来
@@ -17,7 +17,7 @@ class CollectTask extends Base @@ -17,7 +17,7 @@ class CollectTask extends Base
17 const STATUS_COM = 2; 17 const STATUS_COM = 2;
18 const STATUS_FAIL = 3; 18 const STATUS_FAIL = 3;
19 19
20 - public static function _insert($url, $project_id, $source, $source_id, $link_type = 0, $language_list = [], $page_list = []) 20 + public static function _insert($url, $project_id, $source, $source_id, $domain, $link_type = 0, $language_list = [], $page_list = [])
21 { 21 {
22 if (!$url) { 22 if (!$url) {
23 return; 23 return;
@@ -40,15 +40,15 @@ class CollectTask extends Base @@ -40,15 +40,15 @@ class CollectTask extends Base
40 'project_id' => $project_id, 40 'project_id' => $project_id,
41 'source' => $source, 41 'source' => $source,
42 'source_id' => $source_id, 42 'source_id' => $source_id,
43 - 'domain' => $url_arr['host'],  
44 - 'route' => $url_arr['path'], 43 + 'domain' => $url_arr['host'] ?? $domain,
  44 + 'route' => substr($url_arr['path'], 0, 1) == '/' ? $url_arr['path'] : '/' . $url_arr['path'],
45 'language' => '', 45 'language' => '',
46 'created_at' => $now, 46 'created_at' => $now,
47 'updated_at' => $now, 47 'updated_at' => $now,
48 ]; 48 ];
49 49
50 if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) { 50 if ($link_type > 0 && $language_list && in_array($url_arr['path'], $page_list)) {
51 - $domain_arr = explode('.', $url_arr['host']); 51 + $domain_arr = explode('.', $url_arr['host'] ?? $domain);
52 foreach ($language_list as $v_lan) { 52 foreach ($language_list as $v_lan) {
53 if ($link_type == 1) { 53 if ($link_type == 1) {
54 //二级域名 54 //二级域名
@@ -56,7 +56,7 @@ class CollectTask extends Base @@ -56,7 +56,7 @@ class CollectTask extends Base
56 $new_domain = implode('.', $domain_arr); 56 $new_domain = implode('.', $domain_arr);
57 } else { 57 } else {
58 //二级目录 58 //二级目录
59 - $new_domain = $url_arr['host'] . '/' . $v_lan; 59 + $new_domain = $url_arr['host'] ?? $domain . '/' . $v_lan;
60 } 60 }
61 61
62 $data[] = [ 62 $data[] = [
@@ -7,7 +7,70 @@ use App\Models\Base; @@ -7,7 +7,70 @@ use App\Models\Base;
7 use Illuminate\Database\Eloquent\SoftDeletes; 7 use Illuminate\Database\Eloquent\SoftDeletes;
8 8
9 /** 9 /**
  10 + * App\Models\Product\Product
  11 + *
10 * @method static get() 12 * @method static get()
  13 + * @property int $id
  14 + * @property int $project_id
  15 + * @property string $title
  16 + * @property string $thumb 封面
  17 + * @property mixed|null $gallery 图集
  18 + * @property mixed|null $attrs 属性参数
  19 + * @property string|null $attr_id 通用参数
  20 + * @property string|null $category_id 分类 多个,号隔开
  21 + * @property string|null $keyword_id 关键词标签 多个,号隔开
  22 + * @property string|null $intro 简介
  23 + * @property string|null $content 详情
  24 + * @property mixed|null $describe 描述
  25 + * @property string $describe_id 通用描述
  26 + * @property mixed|null $seo_mate seo tdk
  27 + * @property string $related_product_id 相关产品 多个,号隔开
  28 + * @property int $sort 排序
  29 + * @property int $status 状态 0草稿 1已上架 2已下架
  30 + * @property int $created_uid 创建者
  31 + * @property \Illuminate\Support\Carbon|null $created_at
  32 + * @property \Illuminate\Support\Carbon|null $updated_at
  33 + * @property \Illuminate\Support\Carbon|null $deleted_at
  34 + * @property string|null $route 路由
  35 + * @property mixed|null $icon 图标
  36 + * @property string|null $product_type 产品类型:1,一般产品;2:推荐产品(recommend);3:热销产品(hot)
  37 + * @property int $is_upgrade 0:6.0 1:4.0,5.0升级
  38 + * @property string|null $send_time 发布时间
  39 + * @property int|null $six_read 1:导入数据可按6.0显示
  40 + * @method \Illuminate\Database\Eloquent\Builder|Product newModelQuery()
  41 + * @method \Illuminate\Database\Eloquent\Builder|Product newQuery()
  42 + * @method \Illuminate\Database\Eloquent\Builder|Product onlyTrashed()
  43 + * @method static \Illuminate\Database\Eloquent\Builder|Product query()
  44 + * @method \Illuminate\Database\Eloquent\Builder|Product whereAttrId($value)
  45 + * @method \Illuminate\Database\Eloquent\Builder|Product whereAttrs($value)
  46 + * @method \Illuminate\Database\Eloquent\Builder|Product whereCategoryId($value)
  47 + * @method \Illuminate\Database\Eloquent\Builder|Product whereContent($value)
  48 + * @method \Illuminate\Database\Eloquent\Builder|Product whereCreatedAt($value)
  49 + * @method \Illuminate\Database\Eloquent\Builder|Product whereCreatedUid($value)
  50 + * @method \Illuminate\Database\Eloquent\Builder|Product whereDeletedAt($value)
  51 + * @method \Illuminate\Database\Eloquent\Builder|Product whereDescribe($value)
  52 + * @method \Illuminate\Database\Eloquent\Builder|Product whereDescribeId($value)
  53 + * @method \Illuminate\Database\Eloquent\Builder|Product whereGallery($value)
  54 + * @method \Illuminate\Database\Eloquent\Builder|Product whereIcon($value)
  55 + * @method \Illuminate\Database\Eloquent\Builder|Product whereId($value)
  56 + * @method \Illuminate\Database\Eloquent\Builder|Product whereIntro($value)
  57 + * @method \Illuminate\Database\Eloquent\Builder|Product whereIsUpgrade($value)
  58 + * @method \Illuminate\Database\Eloquent\Builder|Product whereKeywordId($value)
  59 + * @method \Illuminate\Database\Eloquent\Builder|Product whereProductType($value)
  60 + * @method \Illuminate\Database\Eloquent\Builder|Product whereProjectId($value)
  61 + * @method \Illuminate\Database\Eloquent\Builder|Product whereRelatedProductId($value)
  62 + * @method \Illuminate\Database\Eloquent\Builder|Product whereRoute($value)
  63 + * @method \Illuminate\Database\Eloquent\Builder|Product whereSendTime($value)
  64 + * @method \Illuminate\Database\Eloquent\Builder|Product whereSeoMate($value)
  65 + * @method \Illuminate\Database\Eloquent\Builder|Product whereSixRead($value)
  66 + * @method \Illuminate\Database\Eloquent\Builder|Product whereSort($value)
  67 + * @method \Illuminate\Database\Eloquent\Builder|Product whereStatus($value)
  68 + * @method \Illuminate\Database\Eloquent\Builder|Product whereThumb($value)
  69 + * @method \Illuminate\Database\Eloquent\Builder|Product whereTitle($value)
  70 + * @method \Illuminate\Database\Eloquent\Builder|Product whereUpdatedAt($value)
  71 + * @method \Illuminate\Database\Eloquent\Builder|Product withTrashed()
  72 + * @method \Illuminate\Database\Eloquent\Builder|Product withoutTrashed()
  73 + * @mixin \Eloquent
11 */ 74 */
12 class Product extends Base 75 class Product extends Base
13 { 76 {
  1 +<?php
  2 +/**
  3 + * Created by PhpStorm.
  4 + * User: zhl
  5 + * Date: 2024/1/5
  6 + * Time: 14:16
  7 + */
  8 +namespace App\Models\Visit;
  9 +
  10 +use App\Models\Base;
  11 +
  12 +/**
  13 + * Class SyncSubmitTask
  14 + * @package App\Models\Visit
  15 + */
  16 +class SyncSubmitTask extends Base
  17 +{
  18 + /**
  19 + * 表名
  20 + * @var string
  21 + */
  22 + protected $table = 'gl_sync_submit_task';
  23 +
  24 + const TYPE_INQUIRY = 'inquiry';
  25 + const TYPE_VISIT = 'visit';
  26 +
  27 + /**
  28 + * @param $data
  29 + * @param string $type
  30 + * @return mixed
  31 + */
  32 + public static function createTask($data, $type = self::TYPE_VISIT)
  33 + {
  34 + $task = new self();
  35 + $task->data = json_encode($data);
  36 + $task->type = $type;
  37 + $task->save();
  38 + return $task->id;
  39 + }
  40 +}
@@ -20,10 +20,13 @@ class Visit extends Base @@ -20,10 +20,13 @@ class Visit extends Base
20 protected $connection = 'custom_mysql'; 20 protected $connection = 'custom_mysql';
21 protected $appends = ['device_text']; 21 protected $appends = ['device_text'];
22 22
  23 + const DEVICE_PC = 1;
  24 + const DEVICE_MOBILE = 2;
  25 +
23 public static function deviceMap(){ 26 public static function deviceMap(){
24 return [ 27 return [
25 - 1 => 'PC',  
26 - 2 => '移动端' 28 + self::DEVICE_PC => 'PC',
  29 + self::DEVICE_MOBILE => '移动端'
27 ]; 30 ];
28 } 31 }
29 32
@@ -105,7 +105,7 @@ class ProjectServer @@ -105,7 +105,7 @@ class ProjectServer
105 $created_at = date('Y-m-d H:i:s'); 105 $created_at = date('Y-m-d H:i:s');
106 self::initGroup($project_id,$created_at); 106 self::initGroup($project_id,$created_at);
107 //初始化单页 107 //初始化单页
108 - self::init404Page($project_id); 108 + self::init404Page($project_id,$created_at);
109 //初始化模块数据 109 //初始化模块数据
110 self::initModule($project_id); 110 self::initModule($project_id);
111 DB::disconnect('custom_mysql'); 111 DB::disconnect('custom_mysql');
@@ -172,7 +172,7 @@ class ProjectServer @@ -172,7 +172,7 @@ class ProjectServer
172 * @method :post 172 * @method :post
173 * @time :2023/12/29 9:32 173 * @time :2023/12/29 9:32
174 */ 174 */
175 - public function init404Page($project_id){ 175 + public function init404Page($project_id,$created_at){
176 $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first(); 176 $info = DB::connection('custom_mysql')->table('gl_web_custom_template')->first();
177 if(empty($info)) { 177 if(empty($info)) {
178 $main_404_html = '<main> 178 $main_404_html = '<main>
@@ -208,7 +208,10 @@ class ProjectServer @@ -208,7 +208,10 @@ class ProjectServer
208 'status' => 1, 208 'status' => 1,
209 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL, 209 'url' => BCustomTemplate::NOT_FOUND_PAGE_URL,
210 'html' => $main_404_html, 210 'html' => $main_404_html,
211 - 'html_style' => '<style id="globalsojs-styles"></style>','title' => '404-Page not found', 'description' => 'Sorry. The page has either moved or cannot be found.', 'created_at' => $created_at, 'updated_at' => $created_at]; 211 + 'html_style' => '<style id="globalsojs-styles"></style>',
  212 + 'title' => '404-Page not found',
  213 + 'description' => 'Sorry. The page has either moved or cannot be found.',
  214 + 'created_at' => $created_at, 'updated_at' => $created_at];
212 $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data); 215 $id = DB::connection('custom_mysql')->table('gl_web_custom_template')->insertGetId($data);
213 //路由 216 //路由
214 $info = DB::connection('custom_mysql')->table('gl_route_map')->first(); 217 $info = DB::connection('custom_mysql')->table('gl_route_map')->first();
@@ -17,3 +17,5 @@ use Illuminate\Support\Facades\Route; @@ -17,3 +17,5 @@ use Illuminate\Support\Facades\Route;
17 Route::middleware('auth:sanctum')->get('/user', function (Request $request) { 17 Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
18 return $request->user(); 18 return $request->user();
19 }); 19 });
  20 +
  21 +Route::any('traffic_visit', [\App\Http\Controllers\Api\NoticeController::class, 'trafficVisit'])->name('api.traffic_visit');
@@ -357,7 +357,7 @@ Route::middleware(['aloginauth'])->group(function () { @@ -357,7 +357,7 @@ Route::middleware(['aloginauth'])->group(function () {
357 //无需登录验证的路由组 357 //无需登录验证的路由组
358 Route::group([], function () { 358 Route::group([], function () {
359 Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white'); 359 Route::any('/login', [Aside\LoginController::class, 'login'])->name('admin.login.white');
360 - Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show'); 360 +// Route::any('/image/{hash}/{w?}/{h?}', [\App\Http\Controllers\File\ImageController::class, 'index'])->name('admin.image_show');
361 Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show'); 361 Route::any('/file/{hash}', [\App\Http\Controllers\File\FileController::class, 'index'])->name('admin.file_show');
362 Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件 362 Route::any('/download_files', [\App\Http\Controllers\File\FileController::class, 'downLoad'])->name('admin.files_downLoad');//导出文件
363 Route::any('/download_images', [\App\Http\Controllers\File\ImageController::class, 'downLoad'])->name('admin.images_downLoad');//导出图片 363 Route::any('/download_images', [\App\Http\Controllers\File\ImageController::class, 'downLoad'])->name('admin.images_downLoad');//导出图片