Explorar o código

处理大纲时维护剧本集数

lh hai 2 meses
pai
achega
1a791f3690
Modificáronse 1 ficheiros con 22 adicións e 7 borrados
  1. 22 7
      app/Services/DeepSeek/DeepSeekService.php

+ 22 - 7
app/Services/DeepSeek/DeepSeekService.php

@@ -3348,6 +3348,15 @@ Q版卡通风格,头大身小,造型圆润可爱,线条简单,色彩明
             'updated_at' => date('Y-m-d H:i:s')
         ];
 
+        if ($table_data['content']) {
+            $chapters = $this->splitContent($table_data['content']);
+            $chapter_count = count($chapters);
+            if ($chapter_count > 0) {
+                $table_data['start_episode_sequence'] = 1;
+                $table_data['end_episode_sequence'] = $table_data['episode_num'] = $chapter_count;
+            }
+        }
+
         $single_episode = [];
         try {
             DB::beginTransaction();
@@ -4108,13 +4117,14 @@ Q版卡通风格,头大身小,造型圆润可爱,线条简单,色彩明
         // 如果是修改集数,则将content内容更新(会改变原文)
         if (isset($episode_count) && $episode_count > 0) {
             if (isset($script_arr['content']) && $script_arr['content']) $table_data['content'] = $script_arr['content'];
+            $table_data['start_episode_sequence'] = 1;
             $table_data['end_episode_sequence'] = $table_data['episode_num'] = $episode_count;
         }else {
             // 如果需要生成原文内容,从script_arr中提取
             if ($need_generate_content && isset($script_arr['content']) && $script_arr['content']) {
                 $table_data['content'] = $script_arr['content'];
                 dLog('deepseek')->info('从AI生成结果中提取原文内容', ['content_length' => strlen($script_arr['content'])]);
-                if (!$content) {
+                if (!$table_data['content']) {
                     yield [
                         'type'  => 'done',
                         'script' => [],
@@ -4126,12 +4136,13 @@ Q版卡通风格,头大身小,造型圆润可爱,线条简单,色彩明
                     ];
                     return;
                 }
-            } else {
-                $chapters = $this->splitContent($content);
-                $chapter_count = count($chapters);
-                if ($chapter_count > 0) {
-                    $table_data['end_episode_sequence'] = $table_data['episode_num'] = $chapter_count;
-                }
+            } 
+
+            $chapters = $this->splitContent($table_data['content']);
+            $chapter_count = count($chapters);
+            if ($chapter_count > 0) {
+                $table_data['start_episode_sequence'] = 1;
+                $table_data['end_episode_sequence'] = $table_data['episode_num'] = $chapter_count;
             }
         }
 
@@ -4307,6 +4318,10 @@ Q版卡通风格,头大身小,造型圆润可爱,线条简单,色彩明
         $roles = is_array($roles) ? $roles : [];
         $scenes = is_array($scenes) ? $scenes : [];
 
+        // 获取最后一集序号
+        $end_episode_sequence = getProp($anime, 'end_episode_sequence');
+        if ($end_episode_sequence && $episode_number > $end_episode_sequence) Utils::throwError("20003:总集数只有{$end_episode_sequence}集,不允许继续策划下一集!");
+
         // 转换主体列表和场景列表的格式
         // 获取参考主体或场景
         if ((int)$episode_number === 1) {