wupengfei 2 anni fa
parent
commit
ff6eb7273c

+ 3 - 1
.idea/workspace.xml

@@ -4,6 +4,8 @@
     <list default="true" id="1a36929e-c054-4875-a943-593a74e55fa4" name="Default Changelist" comment="">
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/application/api/controller/Video.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/api/controller/Video.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/model/UserMessage.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/UserMessage.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/application/common/model/VideoComment.php" beforeDir="false" afterPath="$PROJECT_DIR$/application/common/model/VideoComment.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -230,7 +232,7 @@
       <workItem from="1675904734949" duration="20832000" />
       <workItem from="1675990026788" duration="13260000" />
       <workItem from="1676077132290" duration="20234000" />
-      <workItem from="1676250114476" duration="16390000" />
+      <workItem from="1676250114476" duration="21739000" />
     </task>
     <servers />
   </component>

+ 68 - 34
application/api/controller/Video.php

@@ -788,46 +788,35 @@ class Video extends Base
         $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num)]);
     }
 
-    /**
-     * @title 删除评论&&批量删除
-     * @desc 删除评论
-     * @author qc
-     * @method POST
-     * @url /api/Video/delComment
-     * @header name:Authorization require:1 desc:Token
-     * @param name:id type:int default:1 desc:评论id【多个用逗号隔开=>'1,2'】
-     */
-    public function delComment(){
-        VideoComment::where(['user_id'=>$this->user_id])->where('id','in',input('post.id'))->update(['is_deleted'=>2]);
-        $this->success('删除成功');
-    }
 
     /**
-     * @title 点赞||取消点赞
+     * @title 点赞||取消点赞--可以批量
      * @desc 点赞||取消点赞
      * @author qc
      * @method POST
      * @url /api/Video/videoTags
      * @header name:Authorization require:1 desc:Token
-     * @param name:type type:int default:1 desc:1评论点赞,评论记录id,2平台视频点赞
-     * @param name:like_id type:int default:1 desc:点赞id【二级评论不要这个功能】(平台视频点赞用video_arr的iD
+     * @param name:type type:int default:1 desc:1评论点赞,2平台视频点赞
+     * @param name:like_id type:int default:1 desc:点赞id【多个逗号隔开】(平台视频点赞用video_arr的id或评论记录id或点赞记录的like_id)
      * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
      */
     public function videoTags()
     {
         $type = input('post.type',1);
-        $like_id = input('post.like_id');
+        $id  =  input('post.like_id');
         $ret_val = 0;
-        $check_tags =  VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->value('id');
-        if($check_tags) {
-            VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->delete();
-            if($type == 1) VideoComment::where('id',$like_id)->setDec('like_times');
-        }else{
-            Data::save('VideoCommentLike',
-                ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type],'user_id',
-                ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type]);
-            $ret_val = 1;
-            if($type == 1) VideoComment::where('id',$like_id)->setInc('like_times');
+        foreach ($id as $like_id) {
+            $check_tags =  VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->value('id');
+            if($check_tags) {
+                VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->delete();
+                if($type == 1) VideoComment::where('id',$like_id)->setDec('like_times');
+            }else{
+                Data::save('VideoCommentLike',
+                    ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type],'user_id',
+                    ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type]);
+                $ret_val = 1;
+                if($type == 1) VideoComment::where('id',$like_id)->setInc('like_times');
+            }
         }
         $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
     }
@@ -958,18 +947,16 @@ class Video extends Base
 
         // 点赞我的
         $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
-        $video_praise_num = VideoCommentLike::where([['type','=',2],['is_read','=',0],['url_id','in',$all_video]])->count();
-        $comment_praise_num = VideoCommentLike::where([['type','=',1],['is_read','=',0],['url_id','in',$all_comment]])->count();
+        $video_praise_num = VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video]])->count();
+        $comment_praise_num = VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$all_comment]])->count();
         $praise_num =  $video_praise_num + $comment_praise_num;
-
         // 追播未读量
-        $follow_num = 0;
-
+        $follow_num = UserMessage::getUnreadNum($this->user_id,'video',5);
         $this->success('ok',compact(['reply_num','comment_num','praise_num','comment_praise_num','video_praise_num','follow_num']));
     }
 
     /**
-     * @title 消息已读未读变更
+     * @title 消息已读&&未读变更
      * @desc 支持批量选择
      * @author qc
      * @method POST
@@ -991,6 +978,32 @@ class Video extends Base
         $this->success('消息变更成功');
     }
 
+    /**
+     * @title 删除评论&&批量删除
+     * @desc 删除评论
+     * @author qc
+     * @method POST
+     * @url /api/Video/delComment
+     * @header name:Authorization require:1 desc:Token
+     * @param name:id type:int default:1 desc:评论记录id【多个用逗号隔开=>'1,2'】
+     * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,2】
+     */
+    public function delComment(){
+        $type = input('post.type',1);
+        switch ($type)
+        {
+            case 1:
+                VideoComment::where(['user_id'=>$this->user_id])->where('id','in',input('post.id'))->update(['is_deleted'=>1]);
+                break;
+            default :
+                VideoComment::where('id','in',input('post.id'))->update(['is_read'=>input('post.is_read')]);
+                break;
+        }
+
+        $this->success('删除成功');
+    }
+
+
 
 
 
