Prechádzať zdrojové kódy

短剧列表中增加微信审核状态

liuzejian 1 rok pred
rodič
commit
5d8b9a5721

+ 0 - 62
app/Console/Commands/Video/WechatCheckGetTask.php

@@ -1,62 +0,0 @@
-<?php
-
-namespace App\Console\Commands\Video;
-
-use Illuminate\Console\Command;
-use Illuminate\Support\Facades\DB;
-use Modules\Video\Services\WechatCheckSyncService;
-
-class WechatCheckGetTask extends Command
-{
-    /**
-     * The name and signature of the console command.
-     *
-     * @var string
-     */
-    protected $signature = 'Video:WechatCheckGetTask {--task_ids= : 英文逗号分割的任务id}';
-
-    /**
-     * The console command description.
-     *
-     * @var string
-     */
-    protected $description = '查询短剧同步到微信的任务状态';
-
-    /**
-     * Execute the console command.
-     */
-    public function handle(): void
-    {
-        $task_ids = $this->option('task_ids');
-        $taskIdArr = null;
-        if($task_ids) {
-            $taskIdArr = explode(',', trim($task_ids, ','));
-        }
-        DB::table('video_series_wechat_check')
-            ->whereIn('sync_status', [1,2])
-            ->where('sync_task_id', '<>', '')
-            ->where('is_enabled', 1)
-            ->when($taskIdArr, function ($query, $taskIdArr) {
-                return $query->whereIn('task_id', $taskIdArr);
-            })->orderBy('id', 'asc')
-            ->chunk(100, function ($items) {
-                $now = date('Y-m-d H:i:s');
-                foreach ($items as $item) {
-                    $taskInfo = WechatCheckSyncService::getTask($item);
-                    if($taskInfo && 1 == $taskInfo['task_type']) {
-                        if(in_array($taskInfo['status'], [3,4])) {
-                            DB::table('video_series_wechat_check')
-                                ->where(['id' => $item->id])
-                                ->update([
-                                    'status' => $taskInfo['status'],
-                                    'remark' => $taskInfo['errmsg'] ?? '',
-                                    'media_id' => $taskInfo['media_id'] ?? '',
-                                    'updated_at' => $now,
-                                    'sync_task_info' => \json_encode($taskInfo),
-                                ]);
-                        }
-                    }
-                }
-            });
-    }
-}

+ 18 - 1
modules/Video/Http/Controllers/EpisodeController.php

@@ -30,9 +30,22 @@ class EpisodeController extends CatchController
             ->where([
                 'video_id' => $request->integer('video_id'),
                 'is_enabled' => 1
-            ])->select('series_name', 'series_sequence', 'video_key', 'duration')
+            ])->select('series_name', 'series_sequence', 'video_key', 'duration', 'id', 'video_id')
             ->orderBy('series_sequence', 'asc')
             ->paginate($request->integer('limit', 15));
+        /**
+         * 增加微信审核状态
+         */
+        $wechatCheckStatus = null;
+        if($request->input('need_wechat_status', 0)) {
+            $serieIds = $videoSeries->pluck('id');
+            $wechatCheckStatus = DB::table('video_series_wechat_check')
+                ->whereIn('series_id', $serieIds)
+                ->where('is_enabled', 1)
+                ->select('series_id', 'check_status')
+                ->get()->keyBy('series_id');
+        }
+        $wechatCheckStatusMap = config('video.wechat.checkStatus');
         foreach ($videoSeries as $series) {
             $series->series_name = sprintf('第%s集', $series->series_sequence);
             $series->is_charge = $series->series_sequence >= $video->charge_sequence;
@@ -40,6 +53,10 @@ class EpisodeController extends CatchController
             $series->public_video_url = config('common.qiniu.publicVideoLinkDomain') . DIRECTORY_SEPARATOR . $series->video_key;
             $series->download_video_url = QiniuTokenService::getPrivateSourceDownloadUrl(config('common.qiniu.sourceVideoLinkDomain') . DIRECTORY_SEPARATOR .
                 $series->video_key.'?attname='.urlencode($series->series_name).'.mp4');
+            $wechat_check_status = $wechatCheckStatus[$series->id]->check_status ?? 0;
+            $series->wechat_check_status = $wechat_check_status;
+            $series->wechat_check_status_str = $wechatCheckStatusMap[$wechat_check_status] ?? '';
+
         }
 
         return $videoSeries;

+ 5 - 3
modules/Video/Http/Controllers/VideoSeriesWechatCheckController.php

@@ -28,7 +28,8 @@ class VideoSeriesWechatCheckController extends CatchController
             ->join('videos', 'video_series.video_id', 'videos.id')
             ->whereIn('video_series.id', $series_ids)
             ->where(['video_series.is_enabled' => 1])
