作者 刘锟

update

@@ -10,6 +10,8 @@ use App\Models\Domain\DomainInfo; @@ -10,6 +10,8 @@ use App\Models\Domain\DomainInfo;
10 use App\Models\Product\KeywordRelated; 10 use App\Models\Product\KeywordRelated;
11 use App\Models\Product\Product; 11 use App\Models\Product\Product;
12 use App\Models\Project\Project; 12 use App\Models\Project\Project;
  13 +use App\Models\RouteMap\RouteMap;
  14 +use App\Models\WebSetting\WebLanguage;
13 use App\Services\BatchExportService; 15 use App\Services\BatchExportService;
14 use App\Services\ProjectServer; 16 use App\Services\ProjectServer;
15 use Illuminate\Console\Command; 17 use Illuminate\Console\Command;
@@ -52,7 +54,6 @@ class Temp extends Command @@ -52,7 +54,6 @@ class Temp extends Command
52 $project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get(); 54 $project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get();
53 55
54 $domain_model = new DomainInfo(); 56 $domain_model = new DomainInfo();
55 - $notify_model = new Notify();  
56 $data = []; 57 $data = [];
57 foreach ($project_list as $value) { 58 foreach ($project_list as $value) {
58 $domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']); 59 $domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']);
@@ -72,13 +73,31 @@ class Temp extends Command @@ -72,13 +73,31 @@ class Temp extends Command
72 } 73 }
73 74
74 //获取最新一条小语种生成任务 75 //获取最新一条小语种生成任务
75 - $notify = $notify_model->read(['project_id' => $value->id, 'type' => 2, 'status' => 3, 'route' => 1], ['id']); 76 + $notify = Notify::where(['server_id' => $server_id, 'project_id' => $value->id, 'type' => 2, 'status' => 3, 'route' => 4])->orderBy('id', 'desc')->first();
76 if (!$notify) { 77 if (!$notify) {
77 //过滤未生成过小语种的项目 78 //过滤未生成过小语种的项目
78 continue; 79 continue;
79 } 80 }
  81 + $notify_data = json_decode($notify->data, true);
  82 + $language = array_diff($notify_data['language'], ['1']);
  83 + $language_id = current($language);
  84 + if (!$language_id) {
  85 + continue;
  86 + }
  87 +
  88 + $lan_info = WebLanguage::getLangById($language_id);
  89 + $short = $lan_info->short;
  90 +
  91 +
  92 + ProjectServer::useProject($value->id);
  93 +
  94 + $route = RouteMap::where('source', 'product_keyword')->value('route');
  95 + if (!$route) {
  96 + //过滤没有关键词的项目
  97 + continue;
  98 + }
80 99
81 - $url = 'https://' . $domain . '/fr'; 100 + $url = 'https://' . $domain . '/' . $short . '/' . $route . '/';
82 $code = check_curl_status($url); 101 $code = check_curl_status($url);
83 $html = curl_c($url, false); 102 $html = curl_c($url, false);
84 $is_404 = false; 103 $is_404 = false;
@@ -95,7 +114,7 @@ class Temp extends Command @@ -95,7 +114,7 @@ class Temp extends Command
95 } 114 }
96 $map = ['项目id', '名称', '访问地址', '访问状态', '是否404']; 115 $map = ['项目id', '名称', '访问地址', '访问状态', '是否404'];
97 if ($data) { 116 if ($data) {
98 - $table = new BatchExportService($server_name . '站点小语种页面访问状态'); 117 + $table = new BatchExportService($server_name . '站点小语种聚合页面访问状态');
99 $file = $table->head($map)->data($data)->save(); 118 $file = $table->head($map)->data($data)->save();
100 if (!$file) { 119 if (!$file) {
101 $this->output('文件生成失败,请重试'); 120 $this->output('文件生成失败,请重试');