@@ -1314,6 +1327,13 @@ class Video extends Base
      * @return name:ali_vid type:string default:-- desc:云点播id
      * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
      * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
+     * @return name:transmit_num type:int default:-- desc:转发量
+     * @return name:comment_num type:int default:-- desc:评论量
+     * @return name:is_praise type:int default:-- desc:是否点赞
+     * @return name:praise_num type:int default:-- desc:点赞量
+     * @return name:praise_num type:int default:-- desc:点赞量
+     * @return name:is_collect type:int default:-- desc:是否收藏
+     * @return name:collect_num type:int default:-- desc:收藏量
      */
     public function getTagsVideo()
     {
@@ -1324,13 +1344,27 @@ class Video extends Base
         $sel_where[]  = ['t.type','=',2];
         $list = VideoCommentLike::where($sel_where)
             ->alias('t')
-            ->field('t.id,t.create_at,t.like_id url_id,i.title,i.cover,i.is_vip,i.cover,i.ali_vid,i.video_id,i.duration')
+            ->field('t.id,t.create_at,t.like_id url_id,v.user_id buid,i.title,i.cover,i.is_vip,i.cover,i.ali_vid,i.video_id,i.duration,i.transmit_num')
             ->leftJoin('VideoUrl i','t.like_id = i.id')
             ->order('id desc')
             ->limit($this->off_set,$this->page_num)
             ->select()->toArray();
         array_walk($list,function (&$v){
             $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
+            $v['transmit_num'] = numTransform($v['transmit_num']);
+            $v['comment_num'] = VideoComment::getVideoCommentNum($v['url_id']);
+            $v['is_praise']  = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$v['url_id']])->count();
+            $v['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$v['url_id']])->count();
+            $v['is_collect'] =  UserCollect::checkCollectByType($this->user_id,1,$v['video_id'],$v['url_id']);
+            $v['collect_num'] =  UserCollect::getCollectNum(1,$v['video_id'],$v['url_id']);
+            if(!$v['buid']){
+                $v['app_name']  = APPNAME;
+                $v['app_logo']  = APPLOGO;
+            }else{
+                $user_info = User::where('id',$v['buid'])->field('name,headimg')->find();
+                $v['app_name']  = $user_info ? $user_info->name : '';
+                $v['app_logo']  = $user_info ? $user_info->headimg : '';
+            }
         });
         $this->success('ok',['list'=>$list]);
     }

+ 15 - 0
application/common/model/UserMessage.php

@@ -13,6 +13,7 @@ class UserMessage extends Model
             2=>['title'=>'视频审核','msg'=>['恭喜您视频审核成功','抱歉啦视频审核失败~~']],
             3=>['title'=>'视频评论回复','msg'=>['有会员评论了您的回复']],
             4=>['title'=>'视频评论','msg'=>['有会员评论了您的视频']],
+            5=>['title'=>'追更','msg'=>['您追更的视频有更新']],
             ],// 视频
         'article'=>[
             1=>['title'=>'图文投稿','msg'=>['图文投稿成功请等待审核']],
@@ -100,4 +101,18 @@ class UserMessage extends Model
     }
 
 
+    /**
+     * 获取消息未读数量
+     * @param $user_id  发送给谁
+     * @param $module  模块
+     * @param $type   模块类型
+     * @param $msg_key 内容key[msg的key]
+     */
+    public static function getUnreadNum($user_id,$module,$type)
+    {
+        return static::where(['user_id'=>$user_id,'module'=>$module,'type'=>$type,'is_read'=>0])->count();
+    }
+
+
+
 }

+ 5 - 1
application/common/model/VideoComment.php

@@ -4,5 +4,9 @@ use think\Model;
 // 视频评论
 class VideoComment extends Model
 {
-
+    // 获取视频评论量
+    public static function getVideoCommentNum($url_id){
+        $num =   static::where([['is_deleted','=',0],['url_id','=',$url_id]])->count();
+        return numTransform($num);
+    }
 }