|
...
|
...
|
@@ -9,6 +9,7 @@ |
|
|
|
|
|
|
|
namespace App\Console\Commands\Ai;
|
|
|
|
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\DeployOptimize;
|
|
|
|
use App\Models\Project\Project;
|
|
...
|
...
|
@@ -77,7 +78,11 @@ class AiVideoAutoPublish extends Command |
|
|
|
}
|
|
|
|
//获取当前网站的标题
|
|
|
|
ProjectServer::useProject($item['id']);
|
|
|
|
$data = $this->getProduct();
|
|
|
|
$data = $this->getVideoInfo();
|
|
|
|
if(!empty($data)){
|
|
|
|
//写入一条零时生成视频记录
|
|
|
|
|
|
|
|
}
|
|
|
|
DB::disconnect('custom_mysql');
|
|
|
|
}
|
|
|
|
}
|
|
...
|
...
|
@@ -89,20 +94,36 @@ class AiVideoAutoPublish extends Command |
|
|
|
* @method :post
|
|
|
|
* @time :2025/8/1 16:09
|
|
|
|
*/
|
|
|
|
public function getProduct(){
|
|
|
|
public function getVideoInfo(){
|
|
|
|
$data = [];
|
|
|
|
$productModel = new Product();
|
|
|
|
$info = $productModel->formatQuery(['gallery'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
|
|
if(empty($info)){
|
|
|
|
$random = rand(1, 2);
|
|
|
|
if($random == 1){//取产品
|
|
|
|
$productModel = new Product();
|
|
|
|
$info = $productModel->formatQuery(['title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
|
|
if(empty($info)){
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
$data['title'] = $info['title'];
|
|
|
|
$data['remark'] = $info['intro'];
|
|
|
|
$data['images'] = array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);});
|
|
|
|
return $data;
|
|
|
|
}else{
|
|
|
|
//聚合页获取当前关联产品的图片
|
|
|
|
$keywordModel = new Keyword();
|
|
|
|
$keywordInfo = $keywordModel->formatQuery(['keyword_title'=>['!=',null],'keyword_content'=>['!=',null]])->select(['keyword_title','keyword_content'])->inRandomOrder()->first();
|
|
|
|
if(empty($keywordInfo)){
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
$data['title'] = $keywordInfo['title'];
|
|
|
|
$data['remark'] = $keywordInfo['intro'];
|
|
|
|
$data['images'] = [];
|
|
|
|
$productModel = new Product();
|
|
|
|
$productList = $productModel->list(['keyword_id'=>['like','%,'.$keywordInfo['id'].',%']],'id',['gallery'],'desc',10);
|
|
|
|
foreach ($productList as $info){
|
|
|
|
$data['images'] = array_merge($data['images'],array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);}));
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
$data['title'] = $info['title'];
|
|
|
|
$data['remark'] = $info['intro'];
|
|
|
|
$data['images'] = array_walk($info['gallery'], function (&$item) {$item['alt'] = $item['title'];unset($item['title']);});
|
|
|
|
if(count($data['images']) < 6){
|
|
|
|
//todo::需要生成图片
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
...
|
...
|
|