|
|
@@ -8,6 +8,7 @@ use GuzzleHttp\Client;
|
|
|
use GuzzleHttp\Exception\GuzzleException;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
+use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
class AIImageGenerationService
|
|
|
{
|
|
|
@@ -86,6 +87,7 @@ class AIImageGenerationService
|
|
|
// 创建排队状态的任务记录
|
|
|
return MpGeneratePicTask::create([
|
|
|
'task_id' => $taskId,
|
|
|
+ 'alias_segment_id' => $params['alias_segment_id'] ?? 0,
|
|
|
'prompt' => $params['prompt'] ?? '',
|
|
|
'width' => $params['width'] ?? 2048,
|
|
|
'height' => $params['height'] ?? 2048,
|
|
|
@@ -337,11 +339,19 @@ class AIImageGenerationService
|
|
|
]);
|
|
|
|
|
|
// 同步调整分镜图片状态和结果
|
|
|
- if (getProp($task, 'alias_segment_id')) {
|
|
|
+ $segment_id = getProp($task, 'alias_segment_id');
|
|
|
+ if ($segment_id) {
|
|
|
DB::table('mp_episode_segments')->where('segment_id', getProp($task, 'alias_segment_id'))->update([
|
|
|
'img_url' => $statusInfo['result_url'][0],
|
|
|
'pic_task_status' => '已完成',
|
|
|
]);
|
|
|
+
|
|
|
+ // 如果是首帧图ID则更新anime表
|
|
|
+ if (Redis::sismember('anime_first_frame_urls', $segment_id)) {
|
|
|
+ $anime_id = DB::table('mp_episode_segments')->where('segment_id', $segment_id)->value('anime_id');
|
|
|
+ DB::table('mp_animes')->where('id', $anime_id)->update(['first_frame_url'=>$statusInfo['result_url'][0], 'updated_at'=>date('Y-m-d H:i:s')]);
|
|
|
+ Redis::srem('anime_first_frame_urls', $segment_id);
|
|
|
+ }
|
|
|
}
|
|
|
} elseif ($statusInfo['status'] === 'failed') {
|
|
|
$task->updateStatus(MpGeneratePicTask::STATUS_FAILED, [
|