|
@@ -20,6 +20,7 @@ use Illuminate\Console\Command; |
|
@@ -20,6 +20,7 @@ use Illuminate\Console\Command; |
|
20
|
use Illuminate\Support\Facades\DB;
|
20
|
use Illuminate\Support\Facades\DB;
|
|
21
|
use Illuminate\Support\Facades\Log;
|
21
|
use Illuminate\Support\Facades\Log;
|
|
22
|
use App\Models\Project\AiVideoTask;
|
22
|
use App\Models\Project\AiVideoTask;
|
|
|
|
23
|
+use Illuminate\Support\Facades\Redis;
|
|
23
|
|
24
|
|
|
24
|
/**
|
25
|
/**
|
|
25
|
* @remark :ai视频自动发布
|
26
|
* @remark :ai视频自动发布
|
|
@@ -104,7 +105,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -104,7 +105,7 @@ class AiVideoAutoPublish extends Command |
|
104
|
$random = rand(1, 2);
|
105
|
$random = rand(1, 2);
|
|
105
|
if($random == 1){//取产品
|
106
|
if($random == 1){//取产品
|
|
106
|
$productModel = new Product();
|
107
|
$productModel = new Product();
|
|
107
|
- $info = $productModel->formatQuery(['title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
108
|
+ $info = $productModel->formatQuery(['status'=>1,'title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
108
|
if(empty($info)){
|
109
|
if(empty($info)){
|
|
109
|
return $data;
|
110
|
return $data;
|
|
110
|
}
|
111
|
}
|
|
@@ -139,23 +140,30 @@ class AiVideoAutoPublish extends Command |
|
@@ -139,23 +140,30 @@ class AiVideoAutoPublish extends Command |
|
139
|
* @time :2025/8/2 10:37
|
140
|
* @time :2025/8/2 10:37
|
|
140
|
*/
|
141
|
*/
|
|
141
|
public function auto_send_video(){
|
142
|
public function auto_send_video(){
|
|
|
|
143
|
+ $number = Redis::get('ai_video_image') ?? 0;
|
|
|
|
144
|
+ $aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
142
|
while (true){
|
145
|
while (true){
|
|
143
|
- $aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
|
|
144
|
- $lists = $aiVideoAutoLogModel->list(['status'=>0]);
|
|
|
|
145
|
- if(empty($lists)){
|
146
|
+ if($number > 5){
|
|
|
|
147
|
+ sleep(300);
|
|
|
|
148
|
+ continue;
|
|
|
|
149
|
+ }
|
|
|
|
150
|
+ $item = $aiVideoAutoLogModel->read(['status'=>0]);
|
|
|
|
151
|
+ if(empty($info)){
|
|
146
|
sleep(60);
|
152
|
sleep(60);
|
|
|
|
153
|
+ continue;
|
|
147
|
}
|
154
|
}
|
|
148
|
- foreach ($lists as $item){
|
|
|
|
149
|
- if(count($item['images']) < 6){
|
|
|
|
150
|
- //需要生成图片
|
|
|
|
151
|
- $content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
|
|
|
152
|
- $midJourneyService = new MidJourneyService();
|
|
|
|
153
|
- $result = $midJourneyService->imagine($content);
|
|
|
|
154
|
- dd($result);
|
|
|
|
155
|
- }else{
|
|
|
|
156
|
- //提交到待执行
|
|
|
|
157
|
- $aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
155
|
+ if(count($item['images']) < 6){
|
|
|
|
156
|
+ //需要生成图片
|
|
|
|
157
|
+ $content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
|
|
|
158
|
+ $midJourneyService = new MidJourneyService();
|
|
|
|
159
|
+ $result = $midJourneyService->imagine($content);
|
|
|
|
160
|
+ if($result && !empty($result['trigger_id'])){
|
|
|
|
161
|
+ Redis::incr('ai_video_image');
|
|
|
|
162
|
+ $aiVideoAutoLogModel->edit(['trigger_id'=>$result['trigger_id']],['id'=>$item['id']]);
|
|
158
|
}
|
163
|
}
|
|
|
|
164
|
+ }else{
|
|
|
|
165
|
+ //提交到待执行
|
|
|
|
166
|
+ $aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
|
159
|
}
|
167
|
}
|
|
160
|
}
|
168
|
}
|
|
161
|
}
|
169
|
}
|