作者 李宇航

合并分支 'lyh-server' 到 'master'

gx数据



查看合并请求 !1933
@@ -9,10 +9,16 @@ @@ -9,10 +9,16 @@
9 9
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
  12 +use App\Helper\Arr;
12 use App\Models\Ai\AiBlogAuthor; 13 use App\Models\Ai\AiBlogAuthor;
13 use App\Models\Ai\AiVideo; 14 use App\Models\Ai\AiVideo;
14 use App\Models\Ai\AiVideoList; 15 use App\Models\Ai\AiVideoList;
  16 +use App\Models\Com\Notify;
  17 +use App\Models\Devops\ServerConfig;
  18 +use App\Models\Devops\ServersIp;
  19 +use App\Models\Domain\DomainInfo;
15 use App\Models\Project\AiVideoTask as AiVideoTaskModel; 20 use App\Models\Project\AiVideoTask as AiVideoTaskModel;
  21 +use App\Models\Project\Project;
16 use App\Models\RouteMap\RouteMap; 22 use App\Models\RouteMap\RouteMap;
17 use App\Services\AiBlogService; 23 use App\Services\AiBlogService;
18 use App\Services\AiVideoService; 24 use App\Services\AiVideoService;
@@ -72,7 +78,7 @@ class AiVideoTask extends Command @@ -72,7 +78,7 @@ class AiVideoTask extends Command
72 $this->updateProject = []; 78 $this->updateProject = [];
73 } 79 }
74 if(!empty($this->routes)){ 80 if(!empty($this->routes)){
75 - $this->updateRoutes($this->routes); 81 +// $this->updateRoutes($this->routes);
76 $this->routes = []; 82 $this->routes = [];
77 } 83 }
78 $aiVideoTaskModel = new AiVideoTaskModel(); 84 $aiVideoTaskModel = new AiVideoTaskModel();
@@ -276,4 +282,64 @@ class AiVideoTask extends Command @@ -276,4 +282,64 @@ class AiVideoTask extends Command
276 echo $message; 282 echo $message;
277 return true; 283 return true;
278 } 284 }
  285 +
  286 + /**
  287 + * 通知C端生成界面
  288 + * @param $project_id
  289 + * @return bool
  290 + */
  291 + public function updateRoutes($routes){
  292 + $domainModel = new DomainInfo();
  293 + $project_model = new Project();
  294 + foreach ($routes as $project_id => $route){
  295 + $route[] = 'top-video';
  296 + $domain = $domainModel->getProjectIdDomain($project_id);
  297 + if (empty($domain)) {
  298 + $this->output('send: 域名不存在, project id: ' . $project_id);
  299 + continue;
  300 + }
  301 + //判断是否是自建站服务器,如果是,不请求C端接口,数据直接入库
  302 + $project_info = $project_model->read(['id'=>$project_id],['serve_id']);
  303 + if(!$project_info){
  304 + $this->output('send: 项目不存在, project id: ' . $project_id);
  305 + continue;
  306 + }
  307 + $serve_ip_model = new ServersIp();
  308 + $serve_ip_info = $serve_ip_model->read(['id'=>$project_info['serve_id']],['servers_id']);
  309 + $servers_id = $serve_ip_info ? $serve_ip_info['servers_id'] : 0;
  310 + if($servers_id == ServerConfig::SELF_SITE_ID){
  311 + //判断是否已有更新进行中
  312 + $notify_model = new Notify();
  313 + $data = [
  314 + 'project_id' => $project_id,
  315 + 'type' => Notify::TYPE_MASTER,
  316 + 'route' => Notify::ROUTE_AI_BLOG,
  317 + 'server_id' => ServerConfig::SELF_SITE_ID,
  318 + 'status' => ['!=',Notify::STATUS_FINISH_SITEMAP]
  319 + ];
  320 + $notify = $notify_model->read($data,['id']);
  321 + if(!$notify){
  322 + $domain_array = parse_url($domain);
  323 + $data['data'] = Arr::a2s(['domain'=>$domain_array['host'],'url'=>$route,'language'=>[]]);
  324 + $data['status'] = Notify::STATUS_INIT;
  325 + $data['sort'] = 2;
  326 + $notify_model->add($data);
  327 + }
  328 + $this->output('send: 自建站项目, project id: ' . $project_id);
  329 + }else{
  330 + $c_url = $domain.'api/update_page/';
  331 + $param = [
  332 + 'project_id' => $project_id,
  333 + 'type' => 1,
  334 + 'route' => 3,
  335 + 'url' => $route,
  336 + 'language'=> [],
  337 + 'is_sitemap' => 0
  338 + ];
  339 + $res = http_post($c_url, json_encode($param,true));
  340 + $this->output('notify: project id: ' . $project_id . ', result: ' . json_encode($res,JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
  341 + }
  342 + }
  343 + return true;
  344 + }
279 } 345 }