作者 刘锟

update

... ... @@ -10,6 +10,7 @@ use App\Models\Domain\DomainInfo;
use App\Models\Product\KeywordRelated;
use App\Models\Product\Product;
use App\Models\Project\Project;
use App\Models\WebSetting\WebLanguage;
use App\Services\BatchExportService;
use App\Services\ProjectServer;
use Illuminate\Console\Command;
... ... @@ -32,9 +33,81 @@ class Temp extends Command
public function handle()
{
$this->check_zb_complete_project_site();
$this->check_server_minor_site();
}
/**
* 判断指定服务器项目小语种是否正常访问
* @author Akun
* @date 2024/12/11 10:15
*/
public function check_server_minor_site()
{
$server_id = 15;
$server_name = '美服1';
$server_ip_model = new ServersIp();
$server_ip_ids = $server_ip_model->where('servers_id', $server_id)->get()->pluck('id')->toArray();
$project_list = Project::select(['id', 'serve_id', 'title'])->whereIn('serve_id', $server_ip_ids)->get();
$domain_model = new DomainInfo();
$notify_model = new Notify();
$data = [];
foreach ($project_list as $value) {
$domain_info = $domain_model->read(['project_id' => $value->id, 'status' => 1], ['id', 'domain']);
if (!$domain_info) {
//过滤未绑定正式域名的项目
continue;
}
$domain = $domain_info['domain'];
//获取最新一条小语种生成任务
$notify = $notify_model->read(['project_id' => $value->id, 'type' => 2, 'status' => 3, 'route' => 1], ['data']);
if (!$notify) {
//过滤未生成过小语种的项目
continue;
}
$notify_data = json_decode($notify['data'], true);
$language_id = 0;
foreach ($notify_data['language'] as $vl) {
if ($vl > 1) {
$language_id = $vl;
}
}
if (!$language_id) {
continue;
}
$language_info = WebLanguage::getLangById($language_id);
$lan = $language_info->short;
$code = check_curl_status('https://' . $domain . '/' . $lan);
$html = curl_c('https://' . $domain . '/' . $lan, false);
$is_404 = false;
if (strpos($html, 'Sorry. The page has either moved or cannot be found.') !== false) {
$is_404 = true;
}
$data[] = [
$value->id,
$value->title,
'https://' . $domain . '/' . $lan,
$code,
$is_404
];
}
$map = ['项目id', '名称', '访问地址', '访问状态', '是否404'];
if ($data) {
$table = new BatchExportService($server_name . '站点小语种页面访问状态');
$file = $table->head($map)->data($data)->save();
if (!$file) {
$this->output('文件生成失败,请重试');
} else {
$this->output('export success');
}
} else {
$this->output('no data');
}
}
/**
* 创建指定服务器所有项目主站生成任务
... ... @@ -100,7 +173,7 @@ class Temp extends Command
* @author Akun
* @date 2024/12/11 10:15
*/
public function check_zb_complete_project_site()
public function check_server_project_site()
{
$server_id = 15;
$server_name = '美服1';
... ...