作者 lyh

列表页聚合页模式

@@ -9,6 +9,7 @@ @@ -9,6 +9,7 @@
9 9
10 namespace App\Console\Commands\Ai; 10 namespace App\Console\Commands\Ai;
11 11
  12 +use App\Models\Product\Keyword;
12 use App\Models\Product\Product; 13 use App\Models\Product\Product;
13 use App\Models\Project\DeployOptimize; 14 use App\Models\Project\DeployOptimize;
14 use App\Models\Project\Project; 15 use App\Models\Project\Project;
@@ -77,7 +78,11 @@ class AiVideoAutoPublish extends Command @@ -77,7 +78,11 @@ class AiVideoAutoPublish extends Command
77 } 78 }
78 //获取当前网站的标题 79 //获取当前网站的标题
79 ProjectServer::useProject($item['id']); 80 ProjectServer::useProject($item['id']);
80 - $data = $this->getProduct(); 81 + $data = $this->getVideoInfo();
  82 + if(!empty($data)){
  83 + //写入一条零时生成视频记录
  84 +
  85 + }
81 DB::disconnect('custom_mysql'); 86 DB::disconnect('custom_mysql');
82 } 87 }
83 } 88 }
@@ -89,20 +94,36 @@ class AiVideoAutoPublish extends Command @@ -89,20 +94,36 @@ class AiVideoAutoPublish extends Command
89 * @method :post 94 * @method :post
90 * @time :2025/8/1 16:09 95 * @time :2025/8/1 16:09
91 */ 96 */
92 - public function getProduct(){ 97 + public function getVideoInfo(){
93 $data = []; 98 $data = [];
94 - $productModel = new Product();  
95 - $info = $productModel->formatQuery(['gallery'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();  
96 - if(empty($info)){ 99 + $random = rand(1, 2);
  100 + if($random == 1){//取产品
  101 + $productModel = new Product();
  102 + $info = $productModel->formatQuery(['title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
  103 + if(empty($info)){
  104 + return $data;
  105 + }
  106 + $data['title'] = $info['title'];
  107 + $data['remark'] = $info['intro'];
  108 + $data['images'] = array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);});
  109 + return $data;
  110 + }else{
  111 + //聚合页获取当前关联产品的图片
  112 + $keywordModel = new Keyword();
  113 + $keywordInfo = $keywordModel->formatQuery(['keyword_title'=>['!=',null],'keyword_content'=>['!=',null]])->select(['keyword_title','keyword_content'])->inRandomOrder()->first();
  114 + if(empty($keywordInfo)){
  115 + return $data;
  116 + }
  117 + $data['title'] = $keywordInfo['title'];
  118 + $data['remark'] = $keywordInfo['intro'];
  119 + $data['images'] = [];
  120 + $productModel = new Product();
  121 + $productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],'id',['gallery'],'desc',10);
  122 + foreach ($productList as $info){
  123 + $data['images'] = array_merge($data['images'],array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);}));
  124 + }
97 return $data; 125 return $data;
98 } 126 }
99 - $data['title'] = $info['title'];  
100 - $data['remark'] = $info['intro'];  
101 - $data['images'] = array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);});  
102 - if(count($data['images']) < 6){  
103 - //todo::需要生成图片  
104 - }  
105 - return $data;  
106 } 127 }
107 128
108 /** 129 /**
@@ -53,16 +53,16 @@ class lyhDemo extends Command @@ -53,16 +53,16 @@ class lyhDemo extends Command
53 echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['id'] . PHP_EOL; 53 echo date('Y-m-d H:i:s') . '开始--项目的id:'. $item['id'] . PHP_EOL;
54 $buildInfo = $buildModel->read(['project_id'=>$item['id']],['plan','seo_plan']); 54 $buildInfo = $buildModel->read(['project_id'=>$item['id']],['plan','seo_plan']);
55 if($buildInfo['seo_plan'] != 0){ 55 if($buildInfo['seo_plan'] != 0){
56 - $projectModel->edit(['version_id'=>7],['id'=>$item['id']]); 56 + $projectModel->edit(['version'=>7],['id'=>$item['id']]);
57 continue; 57 continue;
58 } 58 }
59 if(in_array($buildInfo['plan'],[4,5,15,16,17])){ 59 if(in_array($buildInfo['plan'],[4,5,15,16,17])){
60 - $projectModel->edit(['version_id'=>0],['id'=>$item['id']]); 60 + $projectModel->edit(['version'=>0],['id'=>$item['id']]);
61 }else{ 61 }else{
62 if($item['created_at'] > '2025-04-12 00:00:00'){ 62 if($item['created_at'] > '2025-04-12 00:00:00'){
63 - $projectModel->edit(['version_id'=>7],['id'=>$item['id']]); 63 + $projectModel->edit(['version'=>7],['id'=>$item['id']]);
64 }else{ 64 }else{
65 - $projectModel->edit(['version_id'=>6],['id'=>$item['id']]); 65 + $projectModel->edit(['version'=>6],['id'=>$item['id']]);
66 } 66 }
67 } 67 }
68 } 68 }
  1 +<?php
  2 +/**
  3 + * @remark :
  4 + * @name :AiVideoAutoLog.php
  5 + * @author :lyh
  6 + * @method :post
  7 + * @time :2025/8/2 9:59
  8 + */
  9 +
  10 +namespace App\Models\Project;
  11 +
  12 +use App\Models\Base;
  13 +
  14 +class AiVideoAutoLog extends Base
  15 +{
  16 + protected $table = 'gl_ai_video_auto_log';
  17 +}