-            ->select('videos.name', 'video_series.series_sequence','video_series.id', 'video_series.video_key')
+            ->select('video_series.video_id', 'videos.name', 'video_series.series_sequence',
+                'video_series.id', 'video_series.video_key')
             ->get();
         if(collect($series_ids)->count() != $series->count()) {
             CommonBusinessException::throwError(Errors::VIDEO_SERIES_NOT_EXISTS);
@@ -40,7 +41,7 @@ class VideoSeriesWechatCheckController extends CatchController
             $item->video_url = config('common.qiniu.publicVideoLinkDomain') . DIRECTORY_SEPARATOR . $item->video_key;
             $item->media_name = sprintf('%s - 第%s集', $item->name, $item->series_sequence);
             $parsedContent = WechatCheckSyncService::pullupload($item, $accessToken);
-            if(false === $parsedContent) {
+            if(false === $parsedContent || (0 != ($parsedContent['errcode'] ?? 0))) {
                 CommonBusinessException::throwError(Errors::SYNC_WECHAT_NOT_OK);
             }
             $taskId = $parsedContent['task_id'];
@@ -51,7 +52,8 @@ class VideoSeriesWechatCheckController extends CatchController
                 ->insert([
                     'series_id' => $item->id,
                     'sync_task_id' => $taskId, 'appid' => $appid,
-                    'created_at' => $now, 'updated_at' => $now
+                    'created_at' => $now, 'updated_at' => $now,
+                    'video_id' => $item->video_id,
                 ]);
         }
 

+ 6 - 2
modules/Video/Http/Controllers/WechatCheckController.php

@@ -7,6 +7,7 @@ use Catch\Base\CatchController;
 use Illuminate\Foundation\Validation\ValidatesRequests;
 use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
+use Modules\Manage\Services\WechatMiniprogramService;
 
 /**
  * 微信提审
@@ -24,11 +25,14 @@ class WechatCheckController extends CatchController
             'producer' => 'required|string|max:256',
             'playwright' => 'required|string|max:256',
             'production_license_img' => 'required|url',
-            'authorized_img' => 'required|url'
+            'authorized_img' => 'required|url',
+            'registration_number' => 'required'
         ]);
 
         $data = $request->all();
+        $appid = WechatMiniprogramService::getDuanjuCheckAppid();
         $data['created_at'] = $data['updated_at'] = date('Y-m-d H:i:s');
+        $data['appid'] = $appid;
         DB::table('video_wechat_check')
             ->insert($data);
 
@@ -82,7 +86,7 @@ class WechatCheckController extends CatchController
             })->select('check.id', 'videos.name', 'videos.note', 'videos.total_episode_num',
                 'videos.cover_image','check.status','check.producer',
             'check.playwright', 'check.production_license_img', 'check.authorized_img', 'check.apply_at',
-            'check.check_at', 'check.check_reason')
+            'check.check_at', 'check.check_reason', 'check.registration_number')
             ->orderBy('check.id','desc')
             ->paginate($request->input('limit', 10));
 

+ 5 - 12
modules/Video/Services/WechatCheckSyncService.php

@@ -53,20 +53,13 @@ class WechatCheckSyncService
         ]);
     }
 
+    /**
+     * 短剧播放链接保存的rediskey
+     * @param $seriesId
+     * @return string
+     */
     public static function getWechatMediaLinkRedisKey($seriesId) {
         return 'wechat.medialink.'.$seriesId;
     }
 
-    public static function getTask($syncInfo) {
-        $accessToken = WechatMiniprogramService::getDuanjuCheckAccessToken($syncInfo->appid);
-        $parsedContent = HttpRequest::simplePost(WechatURL::vod_gettask . $accessToken, [
-            'task_id' => $syncInfo->sync_task_id
-        ]);
-        if(false === $parsedContent || (0 != $parsedContent['errcode'] ?? 0)) {
-            return $parsedContent['task_info'];
-        } else {
-            return [];
-        }
-
-    }
 }

+ 10 - 0
modules/Video/config/wechat.php

@@ -0,0 +1,10 @@
+<?php
+
+return [
+    'checkStatus' => [
+        '0' =>  '',
+        '1' => '审核中',
+        '2' => '审核驳回',
+        '3' => '审核通过'
+    ],
+];

+ 1 - 1
tests/UsedTestCase.php

@@ -23,6 +23,6 @@ abstract class UsedTestCase extends BaseTestCase
     }
 
     public function dumpJson($res) {
-        dump(\json_encode($res->json()));
+        dump(\json_encode($res->json(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
     }
 }

+ 3 - 3
tests/Video/Http/Controllers/EpisodeControllerTest.php

@@ -14,10 +14,10 @@ class EpisodeControllerTest extends UsedTestCase
         $res = $this->withHeaders([
             'Authorization' => 'Bearer '. $this->token,
         ])->json('get','http://localhost/api/videoStock/episode/downloadList', [
-            'video_id' => 3
+            'video_id' => 3,
+            'need_wechat_status' => 1
         ]);
-//        $this->dumpJson($res);
-        $res->dump();
+        $this->dumpJson($res);
     }
 
     public function testAdd()