作者 刘锟

合并分支 'akun' 到 'master'

Akun



查看合并请求 !947
@@ -6,15 +6,16 @@ use App\Helper\Arr; @@ -6,15 +6,16 @@ use App\Helper\Arr;
6 use App\Models\Com\Notify; 6 use App\Models\Com\Notify;
7 use App\Models\Devops\ServerConfig; 7 use App\Models\Devops\ServerConfig;
8 use App\Models\Devops\ServersIp; 8 use App\Models\Devops\ServersIp;
  9 +use App\Models\Domain\DomainCreateTask;
9 use App\Models\Domain\DomainInfo; 10 use App\Models\Domain\DomainInfo;
10 use App\Models\Product\Keyword; 11 use App\Models\Product\Keyword;
11 use App\Models\Product\KeywordRelated; 12 use App\Models\Product\KeywordRelated;
12 use App\Models\Product\Product; 13 use App\Models\Product\Product;
  14 +use App\Models\Project\DeployBuild;
13 use App\Models\Project\Project; 15 use App\Models\Project\Project;
14 use App\Services\BatchExportService; 16 use App\Services\BatchExportService;
15 use App\Services\ProjectServer; 17 use App\Services\ProjectServer;
16 use Illuminate\Console\Command; 18 use Illuminate\Console\Command;
17 -use Symfony\Component\Process\Process;  
18 19
19 class Temp extends Command 20 class Temp extends Command
20 { 21 {
@@ -33,6 +34,88 @@ class Temp extends Command @@ -33,6 +34,88 @@ class Temp extends Command
33 protected $description = '临时脚本'; 34 protected $description = '临时脚本';
34 35
35 /** 36 /**
  37 + * 伍欣组推广项目:开启AMP站点,首页不强制跳转,批量生成AMP站点页面
  38 + * @author Akun
  39 + * @date 2024/12/10 10:43
  40 + */
  41 + public function handle()
  42 + {
  43 + //获取所有组内推广项目
  44 + $leader_mid = 16;
  45 + $project_ids = DeployBuild::where('leader_mid', $leader_mid)->pluck('project_id')->toArray();
  46 + $project_list = Project::where('type', 2)->whereIn('id', $project_ids)->get();
  47 +
  48 + $task_model = new DomainCreateTask();
  49 + foreach ($project_list as $project) {
  50 + $project_id = $project->id;
  51 +
  52 + $this->output('项目id:' . $project_id . ',start');
  53 +
  54 + //获取项目域名情况
  55 + $domain_info = DomainInfo::where('project_id', $project_id)->where('status', 1)->first();
  56 + if (!$domain_info) {
  57 + $this->output('未绑定正式域名');
  58 + continue;
  59 + }
  60 + $domain_id = $domain_info->id;
  61 + $domain = $domain_info->domain;
  62 +
  63 + //获取项目所在服务器
  64 + $serve_ip_info = ServersIp::where('id', $project->serve_id)->first();
  65 + if (!$serve_ip_info) {
  66 + $this->output('未查询到服务器数据');
  67 + continue;
  68 + }
  69 + $servers_id = $serve_ip_info->servers_id;
  70 +
  71 + if ($servers_id == ServerConfig::SELF_SITE_ID) {
  72 + $this->output('自建站项目过滤');
  73 + continue;
  74 + }
  75 +
  76 + //开启AMP站点
  77 + if ($domain_info->amp_status == 0) {
  78 + $domain_info->amp_status = 1;
  79 + $domain_info->amp_type = 1;
  80 + }
  81 + //首页不强制跳转
  82 + $domain_info->is_redirect = 0;
  83 + $domain_info->save();
  84 +
  85 + //创建主站建站任务
  86 + $task_model->add([
  87 + 'server_id' => $servers_id,
  88 + 'project_id' => $project_id,
  89 + 'domain_id' => $domain_id,
  90 + 'type' => DomainCreateTask::TYPE_MAIN
  91 + ]);
  92 +
  93 + //创建AMP站建站任务
  94 + $task_model->add([
  95 + 'server_id' => $servers_id,
  96 + 'project_id' => $project_id,
  97 + 'domain_id' => $domain_id,
  98 + 'type' => DomainCreateTask::TYPE_AMP
  99 + ]);
  100 +
  101 + //请求对应C端页面更新接口
  102 + $c_url = $domain . '/api/update_page/';
  103 + $c_params = [
  104 + 'project_id' => $project_id,
  105 + 'type' => 3
  106 + ];
  107 + $re = http_post($c_url, json_encode($c_params), [], true);
  108 + if (isset($re['status']) && $re['status'] == 200) {
  109 + $this->output($c_url . ' | 请求成功');
  110 + } else {
  111 + $this->output($c_url . ' | ' . ($re['message'] ?? '未返回失败原因'));
  112 + }
  113 +
  114 + $this->output('项目id:' . $project_id . ',end');
  115 + }
  116 + }
  117 +
  118 + /**
36 * 关联所有项目关键词 119 * 关联所有项目关键词
37 * @author Akun 120 * @author Akun
38 * @date 2024/11/18 15:07 121 * @date 2024/11/18 15:07
@@ -236,7 +319,7 @@ class Temp extends Command @@ -236,7 +319,7 @@ class Temp extends Command
236 * @author Akun 319 * @author Akun
237 * @date 2024/09/26 10:48 320 * @date 2024/09/26 10:48
238 */ 321 */
239 - public function handle() 322 + public function handle1()
240 { 323 {
241 $notify_model = new Notify(); 324 $notify_model = new Notify();
242 $project_model = new Project(); 325 $project_model = new Project();