|
@@ -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视频自动发布
|
|
@@ -45,7 +46,10 @@ class AiVideoAutoPublish extends Command |
|
@@ -45,7 +46,10 @@ class AiVideoAutoPublish extends Command |
|
45
|
protected $description = '自动发布AI Video';
|
46
|
protected $description = '自动发布AI Video';
|
|
46
|
|
47
|
|
|
47
|
public function handle(){
|
48
|
public function handle(){
|
|
48
|
-
|
49
|
+ $action = $this->argument('action');
|
|
|
|
50
|
+ if($action == 'auto_publish'){
|
|
|
|
51
|
+ $this->auto_publish();
|
|
|
|
52
|
+ }
|
|
49
|
}
|
53
|
}
|
|
50
|
|
54
|
|
|
51
|
/**
|
55
|
/**
|
|
@@ -104,7 +108,7 @@ class AiVideoAutoPublish extends Command |
|
@@ -104,7 +108,7 @@ class AiVideoAutoPublish extends Command |
|
104
|
$random = rand(1, 2);
|
108
|
$random = rand(1, 2);
|
|
105
|
if($random == 1){//取产品
|
109
|
if($random == 1){//取产品
|
|
106
|
$productModel = new Product();
|
110
|
$productModel = new Product();
|
|
107
|
- $info = $productModel->formatQuery(['title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
111
|
+ $info = $productModel->formatQuery(['status'=>1,'title'=>['!=',null],'intro'=>['!=',null]])->select(['title','gallery','intro'])->inRandomOrder()->first();
|
|
108
|
if(empty($info)){
|
112
|
if(empty($info)){
|
|
109
|
return $data;
|
113
|
return $data;
|
|
110
|
}
|
114
|
}
|
|
@@ -139,26 +143,33 @@ class AiVideoAutoPublish extends Command |
|
@@ -139,26 +143,33 @@ class AiVideoAutoPublish extends Command |
|
139
|
* @time :2025/8/2 10:37
|
143
|
* @time :2025/8/2 10:37
|
|
140
|
*/
|
144
|
*/
|
|
141
|
public function auto_send_video(){
|
145
|
public function auto_send_video(){
|
|
142
|
- while (true){
|
146
|
+ $number = Redis::get('ai_video_image') ?? 0;
|
|
143
|
$aiVideoAutoLogModel = new AiVideoAutoLog();
|
147
|
$aiVideoAutoLogModel = new AiVideoAutoLog();
|
|
144
|
- $lists = $aiVideoAutoLogModel->list(['status'=>0]);
|
|
|
|
145
|
- if(empty($lists)){
|
148
|
+ while (true){
|
|
|
|
149
|
+ if($number > 5){
|
|
|
|
150
|
+ sleep(300);
|
|
|
|
151
|
+ continue;
|
|
|
|
152
|
+ }
|
|
|
|
153
|
+ $item = $aiVideoAutoLogModel->read(['status'=>0]);
|
|
|
|
154
|
+ if(empty($info)){
|
|
146
|
sleep(60);
|
155
|
sleep(60);
|
|
|
|
156
|
+ continue;
|
|
147
|
}
|
157
|
}
|
|
148
|
- foreach ($lists as $item){
|
|
|
|
149
|
if(count($item['images']) < 6){
|
158
|
if(count($item['images']) < 6){
|
|
150
|
//需要生成图片
|
159
|
//需要生成图片
|
|
151
|
$content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
160
|
$content = "{$item['remark']},{$item['title']},4K,高清 --no logo --ar 16:9";
|
|
152
|
$midJourneyService = new MidJourneyService();
|
161
|
$midJourneyService = new MidJourneyService();
|
|
153
|
$result = $midJourneyService->imagine($content);
|
162
|
$result = $midJourneyService->imagine($content);
|
|
154
|
- dd($result);
|
163
|
+ if($result && !empty($result['trigger_id'])){
|
|
|
|
164
|
+ Redis::incr('ai_video_image');
|
|
|
|
165
|
+ $aiVideoAutoLogModel->edit(['trigger_id'=>$result['trigger_id']],['id'=>$item['id']]);
|
|
|
|
166
|
+ }
|
|
155
|
}else{
|
167
|
}else{
|
|
156
|
//提交到待执行
|
168
|
//提交到待执行
|
|
157
|
$aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
169
|
$aiVideoAutoLogModel->edit(['status'=>1],['id'=>$item['id']]);
|
|
158
|
}
|
170
|
}
|
|
159
|
}
|
171
|
}
|
|
160
|
}
|
172
|
}
|
|
161
|
- }
|
|
|
|
162
|
|
173
|
|
|
163
|
/**
|
174
|
/**
|
|
164
|
* @remark :
|
175
|
* @remark :
|