0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray(); }else{ $list = SeriesVideoCate::where(['is_deleted'=>0])->field('id,logo,title,pid')->order('sort desc')->select()->toArray(); } $list = make_tree($list); $this->success('ok',['list'=>$list]); } /** * @title 获取视频标签 * @desc 获取视频标签 * @author qc * @url /api/Video/getVideoLabel * @method GET * @header name:Authorization require:1 desc:Token * @return name:id type:int default:-- desc:id * @return name:title type:string default:0 desc:标题 */ public function getVideoLabel() { $list = VideoLabel::field('id,title')->where(['is_deleted'=>0,'status'=>1])->select()->toArray(); $this->success('',['list'=>$list]); } /** * @title 视频推荐 * @desc 视频推荐 * @author qc * @method GET * @url /api/Video/getRecommendList * @header name:Authorization require:1 desc:Token * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:id type:string default:-- desc:视频url_id * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:系列id * @return name:cover type:string default:-- desc:封面 * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是) * @return name:app_name type:string default:-- desc:平台名称 * @return name:app_logo type:string default:-- desc:平台头像 */ public function getRecommendList() { $app_name = sysconf('app_name'); $app_logo = sysconf('app_logo'); $search_log = UserSearch::getSearchTitle($this->user_id,1); $search_arr = []; $where_str = 'b.id > 0'; foreach ($search_log as $t){ $search_arr[] = " b.title like '".'%'.$t."%'" .' '; $search_arr[] = " b.label like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $field = ' a.id,a.title,a.cover,a.user_id,a.is_vip,a.ali_vid,a.video_id ,IFNULL(is_recommend,0) is_recommend '; $table = 'dd_video_url'; $order_by_two = 'id'; $sql = "SELECT $field FROM " .$table . " a LEFT JOIN ( SELECT id,IF(id,1,1) is_recommend FROM $table b WHERE ( $where_str )) AS c ON c.id = a.id Left JOIN dd_video_intro as k ON a.video_id = k.id WHERE a.is_deleted = 0 AND a.status =1 AND k.is_deleted = 0 AND k.status = 1 ORDER BY is_recommend DESC , $order_by_two desc LIMIT {$this->off_set},{$this->page_num}"; $list = Db::query($sql); array_walk($list,function (&$v,$k)use ($app_name,$app_logo){ if(!$v['user_id']){ $v['app_name'] = $app_name; $v['app_logo'] = $app_logo; }else{ $user_info = User::where('id',$v['user_id'])->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,'sql'=>$sql]); } /** * @title 获取视频列表(平台发布) * @desc 获取视频列表 * @author qc * @method GET * @url /api/Video/getVideoList * @header name:Authorization require:1 desc:Token * @param name:type type:int default:0 desc:类型0全部1单个2系列 * @param name:is_tj type:int default:0 desc:是否推荐0否1是 * @param name:is_hot type:int default:-1 desc:是否置顶0否1是(-1全部) * @param name:title type:string default:-- desc:标题 * @param name:first_classify type:int default:0 desc:视频一级分类 * @param name:second_classify type:int default:0 desc:视频二级分类 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序 * @return name:id type:string default:-- desc:ID[请求/api/Video/getVideoDetail用] * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类 * @return name:second_classify type:int default:-- desc:视频二级分类 * @return name:is_top type:int default:-- desc:是否置顶(0否,1是) * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是) * @return name:is_over type:int default:-- desc:是否完结(0否,1是) * @return name:label_name type:array default:-- desc:标签 * @return name:read_num type:int default:-- desc:播放量 * @return name:total_num type:int default:-- desc:总数量 * @return name:is_collect type:int default:-- desc:是否收藏 * @return name:app_name type:string default:-- desc:平台名称 * @return name:app_logo type:string default:-- desc:平台头像 * @return name:video_arr type:array default:-- desc:视频地址 * @return name:video_arr.url type:string default:-- desc:视频地址 */ public function getVideoList() { $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['status','=',1]; $sel_where[] = ['url_num','>=',1]; $title = input('get.title'); $type = input('get.type',0); $is_hot = input('get.is_hot',-1); $first_classify = input('get.first_classify'); $second_classify = input('get.second_classify'); $sort_type = input('get.sort_type',1); $is_tj = input('get.is_tj',0); $app_name = sysconf('app_name'); $app_logo = sysconf('app_logo'); if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1); if($title) $sel_where[] = ['title|label','like','%'.$title.'%']; if($first_classify) $sel_where[] = ['first_classify','=',$first_classify]; if($second_classify) $sel_where[] = ['second_classify','=',$second_classify]; if($type) $sel_where[] = ['type','=',$type]; if($is_hot >= 0) $sel_where[] = ['is_hot','=',$is_hot]; $where_str = 'id > 0'; switch ($sort_type) { case 1: $order = ['is_top'=>'desc','sort'=>'desc','id'=>'desc']; break; case 2: $order = ['id'=>'asc','sort'=>'desc']; break; case 3: $order = ['id'=>'desc','sort'=>'desc']; break; } $total_num =VideoIntro::where($sel_where)->where($where_str)->count(); $list = VideoIntro::with(['videoArr'])->where($sel_where) ->where($where_str) ->order($order) ->limit($this->off_set,$this->page_num)->select()->toArray(); array_walk($list,function (&$v,$k)use ($app_name,$app_logo){ $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['id']); $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null; $v['read_num'] = array_sum(array_column($v['video_arr'],'read_num')); $v['app_name'] = $app_name; $v['app_logo'] = $app_logo; }); $this->success('ok',['list'=>$list,'total_num'=>$total_num]); } /** * @title 获取推荐视频列表【不分页】【弃用】 * @desc 获取推荐视频列表【不分页】 * @author qc * @method GET * @url /api/Video/getRecommendVideoList * @header name:Authorization require:1 desc:Token * @return name:id type:string default:-- desc:id * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:预览图 * @return name:transmit_num type:int default:-- desc:转发量 * @return name:read_num type:int default:-- desc:播放量 * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是) * @return name:ppt type:string default:-- desc:关联ppt链接 * @return name:ali_vid type:string default:-- desc:阿里云点播id * @return name:app_name type:string default:-- desc:平台名称 * @return name:app_logo type:string default:-- desc:平台头像 */ public function getRecommendVideoList() { $app_name = sysconf('app_name'); $app_logo = sysconf('app_logo'); $where_str = 'id > 0'; $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['status','=',1]; $search_log = UserSearch::getSearchTitle($this->user_id,1); $search_arr = []; foreach ($search_log as $t){ $search_arr[] = " title like '".'%'.$t."%'" .' '; } if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr); $list = VideoUrl::field('id,video_id,title,cover,ali_vid,ppt,is_vip,read_num') ->where($where_str)->where($sel_where)->order('id desc')->limit(0,20)->select()->toArray(); $rand_num = 0; if(count($list) < 20)$rand_num = 20 - count($list); if($rand_num > 0) { $rand_list = VideoUrl::field('id,video_id,title,cover,ali_vid,ppt,is_vip,read_num')->where(function ($query)use($rand_num,$list){ if(!empty($search_ids)){ $search_ids = array_column($list,'id'); $all_ids = VideoUrl::where(['is_deleted'=>0])->where('id not in '.implode(',',$search_ids))->column('id,title','id'); $rand_ids = array_keys($all_ids); if(count($all_ids) > $rand_num) $rand_ids = array_rand($all_ids,$rand_num); return $query->where('id','in',implode(',',$rand_ids)); } })->where($sel_where)->limit(0,$rand_num)->select()->toArray(); if(!empty($rand_list)) $list = array_merge($list,$rand_list); } array_walk($list,function (&$v,$k)use ($app_name,$app_logo){ $v['app_name'] = $app_name; $v['app_logo'] = $app_logo; }); $this->success('ok',$list); } /** * @title 视频搜索 * @desc 视频搜索 * @author qc * @method GET * @url /api/Video/videoSearch * @header name:Authorization require:1 desc:Token * @param name:title type:string default:1 desc:标题 * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:预览图 * @return name:transmit_num type:int default:-- desc:转发量 * @return name:read_num type:int default:-- desc:播放量 * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是) * @return name:ali_vid type:string default:-- desc:阿里云点播id * @return name:app_name type:string default:-- desc:平台名称 * @return name:app_logo type:string default:-- desc:平台头像 */ public function videoSearch() { $title = input('get.title'); $sort_type = input('get.sort_type',1); if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1); $sel_where = []; $sel_where[] = ['a.is_deleted','=',0]; $sel_where[] = ['a.status','=',1]; $sel_where[] = ['b.is_deleted','=',0]; $sel_where[] = ['b.status','=',1]; if($title) $sel_where[] = ['a.title|a.label','like','%'.$title.'%']; $app_name = sysconf('app_name'); $app_logo = sysconf('app_logo'); switch ($sort_type) { case 1: $order = ['a.id'=>'desc']; break; case 2: $order = ['a.id'=>'asc','a.sort'=>'desc']; break; case 3: $order = ['a.id'=>'desc','a.sort'=>'desc']; break; } $list = VideoUrl::field('a.id,a.video_id,a.title,a.cover,a.ali_vid,a.ppt,a.is_vip,a.read_num') ->alias('a') ->leftJoin('VideoIntro b','a.video_id = b.id') ->where($sel_where)->order($order) ->limit($this->off_set,$this->page_num)->select()->toArray(); array_walk($list,function (&$v,$k)use ($app_name,$app_logo){ $v['app_name'] = $app_name; $v['app_logo'] = $app_logo; }); $this->success('ok',$list); } /** * @title 获取视频详情(平台) * @desc 获取视频详情 * @author qc * @method GET * @url /api/Video/getVideoDetail * @header name:Authorization require:1 desc:Token * @param name:id type:int default:0 desc:视频id * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类 * @return name:is_top type:int default:-- desc:是否置顶(0否,1是) * @return name:read_num type:int default:-- desc:播放量 * @return name:video_arr type:array default:-- desc:视频地址 * @return name:video_arr.id type:int default:-- desc:ID[请求视频模块其他接口参数:url_id] * @return name:video_arr.cover type:string default:-- desc:预览图 * @return name:video_arr.url type:string default:-- desc:视频地址 * @return name:video_arr.transmit_num type:int default:-- desc:转发量 * @return name:video_arr.read_num type:int default:-- desc:播放量 * @return name:video_arr.is_vip type:int default:-- desc:是否是需要会员(0否1是) * @return name:video_arr.is_collect type:int default:-- desc:是否收藏 * @return name:video_arr.collect_num type:int default:-- desc:收藏量 * @return name:video_arr.praise_num type:int default:-- desc:点赞量 * @return name:video_arr.is_praise type:int default:-- desc:是否点赞 * @return name:video_arr.article_id type:int default:-- desc:关联视频id【单个id||系列id】 * @return name:video_arr.article_item type:int default:-- desc:关联视频详情id【item_list.id】 * @return name:video_arr.datum_id type:int default:-- desc:资料id【单个id||系列id】 * @return name:video_arr.datum_item type:int default:-- desc:资料详情id【url_arr.id】 * @return name:video_arr.ppt type:string default:-- desc:关联ppt链接 * @return name:video_arr.ali_vid type:string default:-- desc:阿里云点播id */ public function getVideoDetail() { $sel_where = []; $sel_where[] = ['id','=',input('get.id')]; $detail = VideoIntro::with(['videoArr'])->where($sel_where)->find()->toArray(); if($detail['is_deleted'] == 1 || $detail['status'] == 0)$this->error('该视频已下线'); $detail['label_name'] = []; if($detail['label']) { $detail['label_name'] = explode(',',trim($detail['label'],',')); } $level_id = UserLevelRank::getUserVip($this->user_id); foreach ($detail['video_arr'] as &$dv) { if($dv['is_vip'] && !$level_id) $dv['url'] = ''; $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$detail['id'],$dv['id']); // $dv['collect_num'] = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>1,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count(); $dv['collect_num'] = UserCollect::getCollectNum(1,$detail['id'],$dv['id']); $dv['is_praise'] = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$dv['id']])->count(); $dv['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$dv['id']])->count(); } $detail['read_num'] = array_sum(array_column($detail['video_arr'],'read_num')); $this->success('ok',['detail'=>$detail]); } /** * @title 获取视频列表(用户发布【审核通过的】) * @desc 用户发布【审核通过的】 * @author qc * @method GET * @url /api/Video/getUserVideoList * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:first_classify type:int default:0 desc:视频一级分类 * @param name:second_classify type:int default:0 desc:视频二级分类 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类 * @return name:second_classify type:int default:-- desc:视频二级分类 * @return name:read_num type:int default:-- desc:播放量 * @return name:is_collect type:int default:-- desc:是否收藏 */ public function getUserVideoList() { $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['status','=',1]; $title = input('get.title'); $first_classify = input('get.first_classify'); $second_classify = input('get.second_classify'); if($title) $sel_where[] = ['v.title|v.label','like','%'.$title.'%']; if($first_classify) $sel_where[] = ['v.first_classify','=',$first_classify]; if($second_classify) $sel_where[] = ['v.second_classify','=',$second_classify]; $list = UserVideo::field('v.*')->where($sel_where)->order('v.id desc') ->alias('v') ->leftJoin('User u','u.id = v.user_id') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 获取我的视频列表 * @desc 获取我的视频列表 * @author qc * @method GET * @url /api/Video/getMyVideoList * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类 * @return name:second_classify type:int default:-- desc:视频二级分类 * @return name:read_num type:int default:-- desc:播放量 * @return name:is_collect type:int default:-- desc:是否收藏 * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过 */ public function getMyVideoList() { $sel_where = []; $sel_where[] = ['is_deleted','=',0]; $sel_where[] = ['user_id','=',$this->user_id]; $title = input('get.title'); if($title) $sel_where[] = ['title|label','like','%'.$title.'%']; $list = UserVideo::where($sel_where)->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 获取视频详情(会员) * @desc 获取视频详情 * @author qc * @method GET * @url /api/Video/getUserVideoDetail * @header name:Authorization require:1 desc:Token * @param name:id type:int default:0 desc:视频id * @param name:first_classify type:int default:0 desc:视频一级分类 * @param name:second_classify type:int default:0 desc:视频二级分类 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类 * @return name:second_classify type:int default:-- desc:视频二级分类 * @return name:read_num type:int default:-- desc:播放量 * @return name:is_collect type:int default:-- desc:是否收藏 * @return name:collect_num type:int default:-- desc:收藏量 * @return name:praise_num type:int default:-- desc:点赞量 * @return name:is_praise type:int default:-- desc:是否点赞 * @return name:transmit_num type:int default:-- desc:转发量 */ public function getUserVideoDetail() { $detail = UserVideo::where('id',input('get.id'))->find(); if(!$detail)$this->error('该视频已下线'); if($detail->status != 1)$this->error('该视频未通过审核'); $detail->is_collect = 0; $detail->collect_num = 0; $detail->is_praise =0; $detail->praise_num = 0; $this->success('ok',['detail'=>$detail->toArray()]); } /** * @title 用户提交或修改视频 * @desc 用户提交或修改视频 * @author qc * @method POST * @url /api/Video/userReferVideo * @header name:Authorization require:1 desc:Token * @param name:id type:int default:-- desc:id(修改时必传) * @param name:title type:string default:-- desc:标题 * @param name:video_url type:string default:-- desc:视频地址 * @param name:desc type:string default:-- desc:简介 * @param name:first_classify type:int default:-- desc:视频一级分类id * @param name:second_classify type:int default:-- desc:视频二级分类id * @param name:label type:string default:-- desc:视频标签id(多个用逗号隔开) */ public function userReferVideo() { $id = input('post.id',0); $title = input('post.title'); $desc = input('post.desc'); $video_url = input('post.video_url'); $cover = $video_url.'?x-oss-process=video/snapshot,t_2000,m_fast'; $first_classify = input('post.first_classify',0); $second_classify = input('post.second_classify',0); $label = input('post.label'); if(!$video_url) $this->error('请上传视频'); if($id){ $check_status = UserVideo::where('id',$id)->value('status'); if($check_status == 1) $this->error('视频已审核通过,不允许修改'); } $data = [ 'title' => $title, 'cover' => $cover, 'user_id' => $this->user_id, 'desc' => $desc, 'first_classify' => $first_classify, 'second_classify' => $second_classify, 'video_url' => $video_url, 'label' => $label, 'status' => 0, 'remark' => '', ]; if($id) $data['id'] = $id; if($id){ UserVideo::where('id',$id)->update($data); }else{ $res= UserVideo::create($data) ; } UserMessage::sendUserMessage($this->user_id,'video',1,0,0,$id ? $id:$res->id); $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]); } /** * @title 获取用户提交视频详情 * @desc 获取用户提交视频详情 * @author qc * @method GET * @url /api/Video/userReferVideoDetail * @header name:Authorization require:1 desc:Token * @param name:id type:int default:-- desc:id * @return name:title type:string default:-- desc:标题 * @return name:cover type:string default:-- desc:封面 * @return name:video_url type:string default:-- desc:视频地址 * @return name:first_classify type:int default:-- desc:视频一级分类id * @return name:second_classify type:int default:-- desc:视频二级分类id * @return name:label type:string default:-- desc:视频标签id(多个用逗号隔开) */ public function userReferVideoDetail() { $detail = UserVideo::where('id',input('get.id'))->find()->toArray(); if($detail['is_deleted'] == 1) $this->error('视频已删除'); $detail['label_name'] = []; if($detail['label']) { $detail['label_name'] =explode(',',trim($detail['label'],',')); } $this->success('获取成功',['detail'=>$detail]); } /** * @title 用户删除视频记录 * @desc 用户删除视频记录 * @author qc * @method POST * @url /api/Video/delUserVideo * @header name:Authorization require:1 desc:Token * @param name:id type:int default:-- desc:id */ public function delUserVideo() { UserVideo::where(['user_id'=>$this->user_id,'id'=>input('post.id')])->delete(); $this->success('删除成功'); } /** * @title 视频评论 * @desc 视频评论 * @author qc * @method POST * @url /api/Video/videoComment * @header name:Authorization require:1 desc:Token * @param name:video_type type:int default:1 desc:视频类型(1平台2会员) * @param name:video_id type:int default:-- desc:视频id * @param name:url_id type:int default:-- desc:平台类型必传 * @param name:content type:string default:-- desc:内容 */ public function videoComment() { $video_type = input('post.video_type',1); $video_id = input('post.video_id'); $url_id = input('post.url_id',0); $content = input('post.content',0); if(!$content) $this->error('请输入评论内容'); $res = VideoComment::create(['user_id'=>$this->user_id,'content'=>$content,'video_id'=>$video_id,'url_id'=>$url_id,'video_type'=>$video_type]);; $detail =VideoComment::where('c.id',$res->id) ->alias('c') ->field('c.id,c.content,c.user_id,c.create_at,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find()->toArray(); $send_user = VideoUrl::where('id',$url_id)->value('user_id'); $user_info = $this->userInfo('name'); if($send_user) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$url_id,$user_info['name'].'评论了您的视频'); $this->success('评论成功',['detail'=>$detail]); } /** * @title 视频二级评论 * @desc 视频二级评论 * @author qc * @method POST * @url /api/Video/secondCommend * @header name:Authorization require:1 desc:Token * @param name:id type:int default:1 desc:评论id * @param name:content type:string default:-- desc:内容 * @return name:name type:string default:-- desc:会员名称 * @return name:headimg type:string default:-- desc:会员头像 * @return name:content type:string default:-- desc:内容 */ public function secondCommend() { $comment = VideoComment::where('id',input('post.id'))->find()->toArray(); $user_info = $this->userInfo('name'); UserMessage:: sendUserMessage($comment['user_id'],'video',3,0,$this->user_id,$comment['id'],$user_info['name'].'回复了您的评论'); $send_user = VideoUrl::where('id',$comment['url_id'])->value('user_id'); if($send_user) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$comment['url_id'],$user_info['name'].'评论了您的视频'); unset($comment['id']); unset($comment['create_at']); $comment['pid'] = input('post.id'); $comment['user_id'] = $this->user_id; $comment['content'] = input('post.content'); $comment['lev']++; if(!$comment['source_id']) $comment['source_id'] = input('post.id'); $res = VideoComment::create($comment); $detail = VideoComment::where('c.id',$res->id) ->alias('c') ->field('c.id,c.content,c.create_at,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find()->toArray(); $this->success('评论成功',['detail'=>$detail]); } /** * @title 获取视频评论列表 * @desc 获取视频评论列表 * @author qc * @method GET * @url /api/Video/getVideoCommentList * @header name:Authorization require:1 desc:Token * @param name:video_type type:int default:1 desc:视频类型(1平台2会员) * @param name:video_id type:int default:-- desc:视频id * @param name:url_id type:int default:-- desc:url_id * @param name:sort_type type:int default:1 desc:排序规则1时间2热点 * @param name:page type:int default:1 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:name type:string default:-- desc:会员名称 * @return name:headimg type:string default:-- desc:会员头像 * @return name:content type:string default:-- desc:内容 * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】) * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】) * @return name:like_num type:int default:-- desc:点赞数量 * @return name:is_like type:int default:-- desc:是否点赞(0否1是) * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是) * @return name:total_num type:int default:-- desc:总评论数(仅一级) * */ public function getVideoCommentList() { $where = []; $where[] = ['c.video_id','=',input('get.video_id')]; $where[] = ['c.url_id','=',input('get.url_id')]; $where[] = ['c.video_type','=',input('get.video_type')]; $where[] = ['c.is_deleted','=',0]; $user_id = $this->user_id; $sort_type= input('sort_type',1); switch ($sort_type) { case 1: $order = ['c.id'=>'desc','c.like_times'=>'desc']; break; case 2: $order = ['c.like_times'=>'desc','c.id'=>'desc']; break; } $list =VideoComment::where($where) ->alias('c') ->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->order($order) ->limit($this->off_set,$this->page_num) ->select()->toArray(); array_walk($list,function (&$val,$k)use($user_id){ $children = VideoComment::where(['c.pid'=>$val['id'],'c.is_deleted'=>0]) ->alias('c') ->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->order('c.id asc') ->select()->toArray(); $val['like_num'] = VideoCommentLike::where('like_id',$val['id'])->where('type',1)->count(); $val['children'] = $children; $val['is_like'] = VideoCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>1])->count(); $parent = VideoComment::where(['c.id'=>$val['pid'],'c.is_deleted'=>0]) ->alias('c')->field('c.*,u.name,u.headimg') ->leftJoin('store_member u','u.id = c.user_id') ->find(); $val['parent'] = $parent ? $parent->toArray() : null; $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0; }); $total_num = VideoComment::where($where)->alias('c')->count(); $this->success('ok',['list'=>$list,'total_num'=>$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 */ public function delComment(){ VideoComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]); $this->success('删除成功'); } /** * @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) * @return name:tags type:int default:1 desc:0取消成功,1点赞成功 */ public function videoTags() { $type = input('post.type',1); $like_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'); } $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]); } /** * @title 视频转发(转发数量统计) * @desc 转发成功后调用 * @author qc * @method POST * @url /api/Video/videoTransmit * @header name:Authorization require:1 desc:Token * @param name:video_type type:int default:1 desc:视频类型(1平台2会员) * @param name:video_id type:int default:-- desc:视频id * @param name:url_id type:int default:-- desc:平台类型必传 */ public function videoTransmit() { $video_type = input('post.video_type',1); $video_id = input('post.video_id'); $url_id = input('post.url_id',0); if($video_type == 1) { VideoUrl::where('id',$url_id)->setInc('transmit_num'); }else{ UserVideo::where('id',$video_id)->setInc('transmit_num'); } $this->success('ok'); } /** * @title 视频播放(播放数量统计) * @desc 播放数量统计 * @author qc * @method POST * @url /api/Video/videoPlay * @header name:Authorization require:1 desc:Token * @param name:video_id type:int default:-- desc:视频id * @param name:url_id type:int default:-- desc:url_id */ public function videoPlay() { $video_id = input('post.video_id'); $url_id = input('post.url_id',0); VideoUrl::where('id',$url_id)->setInc('read_num'); if(!$video_id) $video_id = VideoUrl::where('id',$url_id)->value('video_id'); UserTrack::crateTrack($this->user_id,1,$video_id,$url_id); $this->success('ok'); } /** * @title 以下接口学习服务模块的 * @desc * @author qc * @method * @url /api/Video/learn() */ public function learn(){} /** * @title 视频学习历史 * @desc 视频学习历史 * @author qc * @method GET * @url /api/Video/getLearnHistory * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:time type:string default:-- desc:时间 * @return name:ali_vid type:string default:-- desc:云点播id * @return name:is_vip type:int default:-- desc:是否是vip[0否1是] */ public function getLearnHistory() { $sel_where = []; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.type','=',1]; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $list = UserTrack::where($sel_where) ->alias('t') ->field('t.id,t.update_int,t.first_id video_id,t.second_id url_id,i.title,i.cover,i.ali_vid') ->leftJoin('VideoUrl i','t.second_id = i.id') ->order('update_int desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['time'] = date("Y-m-d H:i:s",$v['update_int']); } $this->success('ok',['list'=>$list]); } /** * @title 回复我的【回复我的--回复过我的评论】 * @desc 回复我的 * @author qc * @method GET * @url /api/Video/getReplayComment * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【其他会员】 * @return name:headimg type:string default:-- desc:用户头【其他会员】 * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】 * @return name:parent_comment.content type:string default:-- desc:内容 * @return name:parent_comment.name type:string default:-- desc:会员名称 * @return name:parent_comment.title type:string default:-- desc:视频标题 * @return name:parent_comment.video_id type:string default:-- desc:视频id * @return name:parent_comment.url_id type:string default:-- desc:url_id * @return name:parent_comment.ali_vid:string default:-- desc:云点播id */ public function getReplayComment() { $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id'); if(empty($all_comment)) $this->success('ok',['list'=>null]); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['t.lev','=',2]; $sel_where[] = ['t.user_id','<>',$this->user_id]; $sel_where[] = ['t.pid','in',implode(',',$all_comment)]; $list = VideoComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.id url_id,i.video_id,i.ali_vid,i.cover') ->leftJoin('store_member u','t.user_id = u.id') ->leftJoin('VideoUrl i','t.url_id = i.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $parent_comment = VideoComment::where([['t.id','=',$v['pid']]]) ->field('t.id,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid') ->alias('t') ->leftJoin('VideoUrl i','t.url_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->find()->toArray(); $v['parent_comment'] = $parent_comment; } $this->success('ok',['list'=>$list]); } /** * @title 我的回复【我的回复--我回复过的评论】 * @desc 我的评论 * @author qc * @method GET * @url /api/Video/getReplyVideo * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【用户自己的】 * @return name:headimg type:string default:-- desc:用户头像【用户自己的】 * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】 * @return name:parent_comment.content type:string default:-- desc:内容 * @return name:parent_comment.name type:string default:-- desc:会员名称 * @return name:parent_comment.title type:string default:-- desc:视频标题 * @return name:parent_comment.video_id type:string default:-- desc:视频id * @return name:parent_comment.url_id type:string default:-- desc:url_id * @return name:parent_comment.ali_vid:string default:-- desc:云点播id */ public function getReplyVideo() { $user_info = $this->userInfo(); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['t.lev','=',2]; $list = VideoComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.lev,t.content,i.title,t.pid,i.id url_id,i.video_id,i.ali_vid,i.cover') ->leftJoin('VideoUrl i','t.url_id = i.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['user_name'] = $user_info['name']; $v['headimg'] = $user_info['headimg']; $parent_comment = VideoComment::where([['t.id','=',$v['pid']]]) ->field('t.id,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid') ->alias('t') ->leftJoin('VideoUrl i','t.url_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->find()->toArray(); $v['parent_comment'] = $parent_comment; } $this->success('ok',['list'=>$list]); } /** * @title 我的评论【学习服务--我评论过的视频】 * @desc 我的评论 * @author qc * @method GET * @url /api/Video/getCommentVideo * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名【用户自己的】 * @return name:headimg type:string default:-- desc:用户头像【用户自己的】 * @return name:ali_vid:string default:-- desc:云点播id */ public function getCommentVideo() { $user_info = $this->userInfo(); $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.is_deleted','=',0]; $list = VideoComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.video_id,t.url_id,t.lev,t.content,i.title,i.cover,i.ali_vid,i.cover') ->leftJoin('VideoUrl i','t.url_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); foreach ($list as &$v) { $v['user_name'] = $user_info['name']; $v['headimg'] = $user_info['headimg']; } $this->success('ok',['list'=>$list]); } /** * @title 评论我的【学习服务--评论我的】 * @desc 评论我的 * @author qc * @method GET * @url /api/Video/commentMyVideo * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:user_name type:string default:-- desc:用户名 * @return name:headimg type:string default:-- desc:用户头像 * @return name:ali_vid:string default:-- desc:云点播id */ public function commentMyVideo() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.is_deleted','=',0]; $sel_where[] = ['i.user_id','=',$this->user_id]; $list = VideoComment::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.video_id,t.video_id,t.lev,t.content,i.title,i.cover,i.ali_vid,u.name user_name,u.headimg') ->leftJoin('VideoUrl i','t.url_id = i.id') ->leftJoin('store_member u','t.user_id = u.id') ->order('t.id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 已购视频列表 * @desc 已购视频列表 * @author qc * @method GET * @url /api/Video/getPurchaseVideo * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:ali_vid type:string default:-- desc:云点播id * @return name:is_vip type:int default:-- desc:是否是vip[0否1是] */ public function getPurchaseVideo() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.type','=',1]; $sel_where[] = ['t.end_int','>',time()]; $list = UserLearn::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.first_id video_id,t.second_id url_id,i.title,i.cover,i.is_vip,i.ali_vid') ->leftJoin('VideoUrl i','t.second_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 视频收藏记录【我的收藏】 * @desc 视频收藏记录 * @author qc * @method GET * @url /api/Video/getVideoCollect * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:ali_vid type:string default:-- desc:云点播id * @return name:is_vip type:int default:-- desc:是否是vip[0否1是] */ public function getVideoCollect() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $sel_where[] = ['t.coll_type','=',1]; $list = UserCollect::where($sel_where) ->alias('t') ->field('t.id,t.create_at,t.coll_id video_id,t.children_id url_id,i.title,i.cover,i.is_vip,i.ali_vid') ->leftJoin('VideoUrl i','t.children_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } /** * @title 视频点赞列表【我的点赞】 * @desc 视频点赞列表 * @author qc * @method GET * @url /api/Video/getTagsVideo * @header name:Authorization require:1 desc:Token * @param name:title type:string default:-- desc:标题 * @param name:page type:int default:0 desc:页数 * @param name:page_num type:int default:20 desc:每页数 * @return name:title type:string default:-- desc:标题 * @return name:video_id type:string default:-- desc:视频id * @return name:url_id type:string default:-- desc:url_id * @return name:cover type:string default:-- desc:封面 * @return name:create_at type:string default:-- desc:时间 * @return name:ali_vid type:string default:-- desc:云点播id * @return name:is_vip type:int default:-- desc:是否是vip[0否1是] */ public function getTagsVideo() { $sel_where = []; $title = input('get.title'); if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%']; $sel_where[] = ['t.user_id','=',$this->user_id]; $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') ->leftJoin('VideoUrl i','t.like_id = i.id') ->order('id desc') ->limit($this->off_set,$this->page_num) ->select()->toArray(); $this->success('ok',['list'=>$list]); } }