lh 4 일 전
부모
커밋
1be233c2ea
2개의 변경된 파일30개의 추가작업 그리고 5개의 파일을 삭제
  1. 21 0
      app/Console/Test/TestCommand.php
  2. 9 5
      app/Http/Controllers/DeepSeek/DeepSeekController.php

+ 21 - 0
app/Console/Test/TestCommand.php

@@ -48,6 +48,27 @@ class TestCommand extends Command
      */
     public function handle()
     {
+        $bid = 321;
+        $version_id = 1663;
+        $cid = 708197;
+        $redis_key = "select-{$bid}-{$version_id}-{$cid}";
+        // 查询更新后的信息
+        $paragraph_urls = DB::table('mp_chapter_paragraph_audios')->where('bid', $bid)->where('version_id', $version_id)
+        ->where('cid', $cid)->where(function($query) {
+            return $query->where('generate_status', '!=', '制作中')->orWhere('error_msg', '!=', '');
+        })->select('id', 'sequence', 'paragraph_audio_url', 'error_msg')
+        ->get()->map(function ($value) {
+            return (array)$value;
+        })->toArray();
+        $rem_ids = [];
+        foreach ($paragraph_urls as $item) {
+            $rem_ids[] = getProp($item, 'id');
+        }
+
+        // 删除已发送的id
+        Redis::srem($redis_key, $rem_ids);
+        dd(Redis::smembers($redis_key));
+        exit();
         // $all_timbre = DB::table('mp_timbres')->get();
         // foreach($all_timbre as $timbre) {
         //     $id = getProp($timbre, 'id');

+ 9 - 5
app/Http/Controllers/DeepSeek/DeepSeekController.php

@@ -143,20 +143,24 @@ class DeepSeekController extends BaseController
             // 判断是否有待更新数据,有则查询
             $ids = Redis::smembers($redis_key);
             if (count($ids) > 0) {
-                $update_ids = DB::table('mp_chapter_paragraph_audios')->whereIn('id', $ids)->where(function($query) {
+                $count = DB::table('mp_chapter_paragraph_audios')->whereIn('id', $ids)->where(function($query) {
                     return $query->where('generate_status', '!=', '制作中')->orWhere('error_msg', '!=', '');
-                })->pluck('id')->toArray();
+                })->count('id');
 
                 // 如果有更新数据,则发送消息
-                if (count($update_ids) > 0) {
+                if ($count > 0) {
                     // 查询更新后的信息
                     $paragraph_urls = DB::table('mp_chapter_paragraph_audios')->where('bid', $bid)->where('version_id', $version_id)
                     ->where('cid', $cid)->where(function($query) {
                         return $query->where('generate_status', '!=', '制作中')->orWhere('error_msg', '!=', '');
-                    })->select('sequence', 'paragraph_audio_url', 'error_msg')
+                    })->select('id', 'sequence', 'paragraph_audio_url', 'error_msg')
                     ->get()->map(function ($value) {
                         return (array)$value;
                     })->toArray();
+                    $rem_ids = [];
+                    foreach ($paragraph_urls as $item) {
+                        $rem_ids[] = getProp($item, 'id');
+                    }
                     
                     // 发送消息
                     $this->sendEvent([
@@ -169,7 +173,7 @@ class DeepSeekController extends BaseController
                     ]);
 
                     // 删除已发送的id
-                    Redis::srem($redis_key, $update_ids);
+                    Redis::srem($redis_key, $rem_ids);
                 }
             }