123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043 |
- <?php
- namespace app\api\controller;
- use AlibabaCloud\SDK\Vod\V20170321\Models\GetMediaDNAResultResponseBody\DNAResult\videoDNA\detail\input;
- use app\common\model\ArticleItem;
- use app\common\model\DatumUrl;
- use app\common\model\PlatformSwitch;
- use app\common\model\SeriesVideoCate;
- use app\common\model\TopSearch;
- use app\common\model\User;
- use app\common\model\UserCollect;
- use app\common\model\UserLearn;
- use app\common\model\UserLevel;
- use app\common\model\UserLevelRank;
- use app\common\model\UserMessage;
- use app\common\model\UserSearch;
- use app\common\model\UserTrack;
- use app\common\model\UserVideo;
- use app\common\model\VideoCate;
- use app\common\model\VideoComment;
- use app\common\model\VideoCommentLike;
- use app\common\model\VideoIntro;
- use app\common\model\VideoLabel;
- use app\common\model\VideoUrl;
- use app\common\service\CheckPower;
- use app\common\service\UserSynth;
- use library\tools\Data;
- use think\Db;
- /**
- * @title 视频
- * @controller Video
- * @group base
- */
- class Video extends Base
- {
- // 需要登录的
- protected $need_login = [
- 'getMyVideoList',
- 'userReferVideoDetail',
- 'userReferVideo',
- 'delUserVideo',
- 'videoComment',
- 'secondCommend',
- 'delComment',
- 'videoTags',
- 'videoTransmit',
- 'videoPlay',
- 'getLearnHistory',
- 'getReplayComment',
- 'getCommentVideo',
- 'commentMyVideo',
- 'getReplyVideo',
- 'getPurchaseVideo',
- 'getVideoCollect',
- 'getTagsVideo',
- 'videoCollect',
- 'batchesDel',
- 'getBoundList',
- 'getFollowUpList',
- 'getTagsComment',
- 'getFollowUpMessage',
- 'praiseMyVideoList',
- 'praiseMyComment',
- 'unreadChange',
- 'getMarkNum',
- 'getUserVideoDetail', //1.5新增
- 'getVideoDetail', //1.5新增
- ];
- public function initialize()
- {
- parent::initialize();
- parent::setUid();
- $this->source_type= $this->request->header('source-type',1);
- }
- /**
- * @title 视频接口说明
- * @desc 视频接口说明
- * @author qc
- * @url /api/Video/classIntro
- * @method GET
- * @return name:1 type:string default:-- desc:视频播放改DRM加密,请勿用视频地址【url】播放,这个字段弃用!!
- * @return name:2 type:string default:-- desc:ali_vid视频点播id,阿里云视频点播用
- */
- public function classIntro(){}
- /**
- * @title 获取分类
- * @desc 获取分类(共两级)
- * @author qc
- * @url /api/Video/getCateTree
- * @method GET
- * @header name:Authorization require:1 desc:Token
- * @param name:type type:int default:2 desc:类型2系列
- * @return name:id type:int default:-- desc:分类id
- * @return name:logo type:string default:-- desc:图标
- * @return name:title type:string default:0 desc:分类名称
- * @return name:children type:array default:0 desc:下级分类
- */
- public function getCateTree()
- {
- $type = input('type',2);
- if($type == 1) {
- $list = VideoCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc ')->select()->toArray();
- }else{
- $list = SeriesVideoCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->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:每页数
- * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
- * @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:发布者头像
- * @return name:read_num type:string default:-- desc:阅读量
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:cover_type type:int default:-- desc:1显示大图0显示小图【page_num必须是7的倍数(其他页数忽略这个参数),建议21,】
- * @return name:release_time type:string default:-- desc:上架时间
- */
- public function getRecommendList()
- {
- $user_id = $this->user_id ? $this->user_id : input('rand_user');
- if(!$user_id) $this->error('参数错误');
- $list = UserSynth::getRecommendList($user_id,'video',$this->page,$this->page_num,[],input('sort_type',1));
- if($list['code'] != 200) $this->error($list['msg']);
- $this->success('ok',$list);
- $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.create_at,a.ali_vid,a.video_id,a.duration ,IFNULL(is_recommend,0) is_recommend ';
- $table = 'dd_video_url';
- $order_by_two = 'a.read_num';
- $time_str = date("Y-m-d H:i:s");
- $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.release_time < '". $time_str ."' 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}";
- // var_dump($sql);
- $list = Db::query($sql);
- $list = dispose_recommend($list);
- $seven = [0,7,14,21,28,];
- array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
- $v['cover_type'] = $k%7 ? 0 : 1;
- $v['create_at'] = substr($v['create_at'],0,10);
- 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 : '';
- }
- });
- $sql2 = "SELECT count(a.id) num 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.release_time < '". $time_str ."' AND a.status =1 AND k.is_deleted = 0 AND k.status = 1";
- $total = Db::query($sql2);
- $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取视频列表(平台发布)
- * @desc 获取视频列表
- * @author qc
- * @method GET
- * @url /api/Video/getVideoList
- * @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:每页数
- * @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:视频地址
- * @return name:video_arr.duration type:int 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',2);
- $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);
- $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 = ['sort'=>'asc','id'=>'asc'];
- break;
- case 2:
- $order = ['sort'=>'asc','id'=>'desc'];
- break;
- case 3:
- $order = ['sort'=>'desc','id'=>'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;
- });
- foreach ($list as &$value){
- $recently_info = UserTrack::getRecentlyTrack($this->user_id,1,$value['id'],1);
- $recently_id = !empty($recently_info) ? $recently_info['second_id'] : false;
- foreach ($value['video_arr'] as &$v){
- $v['is_recently'] = $v['id'] == $recently_id ? 1 : 0;
- }
- $value['cate'] = SeriesVideoCate::where('id',$value['second_classify'])->value('title');
- }
- $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取系列列表
- * @desc 获取系列列表
- * @author qc
- * @method GET
- * @url /api/Video/getSeriesList
- * @header name:Authorization require:1 desc:Token
- * @param name:first_classify type:int default:0 desc:一级分类
- * @param name:second_classify type:int default:0 desc:二级分类
- * @return name:second_classify type:int default:-- desc:二级分类
- * @return name:title type:int default:-- desc:二级分类名称
- * @return name:series_list type:array default:-- desc:系列列表
- * @return name:series_list.id type:string default:-- desc:系列id
- * @return name:series_list.title type:string default:-- desc:标题
- * @return name:series_list.cover type:string default:-- desc:封面
- * @return name:series_list.is_vip type:int default:-- desc:是否是vip(0否,1是)
- * @return name:series_list.is_over type:int default:-- desc:是否完结(0否,1是)
- */
- public function getSeriesList()
- {
- $type = input('get.type',2);
- $first_classify = input('get.first_classify');
- $second_classify = input('get.second_classify');
- $list = SeriesVideoCate::where(['is_deleted'=>0,'status'=>1])
- ->field('id second_classify,title')->where('pid',$first_classify)
- ->when($second_classify,function ($query)use ($second_classify){if($second_classify){$query->where('id',$second_classify);}})
- ->order('sort desc,id asc')->select()->toArray();
- foreach ($list as &$v) {
- $v['series_list'] = VideoIntro::field('id,title,cover,is_vip,is_over')
- ->where('second_classify',$v['second_classify'])
- ->where('status',1)
- ->where('is_deleted',0)
- ->where('url_num','>',0)
- ->where('type',$type)->limit($this->off_set,100)
- ->order('sort desc,id desc')->select()->toArray();
- }
- $this->success('ok',['list'=>$list]);
- }
- /**
- * @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:pdf_clear type:string default:-- desc:pdf未加密链接
- * @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,pdf_clear,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,pdf_clear,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:label_name type:array 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:发布者头像
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:create_at type:int 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];
- $sel_where[] = ['a.release_time','< time',date("Y-m-d H:i:s")];
- 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.read_num'=>'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.user_id,a.label,a.cover,a.ali_vid,a.duration,a.ppt,a.pdf_clear,a.is_vip,a.read_num,a.create_at')
- ->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['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')) : null;
- 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 : '';
- }
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = VideoUrl::field('a.id,a.video_id,a.title,a.user_id,a.cover,a.ali_vid,a.duration,a.ppt,a.pdf_clear,a.is_vip,a.read_num')
- ->alias('a')
- ->leftJoin('VideoIntro b','a.video_id = b.id')
- ->where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
- * @return name:follow_switch type:int default:-- desc:追番开关状态【0关闭1开启】
- * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
- * @return name:total_sequel type:int default:-- desc:共多少期【期数】(默认1)
- * @return name:is_over type:int default:-- desc:是否完结
- * @return name:user_level type:int default:-- desc:会员等级id
- * @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】
- * @return name:video_arr.article_item type:int default:-- desc:图文详情资料【系列下的其中一个】
- * @return name:video_arr.datum_id type:int default:-- desc:资料id【系列id】
- * @return name:video_arr.datum_item type:int default:-- desc:资料id【系列下的其中一个】
- *
- * @return name:video_arr.article_jump type:int default:-- desc:关联图文是否能跳转【0不能跳转,1能跳转,验证是否vip】
- * @return name:video_arr.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
- *
- * @return name:video_arr.ppt type:string default:-- desc:关联ppt链接
- * @return name:video_arr.pdf_clear type:string default:-- desc:pdf未加密链接
- * @return name:video_arr.goods_id type:int default:-- desc:供应商商品id
- * @return name:video_arr.ali_vid type:string default:-- desc:阿里云点播id
- * @return name:video_arr.duration type:int default:-- desc:时长(单位:秒)
- * @return name:video_arr.is_recently type:int default:-- desc:是否最近观看【0否1是】
- * @return name:video_arr.track_time type:string default:-- desc:上次观看时间
- * @return name:video_arr.app_name type:string default:-- desc:发布者
- * @return name:video_arr.app_logo type:string default:-- desc:发布者头像
- * @return name:video_arr.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- * @return name:video_arr.mp4_url type:string default:-- desc:mp4路径
- * @return name:video_arr.release_time type:string default:-- desc:上架时间
- */
- public function getVideoDetail()
- {
- $sel_where = [];
- $url_id = input('get.url_id');
- $sel_where[] = ['id','=',input('get.id')];
- $is_release = UserLearn::checkRelease($this->user_id,1,input('get.id'));
- $detail = VideoIntro::with(['videoArr2'=>function($query)use($is_release){
- if(!$is_release) return $query->where('status','=',1);
- }])->where($sel_where)->find();
- if(!$detail){
- $this->error('视频不存在',['detail'=>$detail]);
- }
- $detail = $detail->toArray();
- $detail['video_arr'] = $detail['video_arr2'];
- unset($detail['video_arr2']);
- $detail['is_release'] = $is_release;
- if($is_release && $detail['is_deleted'] )$this->error('该视频已下线');
- if(!$is_release && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该视频已下线');
- $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],2);
- $detail['label_name'] = [];
- if($detail['label']) {
- $detail['label_name'] = explode(',',trim($detail['label'],','));
- }
- $level_id = UserLevelRank::getUserVip($this->user_id);
- $detail['read_num'] = array_sum(array_column($detail['video_arr'],'read_num'));
- $detail['user_level'] = $level_id;
- $recently_info = UserTrack::getRecentlyTrack($this->user_id,1,$detail['id'],1);
- $recently_id = !empty($recently_info) ? $recently_info['second_id'] : false;
- foreach ($detail['video_arr'] as &$dv) {
- if($dv['is_vip'] && !$level_id) $dv['url'] = '';
- $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],7);
- $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();
- $dv['praise_num'] = numTransform($dv['praise_num']);
- $dv['read_num'] = numTransform($dv['read_num']);
- $dv['transmit_num'] = numTransform($dv['transmit_num']);
- $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
- $dv['track_time'] = $dv['is_recently'] ? $recently_info['track_time'] : "0" ;
- $video_auth = VideoUrl::getVideoAuth($dv['user_id'],APPNAME,APPLOGO);
- $dv['app_name'] = $video_auth['app_name'];
- $dv['app_logo'] = $video_auth['app_logo'];
- $dv['article_jump'] = ArticleItem::checkVip($dv['article_item'],$this->user_id);
- $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
- $dv['mp4_url'] = VideoUrl::getMp4Url($dv['ali_vid']);
- }
- // if($this->user_id){
- // TopSearch::seIncHotNum(input('get.id'),$this->request->controller());
- // }
- if($this->user_id){
- $General = new General();
- $General->label($detail['label']);
- }
- $this->success('ok',['detail'=>$detail]);
- }
- /**
- * @title 视频增加热搜量
- * @desc 视频增加热搜量
- * @author qc
- * @method POST
- * @url /api/Video/addTopSearch
- * @header name:Authorization require:1 desc:Token
- * @param name:url_id type:int default:-- desc:视频id
- */
- public function addTopSearch(){
- $url_id = input('url_id');
- if(!$url_id){
- $this->error('参数错误');
- }
- TopSearch::seIncHotNum($url_id,$this->request->controller());
- $this->success('操作成功');
- }
- /**
- * @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 asc')
- ->alias('v')
- ->leftJoin('User u','u.id = v.user_id')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $total_num = UserVideo::where($sel_where)->order('v.id asc')->alias('v')->leftJoin('User u','u.id = v.user_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title ui我的发布--其他【获取我的视频列表【个人发布的】
- * @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 asc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- $total_num = UserVideo::where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:desc type:string default:-- desc:描述
- * @param name:video_url type:string default:-- desc:视频地址
- * @param name:label type:string default:-- desc:视频标签(多个用逗号隔开)
- */
- 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:desc 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])->where('id','in',input('post.id'))->update(['is_deleted'=>1]);
- $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('请输入评论内容');
- $comment_switch = VideoUrl::where('id',$url_id)->value('comment_switch');
- if(!$comment_switch) $this->error('评论功能已关闭');
- $send_user = VideoUrl::where('id',$url_id)->value('user_id');
- $res = VideoComment::create([
- 'user_id'=>$this->user_id,
- 'content'=>$content,
- 'video_id'=>$video_id,
- 'url_id'=>$url_id,
- 'video_type'=>$video_type,
- 'is_read' => $send_user == $this->user_id ? 1 : 0,
- 'source_read' => $send_user == $this->user_id ? 1 : 0,
- ]);
- $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();
- $user_info = $this->userInfo('name');
- if($send_user && $send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$url_id,$content,$url_id,$video_id);
- $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');
- $content = input('post.content');
- if($comment['user_id'] != $this->user_id)UserMessage:: sendUserMessage($comment['user_id'],'video',3,0,$this->user_id,$comment['id'],$content,$comment['url_id'],$comment['video_id']);
- $send_user = VideoUrl::where('id',$comment['url_id'])->value('user_id');
- $to_user = $comment['user_id'];
- $comment_switch = VideoUrl::where('id',$comment['url_id'])->value('comment_switch');
- if(!$comment_switch) $this->error('评论功能已关闭');
- //if($send_user && $send_user != $this->user_id) UserMessage:: sendUserMessage($send_user,'video',4,0,$this->user_id,$comment['url_id'],$content,$comment['url_id'],$comment['video_id']);
- unset($comment['id']);
- unset($comment['create_at']);
- unset($comment['to_deleted']);
- unset($comment['is_top']);
- unset($comment['is_deleted']);
- $comment['pid'] = input('post.id');
- $comment['user_id'] = $this->user_id;
- $comment['content'] = input('post.content');
- $comment['lev']++;
- $comment['is_read']= $this->user_id == $to_user ? 1 :0 ;
- $comment['source_read'] = $this->user_id == $send_user ? 1 :0 ;
- 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:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:is_deleted type:int default:-- desc:是否删除(大于0未删除状态)
- * @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.is_top'=>'desc','c.id'=>'desc','c.like_times'=>'desc'];
- break;
- case 2:
- $order = ['c.is_top'=>'desc','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']])
- ->alias('c')
- ->field('c.*,u.name,u.headimg')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('c.is_top,c.id asc')
- ->select()->toArray();
- $val['like_num'] = VideoCommentLike::where('like_id',$val['id'])->where('type',1)->count();
- $val['like_num'] = numTransform($val['like_num']);
- $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']])
- ->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['parent_comment'] = $val['parent'] ;
- $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'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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评论点赞,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);
- $id = input('post.like_id');
- $ret_val = 0;
- foreach (explode(',',$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{
- if($type == 2) {
- $p_user_id = VideoUrl::where('id',$like_id)->value('user_id');
- }else{
- $p_user_id = VideoComment::where('id',$like_id)->value('user_id');
- }
- $is_read = $p_user_id == $this->user_id ? 1 : 0;
- Data::save('VideoCommentLike',
- ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type,'is_read'=>$is_read],'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_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 require:1 default:-- desc:视频系列id
- * @param name:url_id type:int require:1 default:-- desc:url_id
- * @param name:track_time type:string require:0 default:-- desc:播放到位置
- */
- public function videoPlay()
- {
- $video_id = input('post.video_id');
- $url_id = input('post.url_id',0);
- $track_time = input('post.track_time',0);
- VideoUrl::where('id',$url_id)->setInc('read_num');
- VideoIntro::where('id',$video_id)->setInc('read_num');
- // if($this->user_id){
- // TopSearch::seIncHotNum($url_id,$this->request->controller());
- // }
- if(!$video_id) $video_id = VideoUrl::where('id',$url_id)->value('video_id');
- UserTrack::crateTrack($this->user_id,1,$video_id,$url_id,$track_time);
- $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:series_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:ali_vid type:string default:-- desc:云点播id
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- * @return name:is_normal type:int default:-- desc:是否是正常记录(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,i.duration,i.read_num,i.user_id,i.is_vip,x.title series_title')
- ->leftJoin('VideoUrl i','t.second_id = i.id')
- ->leftJoin('VideoIntro x','t.first_id = x.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']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- }
- $total_num = UserTrack::where($sel_where)->alias('t')
- ->leftJoin('VideoUrl i','t.second_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 获取角标数量【未读数量统计】
- * @desc 未读数量统计
- * @author qc
- * @method GET
- * @url /api/Video/getMarkNum
- * @header name:Authorization require:1 desc:Token
- * @return name:reply_num type:int default:-- desc:回复我的
- * @return name:comment_num type:int default:-- desc:评论我的
- * @return name:praise_num type:int default:-- desc:点赞我的【包含视频点赞和评论点赞】
- * @return name:video_praise_num type:int default:-- desc:-视频点赞
- * @return name:comment_praise_num type:int default:-- desc:评论点赞
- * @return name:follow_num type:int default:-- desc:追播
- */
- public function getMarkNum()
- {
- // 评论我的
- $comment_num = VideoComment::where([['t.is_deleted','=',0],['i.user_id','=',$this->user_id],['t.user_id','<>',$this->user_id],['source_deleted','=',0],['is_read','=',0],['t.pid','=',0]])
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->alias('t')->count();
- // 回复我的
- $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- $reply_num = $all_comment ? VideoComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count() :0;
- // 点赞我的
- $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],['like_id','in',$all_video],['user_id','<>',$this->user_id]])->count();
- $comment_praise_num = VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$all_comment],['user_id','<>',$this->user_id]])->count();
- $praise_num = $video_praise_num + $comment_praise_num;
- // 追播未读量
- $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 删除评论
- * @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 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:duration type:int default:-- desc:时长(单位:秒)
- * @return name:url_id type:string default:-- desc:url_id
- * @return name:cover type:string default:-- desc:封面
- * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:create_at type:string default:-- desc:时间
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo 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.series_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
- * @return name:parent_comment.is_deleted:int default:-- desc:是否删除(0否,1,2已删除)
- * @return name:parent_comment.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- *
- */
- 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'=>[]]);
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.to_deleted','=',0];
- $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
- $reply_num = VideoComment::where([['t.is_deleted','=',0],['t.to_deleted','=',0],['t.user_id','<>',$this->user_id],['t.is_read','=',0],['t.pid','in',implode(',',$all_comment)]])->alias('t')->count();
- $list = VideoComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_top,t.create_at,t.is_read,t.lev,t.content,t.pid,u.name user_name,u.headimg,i.id url_id,i.video_id,i.ali_vid,i.cover,i.duration,i.read_num,i.user_id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->order('t.is_top desc,t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.is_top,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid,t.is_deleted,i.comment_switch,x.title series_title')
- ->alias('t')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->leftJoin('VideoIntro x','t.video_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $v['parent_comment'] = $parent_comment;
- $v['read_num'] = numTransform($v['read_num']);
- }
- $total_num = VideoComment::where($sel_where)->alias('t')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->order('t.is_top desc,t.id desc')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:cover type:string default:-- desc:封面
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @return name:create_at type:string default:-- desc:时间
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- * @return name:read_num type:string default:-- desc:播放量
- * @return name:user_name type:string default:-- desc:用户名【用户自己的】
- * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @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.series_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
- * @return name:parent_comment.is_deleted:int default:-- desc:是否删除(0否,1,2已删除)
- * @return name:parent_comment.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- */
- public function getReplyVideo()
- {
- $user_info = $this->userInfo();
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','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.is_top,t.is_read,t.create_at,t.lev,t.content,i.title,t.pid,i.id url_id,i.video_id,i.ali_vid,i.cover,i.duration,i.user_id buid,read_num,i.comment_switch')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->order('t.is_top,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'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
- ->field('t.id,t.is_top,t.video_id,t.url_id,t.content,i.title,i.cover,t.pid,u.name,i.ali_vid,i.duration,t.is_deleted,x.title series_title')
- ->alias('t')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->leftJoin('VideoIntro x','i.video_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->find()->toArray();
- $v['parent_comment'] = $parent_comment;
- $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- }
- $total_num = VideoComment::where($sel_where)->alias('t')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->order('t.is_top,t.id desc')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_title type:string default:-- desc:系列标题
- * @return name:video_id type:string default:-- desc:视频系列id
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:url_id type:string default:-- desc:url_id
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @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:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:ali_vid:string default:-- desc:云点播id
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- * @return name:read_num type:string default:-- desc:播放量
- */
- public function getCommentVideo()
- {
- $user_info = $this->userInfo();
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['t.pid','=',0];
- $list = VideoComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.is_top,t.video_id,t.url_id,t.lev,t.content,i.title,i.user_id buid, i.cover,i.ali_vid,i.cover,i.duration,i.read_num,x.title series_title')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->leftJoin('VideoIntro x','t.video_id = x.id')
- ->order('t.is_top desc, 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'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- $v['read_num'] = numTransform($v['read_num']);
- }
- $total_num =VideoComment::where($sel_where)->alias('t')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:is_read type:int default:-- desc:是否已读(0未读1已读)
- * @return name:video_id type:string default:-- desc:视频系列id
- * @return name:url_id type:string default:-- desc:url_id
- * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
- * @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
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- */
- public function commentMyVideo()
- {
- $sel_where = [];
- $title = input('get.title');
- if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['i.user_id','=',$this->user_id];
- $sel_where[] = ['t.user_id','<>',$this->user_id];
- $sel_where[] = ['t.source_deleted','=',0];
- $sel_where[] = ['t.pid','=',0];
- $user_info = $this->userInfo('name,headimg');
- $list = VideoComment::where($sel_where)
- ->alias('t')
- ->field('t.id,t.is_read,t.is_top,t.create_at,t.video_id,t.url_id,t.lev,i.read_num,t.content,i.title,i.cover,i.ali_vid,u.name user_name,u.headimg,i.duration,x.title series_title')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->leftJoin('VideoIntro x','t.video_id = x.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->order('t.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v)use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $v['read_num'] = numTransform($v['read_num']);
- $v['app_name'] = $user_info['name'];
- $v['app_logo'] = $user_info['headimg'];
- });
- $total_num = VideoComment::where($sel_where)
- ->alias('t')
- ->leftJoin('VideoUrl i','t.url_id = i.id')
- ->leftJoin('store_member u','t.user_id = u.id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:cover type:string default:-- desc:封面
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @return name:total_sequel type:int default:-- desc:视频期数
- * @return name:first_title type:int default:-- desc:第一期标题
- * @return name:recently_title type:int default:-- desc:上次观看title
- * @return name:is_over type:int default:-- desc:是否完结
- */
- 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()];
- $sel_where[] = ['t.is_deleted','=',0];
- $sel_where[] = ['i.is_deleted','=',0];
- $list = UserLearn::where($sel_where)
- ->alias('t')
- ->field('t.id,t.create_at,t.first_id video_id,i.title,i.cover,i.is_vip,i.total_sequel,i.is_over')
- ->leftJoin('VideoIntro i','t.first_id = i.id')
- ->order('t.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());
- $all_title = VideoUrl::where(['video_id'=>$v['id'],'is_deleted'=>0])->column('title');
- $v['first_title'] = empty($all_title) ? '' : $all_title[0];
- $v['recently_title'] = UserTrack::getRecentlyTitle($this->user_id,1,$v['video_id']);
- });
- $total_num =UserLearn::where($sel_where)->alias('t')->leftJoin('VideoIntro i','t.first_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @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:series_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:duration type:int default:-- desc:时长(单位:秒)
- * @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:收藏量
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:desc type:string default:-- desc:简介
- * @return name:switch_open type:int default:-- desc:通知开关【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.transmit_num,i.is_vip,i.ali_vid,i.duration,i.user_id buid,i.read_num,i.desc,x.title series_title')
- ->leftJoin('VideoUrl i','t.children_id = i.id')
- ->leftJoin('VideoIntro x','t.coll_id = x.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['url_id'],7);
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $v['transmit_num'] = numTransform($v['transmit_num']);
- $v['read_num'] = numTransform($v['read_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['praise_num'] = numTransform($v['praise_num']);
- $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']);
- $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- });
- $total_num = UserCollect::where($sel_where)->alias('t')
- ->leftJoin('VideoUrl i','t.children_id = i.id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 用户视频收藏||取消收藏
- * @desc 用户视频收藏
- * @author qc
- * @method POST
- * @url /api/Video/videoCollect
- * @header name:Authorization require:1 desc:Token
- * @param name:coll_id type:int require:1 default:-- desc:收藏id(平台视频点赞用video_arr的iD)
- * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
- */
- public function videoCollect()
- {
- $coll_type = input('post.coll_type',1);
- $url_id = input('post.coll_id',0);
- $video_id = VideoUrl::where('id',$url_id)->value('video_id');
- $collect_check = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->find();
- if($collect_check) {
- UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->delete();
- $this->success('取消收藏成功',['status'=>0]);
- }else{
- Data::save('UserCollect', [
- 'user_id'=>$this->user_id,
- 'coll_type'=>$coll_type,
- 'coll_id'=>$video_id,
- 'children_id'=>$url_id,
- 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$video_id,'children_id'=>$url_id]);
- $this->success('收藏成功',['status'=>1]);
- }
- }
- /**
- * @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:series_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:duration type:int default:-- desc:时长(单位:秒)
- * @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是]
- * @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:is_collect type:int default:-- desc:是否收藏
- * @return name:collect_num type:int default:-- desc:收藏量
- * @return name:desc type:string default:-- desc:简介
- * @return name:switch_open type:int default:-- desc:通知开关【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.user_id buid,i.title,i.cover,i.is_vip,i.cover,i.ali_vid,i.video_id,i.duration,i.transmit_num,i.desc,x.title series_title')
- ->leftJoin('VideoUrl i','t.like_id = i.id')
- ->leftJoin('VideoIntro x','i.video_id = x.id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['url_id'],7);
- $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']);
- $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- });
- $total_num = VideoCommentLike::where($sel_where)->alias('t')
- ->leftJoin('VideoUrl i','t.like_id = i.id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 以下接口为二期需求
- * @desc 以下接口为二期需求
- * @author qc
- * @url /api/Video/secondPhase
- * @method
- * @return name:1 type:string default:-- desc:以下接口为二期需求
- */
- public function secondPhase(){}
- /**
- * @title ui我的发布-审核成功【后台视频绑定该会员】
- * @desc ui我的发布-审核成功
- * @author qc
- * @method GET
- * @url /api/Video/getBoundList
- * @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:id type:string default:-- desc:记录id【url_id】
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:video_id type:string default:-- desc:视频系列id
- * @return name:duration type:int default:-- desc:时长(单位:秒)
- * @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是]
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getBoundList()
- {
- $sel_where = [];
- $title = input('get.title');
- $sel_where[] = ['t.user_id','=',$this->user_id];
- $sel_where[] = ['t.is_deleted','=',0];
- if($title) $sel_where[] = ['t.title|t.label','like','%'.$title.'%'];
- $list = VideoUrl::where($sel_where)
- ->alias('t')
- ->field('t.id,t.title,t.cover,t.label,t.is_vip,t.ali_vid,t.video_id,t.duration,t.create_at,x.title series_title,t.read_num')
- ->leftJoin('VideoIntro x','x.id = t.video_id')
- ->order('id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['read_num'] = numTransform($v['read_num']);
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['id'],$this->request->controller());
- }
- $total_num = VideoUrl::where($sel_where)->alias('t')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 我的追番列表
- * @desc 我的追番列表
- * @author qc
- * @method GET
- * @url /api/Video/getFollowUpList
- * @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:create_at type:string default:-- desc:追更设置时间
- * @return name:video_id type:int default:-- desc:视频系列id
- * @return name:title type:string default:-- desc:标题
- * @return name:cover type:string default:-- desc:封面
- * @return name:total_sequel type:string default:-- desc:总期数
- * @return name:is_vip type:int default:-- desc:是否vip
- * @return name:is_over type:int default:-- desc:是否完结
- * @return name:recently_title type:int default:-- desc:上次观看title
- * @return name:recently_id type:int default:-- desc:上次观看记录id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getFollowUpList()
- {
- $sel_where = [];
- $sel_where[] = ['p.user_id','=',$this->user_id];
- $sel_where[] = ['p.type','=',2];
- $sel_where[] = ['p.switch_value','=',1];
- $title = input('title');
- if($title) $sel_where[] = ['a.title','like','%'.$title.'%'];
- $field = 'p.id,p.switch_id as video_id,p.create_at,a.title,a.total_sequel,a.is_vip,a.cover,a.is_over,a.status ,a.is_deleted';
- $list = PlatformSwitch::field($field)
- ->alias('p')
- ->leftJoin('VideoIntro a','p.switch_id = a.id')
- ->where($sel_where)
- ->limit($this->off_set,$this->page_num)
- ->order('p.id desc')
- ->select()->toArray();
- array_walk($list,function (&$v){
- $v['is_normal'] = $v['status'] == 1 && $v['is_deleted'] == 0 ? 1 : 0;
- $v['recently_title'] = UserTrack::getRecentlyTitle($this->user_id,1,$v['video_id']);
- $recently_id = UserTrack::getRecentlyTrack($this->user_id,1,$v['video_id']);
- $v['recently_id'] = $recently_id ? $recently_id: 0;
- });
- $total_num =PlatformSwitch::field($field)->alias('p')
- ->leftJoin('VideoIntro a','p.switch_id = a.id')
- ->where($sel_where)->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 评论点赞列表--我的点赞
- * @desc 评论点赞列表
- * @author qc
- * @method GET
- * @url /api/Video/getTagsComment
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @param name:page type:int default:0 desc:页数
- * @param name:page_num type:int default:20 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:content type:string default:-- desc:评论内容
- * @return name:cover type:string default:-- desc:封面
- * @return name:ali_vid type:string default:-- desc:云点播id
- * @return name:title type:string default:-- desc:标题
- * @return name:read_num type:string default:-- desc:播放量
- * @return name:app_name type:string default:-- desc:发布者
- * @return name:app_logo type:string default:-- desc:发布者头像
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- */
- public function getTagsComment()
- {
- $list = VideoCommentLike::field('l.*,i.read_num,c.content,c.url_id,i.read_num,i.title,i.cover,i.ali_vid,u.name user_name,u.headimg,i.duration,i.user_id buid,i.video_id,i.comment_switch,x.title series_title')
- ->alias('l')
- ->where(['l.user_id'=>$this->user_id,'l.type'=>1])
- ->leftJoin('VideoComment c','l.like_id = c.id')
- ->leftJoin('VideoUrl i','i.id = c.url_id')
- ->leftJoin('VideoIntro x','x.id = i.video_id')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v){
- $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
- $v['app_name'] = $video_auth['app_name'];
- $v['app_logo'] = $video_auth['app_logo'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- });
- $total_num =VideoCommentLike::where(['l.user_id'=>$this->user_id,'l.type'=>1])
- ->alias('l')
- ->leftJoin('VideoComment c','l.like_id = c.id')
- ->leftJoin('VideoUrl i','i.id = c.url_id')
- ->leftJoin('store_member u','u.id = c.user_id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 追番消息
- * @desc 追番消息
- * @author qc
- * @method GET
- * @url /api/Video/getFollowUpMessage
- * @header name:Authorization require:1 desc:Token
- * @param name:title type:int default:-- desc:搜索内容
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:content type:string default:-- desc:内容
- * @return name:create_at type:string default:-- desc:时间
- * @return name:is_read type:int default:-- desc:是否已读【0否1是】
- * @return name:video_title type:string default:-- desc:系列标题
- * @return name:video_id type:int default:-- desc:系列id
- * @return name:children_id type:int default:-- desc:详情id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- */
- public function getFollowUpMessage()
- {
- $title = input('title');
- $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'video','m.type_id'=>5])
- ->alias('m')
- ->when($title,function ($query)use ($title){
- if($title) $query->where('m.content','like','%'.$title.'%');})
- ->field('m.id,m.create_at,m.is_read,m.content,m.relation_id video_id,m.module,v.title video_title,m.children_id')
- ->leftJoin('VideoIntro v','v.id= m.relation_id')
- ->limit($this->off_set,$this->page_num)
- ->order(['m.id'=>'desc'])
- ->select()->toArray();
- foreach ($list as &$v) {
- $v['series_title'] =$v['video_title'];
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['children_id'],$this->request->controller());
- }
- $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'video','m.type_id'=>5])
- ->alias('m')
- ->leftJoin('VideoIntro v','v.id= m.relation_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 点赞我的--视频
- * @desc 点赞我的--视频
- * @author qc
- * @method GET
- * @url /api/Video/praiseMyVideoList
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:user_name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:cover type:string default:-- desc:封面
- * @return name:duration type:string default:-- desc:时长
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- *
- */
- public function praiseMyVideoList()
- {
- // 我的视频
- $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
- $user_info = $this->userInfo('name,headimg');
- $list = VideoCommentLike::where([['l.type','=',2],['l.like_id','in',$all_video],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->field('l.id,l.user_id,m.name user_name,m.headimg,l.like_id,l.create_at,v.cover,v.title,v.read_num,v.duration,v.desc,v.video_id,v.comment_switch,x.title series_title')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('VideoUrl v','v.id = l.like_id')
- ->leftJoin('VideoIntro x','x.id = v.video_id')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v,$k)use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['like_id'],$this->request->controller());
- $v['app_name'] = $user_info['name'] ;
- $v['app_logo'] = $user_info['headimg'];
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = VideoCommentLike::where([['type','=',2],['like_id','in',$all_video],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('VideoUrl v','v.id = l.like_id')
- ->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 点赞我的--评论
- * @desc 点赞我的--评论
- * @author qc
- * @method GET
- * @url /api/Video/praiseMyComment
- * @header name:Authorization require:1 desc:Token
- * @param name:page type:int default:-- desc:页数
- * @param name:page_num type:int default:-- desc:每页数
- *
- * @return name:id type:int default:-- desc:记录id
- * @return name:title type:string default:-- desc:标题
- * @return name:series_title type:string default:-- desc:系列标题
- * @return name:create_at type:string default:-- desc:时间
- * @return name:read_num type:int default:-- desc:播放量
- * @return name:user_name type:string default:-- desc:会员名称
- * @return name:headimg type:string default:-- desc:会员头像
- * @return name:cover type:string default:-- desc:封面
- * @return name:duration type:string default:-- desc:时长
- * @return name:content type:string default:-- desc:内容
- * @return name:like_id type:int default:-- desc:评论id
- * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
- * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
- */
- public function praiseMyComment()
- {
- $user_info = $this->userInfo('name,headimg');
- $list = VideoCommentLike::where([['l.type','=',1],['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l')
- ->field('l.id,l.like_id,l.user_id,m.name user_name,m.headimg,l.is_read,l.create_at,v.cover,c.url_id,v.title,v.read_num,v.duration,c.content,v.video_id,v.comment_switch,x.title series_title')
- ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('VideoComment c','c.id = l.like_id')
- ->leftJoin('VideoUrl v','v.id = c.url_id')
- ->leftJoin('VideoIntro x','x.id = v.video_id')
- ->order('l.id desc')
- ->limit($this->off_set,$this->page_num)
- ->select()->toArray();
- array_walk($list,function (&$v,$k)use ($user_info){
- $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
- $v['app_name'] = $user_info['name'] ;
- $v['app_logo'] = $user_info['headimg'];
- $v['read_num'] = numTransform($v['read_num']);
- });
- $total_num = VideoCommentLike::where([['l.type','=',1],['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
- ->alias('l') ->leftJoin('StoreMember m','m.id = l.user_id')
- ->leftJoin('VideoComment c','c.id = l.like_id')
- ->leftJoin('VideoUrl v','v.id = c.url_id')->count();
- $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
- }
- /**
- * @title 消息已读&&未读变更
- * @desc 支持批量选择
- * @author qc
- * @method POST
- * @url /api/Video/unreadChange
- * eadChange
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
- * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3追番消息,4点赞我的--视频,5点赞我的--评论】
- * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
- */
- public function unreadChange()
- {
- $type = input('post.type',1);
- $id = input('post.id');
- $where = [];
- switch ($type) {
- case 1:
- VideoComment::where([['i.user_id','=',$this->user_id],['t.pid','=',0]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->leftJoin('VideoUrl i','t.url_id = i.id')
- ->alias('t') ->update(['is_read'=>input('post.is_read')]);
- break;
- case 2:
- $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- VideoComment::where([['t.pid','in',implode(',',$all_comment)]])
- ->when($id ,function ($query)use ($id){
- if($id) return $query->where('t.id','in',$id);
- })->alias('t')->update(['is_read'=>input('post.is_read')]);
- break;
- case 3:
- $where[] = ['user_id','=',$this->user_id];
- if($id) $where[] = ['id','in',$id];
- UserMessage::where($where)->update(['is_read'=>input('post.is_read')]);
- break;
- case 4:
- $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
- VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video]])->update(['is_read'=>1]);
- break;
- case 5:
- $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
- VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$all_comment]])->update(['is_read'=>1]);
- break;
- }
- $this->success('消息变更成功');
- }
- /**
- * @title 批量删除||批量取消
- * @desc 删除||取消
- * @author qc
- * @method POST
- * @url /api/Video/batchesDel
- * @header name:Authorization require:1 desc:Token
- * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
- * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,3我的回复,4我的已购,5用户视频删除,6追番记录,7追番消息,8我的点赞-视频,9我的点赞-评论,10回复我的,11点赞我的--视频,12点赞我的--评论,13我的收藏】
- */
- public function batchesDel(){
- $type = input('post.type',1);
- $del_where = [];
- $del_where[] = ['id','in',input('post.id')];
- if(in_array($type,[1,3,4,5,6,7,8,9])) $del_where[] = ['user_id','=',$this->user_id];
- if(in_array($type,[1,3])) VideoComment::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[2])) VideoComment::where($del_where)->update(['source_deleted'=>1,'source_read'=>1,'is_read'=>1]);
- if(in_array($type,[10])) VideoComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[4])) UserLearn::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[5])) UserVideo::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[6])) PlatformSwitch::where($del_where)->delete();
- if(in_array($type,[7])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
- if(in_array($type,[8,9])) VideoCommentLike::where($del_where)->delete();
- if(in_array($type,[11,12])) VideoCommentLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
- if(in_array($type,[13])) UserCollect::where($del_where)->delete();
- $this->success('操作成功');
- }
- }
|