Video.php 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043
  1. <?php
  2. namespace app\api\controller;
  3. use AlibabaCloud\SDK\Vod\V20170321\Models\GetMediaDNAResultResponseBody\DNAResult\videoDNA\detail\input;
  4. use app\common\model\ArticleItem;
  5. use app\common\model\DatumUrl;
  6. use app\common\model\PlatformSwitch;
  7. use app\common\model\SeriesVideoCate;
  8. use app\common\model\TopSearch;
  9. use app\common\model\User;
  10. use app\common\model\UserCollect;
  11. use app\common\model\UserLearn;
  12. use app\common\model\UserLevel;
  13. use app\common\model\UserLevelRank;
  14. use app\common\model\UserMessage;
  15. use app\common\model\UserSearch;
  16. use app\common\model\UserTrack;
  17. use app\common\model\UserVideo;
  18. use app\common\model\VideoCate;
  19. use app\common\model\VideoComment;
  20. use app\common\model\VideoCommentLike;
  21. use app\common\model\VideoIntro;
  22. use app\common\model\VideoLabel;
  23. use app\common\model\VideoUrl;
  24. use app\common\service\CheckPower;
  25. use app\common\service\UserSynth;
  26. use library\tools\Data;
  27. use think\Db;
  28. /**
  29. * @title 视频
  30. * @controller Video
  31. * @group base
  32. */
  33. class Video extends Base
  34. {
  35. // 需要登录的
  36. protected $need_login = [
  37. 'getMyVideoList',
  38. 'userReferVideoDetail',
  39. 'userReferVideo',
  40. 'delUserVideo',
  41. 'videoComment',
  42. 'secondCommend',
  43. 'delComment',
  44. 'videoTags',
  45. 'videoTransmit',
  46. 'videoPlay',
  47. 'getLearnHistory',
  48. 'getReplayComment',
  49. 'getCommentVideo',
  50. 'commentMyVideo',
  51. 'getReplyVideo',
  52. 'getPurchaseVideo',
  53. 'getVideoCollect',
  54. 'getTagsVideo',
  55. 'videoCollect',
  56. 'batchesDel',
  57. 'getBoundList',
  58. 'getFollowUpList',
  59. 'getTagsComment',
  60. 'getFollowUpMessage',
  61. 'praiseMyVideoList',
  62. 'praiseMyComment',
  63. 'unreadChange',
  64. 'getMarkNum',
  65. 'getUserVideoDetail', //1.5新增
  66. 'getVideoDetail', //1.5新增
  67. ];
  68. public function initialize()
  69. {
  70. parent::initialize();
  71. parent::setUid();
  72. $this->source_type= $this->request->header('source-type',1);
  73. }
  74. /**
  75. * @title 视频接口说明
  76. * @desc 视频接口说明
  77. * @author qc
  78. * @url /api/Video/classIntro
  79. * @method GET
  80. * @return name:1 type:string default:-- desc:视频播放改DRM加密,请勿用视频地址【url】播放,这个字段弃用!!
  81. * @return name:2 type:string default:-- desc:ali_vid视频点播id,阿里云视频点播用
  82. */
  83. public function classIntro(){}
  84. /**
  85. * @title 获取分类
  86. * @desc 获取分类(共两级)
  87. * @author qc
  88. * @url /api/Video/getCateTree
  89. * @method GET
  90. * @header name:Authorization require:1 desc:Token
  91. * @param name:type type:int default:2 desc:类型2系列
  92. * @return name:id type:int default:-- desc:分类id
  93. * @return name:logo type:string default:-- desc:图标
  94. * @return name:title type:string default:0 desc:分类名称
  95. * @return name:children type:array default:0 desc:下级分类
  96. */
  97. public function getCateTree()
  98. {
  99. $type = input('type',2);
  100. if($type == 1) {
  101. $list = VideoCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc ')->select()->toArray();
  102. }else{
  103. $list = SeriesVideoCate::where(['is_deleted'=>0,'status'=>1])->field('id,logo,title,pid')->order('sort desc,id asc')->select()->toArray();
  104. }
  105. $list = make_tree($list);
  106. $this->success('ok',['list'=>$list]);
  107. }
  108. /**
  109. * @title 获取视频标签
  110. * @desc 获取视频标签
  111. * @author qc
  112. * @url /api/Video/getVideoLabel
  113. * @method GET
  114. * @header name:Authorization require:1 desc:Token
  115. * @return name:id type:int default:-- desc:id
  116. * @return name:title type:string default:0 desc:标题
  117. */
  118. public function getVideoLabel()
  119. {
  120. $list = VideoLabel::field('id,title')->where(['is_deleted'=>0,'status'=>1])->select()->toArray();
  121. $this->success('',['list'=>$list]);
  122. }
  123. /**
  124. * @title 视频推荐
  125. * @desc 视频推荐
  126. * @author qc
  127. * @method GET
  128. * @url /api/Video/getRecommendList
  129. * @header name:Authorization require:1 desc:Token
  130. * @param name:page type:int default:0 desc:页数
  131. * @param name:page_num type:int default:20 desc:每页数
  132. * @param name:rand_user type:string default:-- desc:随机id(非登录状态必传,page=1时生成(a123),其他页数(a123),一直查询到没有数据)
  133. * @return name:id type:string default:-- desc:视频url_id
  134. * @return name:title type:string default:-- desc:标题
  135. * @return name:video_id type:string default:-- desc:系列id
  136. * @return name:cover type:string default:-- desc:封面
  137. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  138. * @return name:app_name type:string default:-- desc:发布者
  139. * @return name:app_logo type:string default:-- desc:发布者头像
  140. * @return name:read_num type:string default:-- desc:阅读量
  141. * @return name:duration type:int default:-- desc:时长(单位:秒)
  142. * @return name:cover_type type:int default:-- desc:1显示大图0显示小图【page_num必须是7的倍数(其他页数忽略这个参数),建议21,】
  143. * @return name:release_time type:string default:-- desc:上架时间
  144. */
  145. public function getRecommendList()
  146. {
  147. $user_id = $this->user_id ? $this->user_id : input('rand_user');
  148. if(!$user_id) $this->error('参数错误');
  149. $list = UserSynth::getRecommendList($user_id,'video',$this->page,$this->page_num,[],input('sort_type',1));
  150. if($list['code'] != 200) $this->error($list['msg']);
  151. $this->success('ok',$list);
  152. $app_name = sysconf('app_name');
  153. $app_logo = sysconf('app_logo');
  154. $search_log = UserSearch::getSearchTitle($this->user_id,1);
  155. $search_arr = [];
  156. $where_str = 'b.id > 0';
  157. foreach ($search_log as $t){
  158. $search_arr[] = " b.title like '".'%'.$t."%'" .' ';
  159. $search_arr[] = " b.label like '".'%'.$t."%'" .' ';
  160. }
  161. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  162. $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 ';
  163. $table = 'dd_video_url';
  164. $order_by_two = 'a.read_num';
  165. $time_str = date("Y-m-d H:i:s");
  166. $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}";
  167. // var_dump($sql);
  168. $list = Db::query($sql);
  169. $list = dispose_recommend($list);
  170. $seven = [0,7,14,21,28,];
  171. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  172. $v['cover_type'] = $k%7 ? 0 : 1;
  173. $v['create_at'] = substr($v['create_at'],0,10);
  174. if(!$v['user_id']){
  175. $v['app_name'] = $app_name;
  176. $v['app_logo'] = $app_logo;
  177. }else{
  178. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  179. $v['app_name'] = $user_info ? $user_info->name : '';
  180. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  181. }
  182. });
  183. $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";
  184. $total = Db::query($sql2);
  185. $this->success('ok',['list'=>$list,'total_count'=>$total[0]['num'],'page_num'=>$this->page_num]);
  186. }
  187. /**
  188. * @title 获取视频列表(平台发布)
  189. * @desc 获取视频列表
  190. * @author qc
  191. * @method GET
  192. * @url /api/Video/getVideoList
  193. * @header name:Authorization require:1 desc:Token
  194. * @param name:title type:string default:-- desc:标题
  195. * @param name:first_classify type:int default:0 desc:视频一级分类
  196. * @param name:second_classify type:int default:0 desc:视频二级分类
  197. * @param name:page type:int default:0 desc:页数
  198. * @param name:page_num type:int default:20 desc:每页数
  199. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  200. * @return name:id type:string default:-- desc:ID[请求/api/Video/getVideoDetail用]
  201. * @return name:title type:string default:-- desc:标题
  202. * @return name:cover type:string default:-- desc:封面
  203. * @return name:video_url type:string default:-- desc:视频地址
  204. * @return name:first_classify type:int default:-- desc:视频一级分类
  205. * @return name:second_classify type:int default:-- desc:视频二级分类
  206. * @return name:is_top type:int default:-- desc:是否置顶(0否,1是)
  207. * @return name:is_vip type:int default:-- desc:是否是vip(0否,1是)
  208. * @return name:is_over type:int default:-- desc:是否完结(0否,1是)
  209. * @return name:label_name type:array default:-- desc:标签
  210. * @return name:read_num type:int default:-- desc:播放量
  211. * @return name:total_num type:int default:-- desc:总数量
  212. * @return name:is_collect type:int default:-- desc:是否收藏
  213. * @return name:app_name type:string default:-- desc:发布者
  214. * @return name:app_logo type:string default:-- desc:发布者头像
  215. * @return name:video_arr type:array default:-- desc:视频地址
  216. * @return name:video_arr.url type:string default:-- desc:视频地址
  217. * @return name:video_arr.duration type:int default:-- desc:时长(单位:秒)
  218. */
  219. public function getVideoList()
  220. {
  221. $sel_where = [];
  222. $sel_where[] = ['is_deleted','=',0];
  223. $sel_where[] = ['status','=',1];
  224. $sel_where[] = ['url_num','>=',1];
  225. $title = input('get.title');
  226. $type = input('get.type',2);
  227. $is_hot = input('get.is_hot',-1);
  228. $first_classify = input('get.first_classify');
  229. $second_classify = input('get.second_classify');
  230. $sort_type = input('get.sort_type',1);
  231. $app_name = sysconf('app_name');
  232. $app_logo = sysconf('app_logo');
  233. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1);
  234. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  235. if($first_classify) $sel_where[] = ['first_classify','=',$first_classify];
  236. if($second_classify) $sel_where[] = ['second_classify','=',$second_classify];
  237. if($type) $sel_where[] = ['type','=',$type];
  238. if($is_hot >= 0) $sel_where[] = ['is_hot','=',$is_hot];
  239. $where_str = 'id > 0';
  240. switch ($sort_type) {
  241. case 1:
  242. $order = ['sort'=>'asc','id'=>'asc'];
  243. break;
  244. case 2:
  245. $order = ['sort'=>'asc','id'=>'desc'];
  246. break;
  247. case 3:
  248. $order = ['sort'=>'desc','id'=>'desc'];
  249. break;
  250. }
  251. $total_num =VideoIntro::where($sel_where)->where($where_str)->count();
  252. $list = VideoIntro::with(['videoArr'])->where($sel_where)
  253. ->where($where_str)
  254. ->order($order)
  255. ->limit($this->off_set,$this->page_num)->select()->toArray();
  256. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  257. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['id']);
  258. $v['label_name'] = $v['label']? explode(',',trim($v['label'],',')) : null;
  259. $v['read_num'] = array_sum(array_column($v['video_arr'],'read_num'));
  260. $v['app_name'] = $app_name;
  261. $v['app_logo'] = $app_logo;
  262. });
  263. foreach ($list as &$value){
  264. $recently_info = UserTrack::getRecentlyTrack($this->user_id,1,$value['id'],1);
  265. $recently_id = !empty($recently_info) ? $recently_info['second_id'] : false;
  266. foreach ($value['video_arr'] as &$v){
  267. $v['is_recently'] = $v['id'] == $recently_id ? 1 : 0;
  268. }
  269. $value['cate'] = SeriesVideoCate::where('id',$value['second_classify'])->value('title');
  270. }
  271. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  272. }
  273. /**
  274. * @title 获取系列列表
  275. * @desc 获取系列列表
  276. * @author qc
  277. * @method GET
  278. * @url /api/Video/getSeriesList
  279. * @header name:Authorization require:1 desc:Token
  280. * @param name:first_classify type:int default:0 desc:一级分类
  281. * @param name:second_classify type:int default:0 desc:二级分类
  282. * @return name:second_classify type:int default:-- desc:二级分类
  283. * @return name:title type:int default:-- desc:二级分类名称
  284. * @return name:series_list type:array default:-- desc:系列列表
  285. * @return name:series_list.id type:string default:-- desc:系列id
  286. * @return name:series_list.title type:string default:-- desc:标题
  287. * @return name:series_list.cover type:string default:-- desc:封面
  288. * @return name:series_list.is_vip type:int default:-- desc:是否是vip(0否,1是)
  289. * @return name:series_list.is_over type:int default:-- desc:是否完结(0否,1是)
  290. */
  291. public function getSeriesList()
  292. {
  293. $type = input('get.type',2);
  294. $first_classify = input('get.first_classify');
  295. $second_classify = input('get.second_classify');
  296. $list = SeriesVideoCate::where(['is_deleted'=>0,'status'=>1])
  297. ->field('id second_classify,title')->where('pid',$first_classify)
  298. ->when($second_classify,function ($query)use ($second_classify){if($second_classify){$query->where('id',$second_classify);}})
  299. ->order('sort desc,id asc')->select()->toArray();
  300. foreach ($list as &$v) {
  301. $v['series_list'] = VideoIntro::field('id,title,cover,is_vip,is_over')
  302. ->where('second_classify',$v['second_classify'])
  303. ->where('status',1)
  304. ->where('is_deleted',0)
  305. ->where('url_num','>',0)
  306. ->where('type',$type)->limit($this->off_set,100)
  307. ->order('sort desc,id desc')->select()->toArray();
  308. }
  309. $this->success('ok',['list'=>$list]);
  310. }
  311. /**
  312. * @title 获取推荐视频列表【不分页】【弃用】
  313. * @desc 获取推荐视频列表【不分页】
  314. * @author qc
  315. * @method GET
  316. * @url /api/Video/getRecommendVideoList
  317. * @header name:Authorization require:1 desc:Token
  318. * @return name:id type:string default:-- desc:id
  319. * @return name:title type:string default:-- desc:标题
  320. * @return name:cover type:string default:-- desc:预览图
  321. * @return name:transmit_num type:int default:-- desc:转发量
  322. * @return name:read_num type:int default:-- desc:播放量
  323. * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是)
  324. * @return name:ppt type:string default:-- desc:关联ppt链接
  325. * @return name:pdf_clear type:string default:-- desc:pdf未加密链接
  326. * @return name:ali_vid type:string default:-- desc:阿里云点播id
  327. * @return name:app_name type:string default:-- desc:发布者
  328. * @return name:app_logo type:string default:-- desc:发布者头像
  329. */
  330. public function getRecommendVideoList()
  331. {
  332. $app_name = sysconf('app_name');
  333. $app_logo = sysconf('app_logo');
  334. $where_str = 'id > 0';
  335. $sel_where = [];
  336. $sel_where[] = ['is_deleted','=',0];
  337. $sel_where[] = ['status','=',1];
  338. $search_log = UserSearch::getSearchTitle($this->user_id,1);
  339. $search_arr = [];
  340. foreach ($search_log as $t){
  341. $search_arr[] = " title like '".'%'.$t."%'" .' ';
  342. }
  343. if(!empty($search_arr)) $where_str = implode(' OR ',$search_arr);
  344. $list = VideoUrl::field('id,video_id,title,cover,ali_vid,ppt,pdf_clear,is_vip,read_num')
  345. ->where($where_str)->where($sel_where)->order('id desc')->limit(0,20)->select()->toArray();
  346. $rand_num = 0;
  347. if(count($list) < 20)$rand_num = 20 - count($list);
  348. if($rand_num > 0) {
  349. $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){
  350. if(!empty($search_ids)){
  351. $search_ids = array_column($list,'id');
  352. $all_ids = VideoUrl::where(['is_deleted'=>0])->where('id not in '.implode(',',$search_ids))->column('id,title','id');
  353. $rand_ids = array_keys($all_ids);
  354. if(count($all_ids) > $rand_num) $rand_ids = array_rand($all_ids,$rand_num);
  355. return $query->where('id','in',implode(',',$rand_ids));
  356. }
  357. })->where($sel_where)->limit(0,$rand_num)->select()->toArray();
  358. if(!empty($rand_list)) $list = array_merge($list,$rand_list);
  359. }
  360. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  361. $v['app_name'] = $app_name;
  362. $v['app_logo'] = $app_logo;
  363. });
  364. $this->success('ok',$list);
  365. }
  366. /**
  367. * @title 视频搜索
  368. * @desc 视频搜索
  369. * @author qc
  370. * @method GET
  371. * @url /api/Video/videoSearch
  372. * @header name:Authorization require:1 desc:Token
  373. * @param name:title type:string default:1 desc:标题
  374. * @param name:sort_type type:int default:1 desc:1默认2时间升序3时间降序
  375. * @param name:page type:int default:0 desc:页数
  376. * @param name:page_num type:int default:20 desc:每页数
  377. * @return name:title type:string default:-- desc:标题
  378. * @return name:cover type:string default:-- desc:预览图
  379. * @return name:transmit_num type:int default:-- desc:转发量
  380. * @return name:read_num type:int default:-- desc:播放量
  381. * @return name:label_name type:array default:-- desc:标签
  382. * @return name:is_vip type:int default:-- desc:是否是需要会员(0否1是)
  383. * @return name:ali_vid type:string default:-- desc:阿里云点播id
  384. * @return name:app_name type:string default:-- desc:发布者
  385. * @return name:app_logo type:string default:-- desc:发布者头像
  386. * @return name:duration type:int default:-- desc:时长(单位:秒)
  387. * @return name:create_at type:int default:-- desc:时间
  388. */
  389. public function videoSearch()
  390. {
  391. $title = input('get.title');
  392. $sort_type = input('get.sort_type',1);
  393. if($title && $this->user_id) UserSearch::saveSearchTitle($this->user_id,$title,1);
  394. $sel_where = [];
  395. $sel_where[] = ['a.is_deleted','=',0];
  396. $sel_where[] = ['a.status','=',1];
  397. $sel_where[] = ['b.is_deleted','=',0];
  398. $sel_where[] = ['b.status','=',1];
  399. $sel_where[] = ['a.release_time','< time',date("Y-m-d H:i:s")];
  400. if($title) $sel_where[] = ['a.title|a.label','like','%'.$title.'%'];
  401. $app_name = sysconf('app_name');
  402. $app_logo = sysconf('app_logo');
  403. switch ($sort_type) {
  404. case 1:
  405. $order = ['a.read_num'=>'desc'];
  406. break;
  407. case 2:
  408. $order = ['a.id'=>'asc','a.sort'=>'desc'];
  409. break;
  410. case 3:
  411. $order = ['a.id'=>'desc','a.sort'=>'desc'];
  412. break;
  413. }
  414. $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')
  415. ->alias('a')
  416. ->leftJoin('VideoIntro b','a.video_id = b.id')
  417. ->where($sel_where)->order($order)
  418. ->limit($this->off_set,$this->page_num)->select()->toArray();
  419. array_walk($list,function (&$v,$k)use ($app_name,$app_logo){
  420. $v['label_name'] = $v['label'] ? explode(',',trim($v['label'],',')) : null;
  421. if(!$v['user_id']){
  422. $v['app_name'] = $app_name;
  423. $v['app_logo'] = $app_logo;
  424. }else{
  425. $user_info = User::where('id',$v['user_id'])->field('name,headimg')->find();
  426. $v['app_name'] = $user_info ? $user_info->name : '';
  427. $v['app_logo'] = $user_info ? $user_info->headimg : '';
  428. }
  429. $v['read_num'] = numTransform($v['read_num']);
  430. });
  431. $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')
  432. ->alias('a')
  433. ->leftJoin('VideoIntro b','a.video_id = b.id')
  434. ->where($sel_where)->count();
  435. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  436. }
  437. /**
  438. * @title 获取视频详情[系列选集列表](平台)
  439. * @desc 获取视频详情
  440. * @author qc
  441. * @method GET
  442. * @url /api/Video/getVideoDetail
  443. * @header name:Authorization require:1 desc:Token
  444. * @param name:id type:int default:0 desc:视频id
  445. * @return name:title type:string default:-- desc:标题
  446. * @return name:cover type:string default:-- desc:封面
  447. * @return name:video_url type:string default:-- desc:视频地址
  448. * @return name:first_classify type:int default:-- desc:视频一级分类
  449. * @return name:is_top type:int default:-- desc:是否置顶(0否,1是)
  450. * @return name:read_num type:int default:-- desc:播放量
  451. * @return name:is_release type:int default:-- desc:是否释放【0否1是】,已释放不需要购买vip
  452. * @return name:follow_switch type:int default:-- desc:追番开关状态【0关闭1开启】
  453. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  454. * @return name:total_sequel type:int default:-- desc:共多少期【期数】(默认1)
  455. * @return name:is_over type:int default:-- desc:是否完结
  456. * @return name:user_level type:int default:-- desc:会员等级id
  457. * @return name:video_arr type:array default:-- desc:视频地址[选集列表]
  458. * @return name:video_arr.id type:int default:-- desc:ID[请求视频模块其他接口参数:url_id]
  459. * @return name:video_arr.cover type:string default:-- desc:预览图
  460. * @return name:video_arr.url type:string default:-- desc:视频地址
  461. * @return name:video_arr.transmit_num type:int default:-- desc:转发量
  462. * @return name:video_arr.read_num type:int default:-- desc:播放量
  463. * @return name:video_arr.is_vip type:int default:-- desc:是否是需要会员(0否1是)
  464. * @return name:video_arr.is_collect type:int default:-- desc:是否收藏
  465. * @return name:video_arr.collect_num type:int default:-- desc:收藏量
  466. * @return name:video_arr.praise_num type:int default:-- desc:点赞量
  467. * @return name:video_arr.is_praise type:int default:-- desc:是否点赞
  468. * @return name:video_arr.article_id type:int default:-- desc:关联图文id【系列id】
  469. * @return name:video_arr.article_item type:int default:-- desc:图文详情资料【系列下的其中一个】
  470. * @return name:video_arr.datum_id type:int default:-- desc:资料id【系列id】
  471. * @return name:video_arr.datum_item type:int default:-- desc:资料id【系列下的其中一个】
  472. *
  473. * @return name:video_arr.article_jump type:int default:-- desc:关联图文是否能跳转【0不能跳转,1能跳转,验证是否vip】
  474. * @return name:video_arr.datum_jump type:int default:-- desc:关联资料是否能跳转【0不能跳转,1能跳转,验证是否vip】
  475. *
  476. * @return name:video_arr.ppt type:string default:-- desc:关联ppt链接
  477. * @return name:video_arr.pdf_clear type:string default:-- desc:pdf未加密链接
  478. * @return name:video_arr.goods_id type:int default:-- desc:供应商商品id
  479. * @return name:video_arr.ali_vid type:string default:-- desc:阿里云点播id
  480. * @return name:video_arr.duration type:int default:-- desc:时长(单位:秒)
  481. * @return name:video_arr.is_recently type:int default:-- desc:是否最近观看【0否1是】
  482. * @return name:video_arr.track_time type:string default:-- desc:上次观看时间
  483. * @return name:video_arr.app_name type:string default:-- desc:发布者
  484. * @return name:video_arr.app_logo type:string default:-- desc:发布者头像
  485. * @return name:video_arr.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  486. * @return name:video_arr.mp4_url type:string default:-- desc:mp4路径
  487. * @return name:video_arr.release_time type:string default:-- desc:上架时间
  488. */
  489. public function getVideoDetail()
  490. {
  491. $sel_where = [];
  492. $url_id = input('get.url_id');
  493. $sel_where[] = ['id','=',input('get.id')];
  494. $is_release = UserLearn::checkRelease($this->user_id,1,input('get.id'));
  495. $detail = VideoIntro::with(['videoArr2'=>function($query)use($is_release){
  496. if(!$is_release) return $query->where('status','=',1);
  497. }])->where($sel_where)->find();
  498. if(!$detail){
  499. $this->error('视频不存在',['detail'=>$detail]);
  500. }
  501. $detail = $detail->toArray();
  502. $detail['video_arr'] = $detail['video_arr2'];
  503. unset($detail['video_arr2']);
  504. $detail['is_release'] = $is_release;
  505. if($is_release && $detail['is_deleted'] )$this->error('该视频已下线');
  506. if(!$is_release && ($detail['is_deleted'] == 1 || $detail['status'] == 0))$this->error('该视频已下线');
  507. $detail['follow_switch'] = PlatformSwitch::checkSwitch($this->user_id,$detail['id'],2);
  508. $detail['label_name'] = [];
  509. if($detail['label']) {
  510. $detail['label_name'] = explode(',',trim($detail['label'],','));
  511. }
  512. $level_id = UserLevelRank::getUserVip($this->user_id);
  513. $detail['read_num'] = array_sum(array_column($detail['video_arr'],'read_num'));
  514. $detail['user_level'] = $level_id;
  515. $recently_info = UserTrack::getRecentlyTrack($this->user_id,1,$detail['id'],1);
  516. $recently_id = !empty($recently_info) ? $recently_info['second_id'] : false;
  517. foreach ($detail['video_arr'] as &$dv) {
  518. if($dv['is_vip'] && !$level_id) $dv['url'] = '';
  519. $dv['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$dv['id'],7);
  520. $dv['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$detail['id'],$dv['id']);
  521. // $dv['collect_num'] = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>1,'coll_id'=>$detail['id'],'children_id'=>$dv['id']])->count();
  522. $dv['collect_num'] = UserCollect::getCollectNum(1,$detail['id'],$dv['id']);
  523. $dv['is_praise'] = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$dv['id']])->count();
  524. $dv['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$dv['id']])->count();
  525. $dv['praise_num'] = numTransform($dv['praise_num']);
  526. $dv['read_num'] = numTransform($dv['read_num']);
  527. $dv['transmit_num'] = numTransform($dv['transmit_num']);
  528. $dv['is_recently'] = $dv['id'] == $recently_id ? 1 : 0;
  529. $dv['track_time'] = $dv['is_recently'] ? $recently_info['track_time'] : "0" ;
  530. $video_auth = VideoUrl::getVideoAuth($dv['user_id'],APPNAME,APPLOGO);
  531. $dv['app_name'] = $video_auth['app_name'];
  532. $dv['app_logo'] = $video_auth['app_logo'];
  533. $dv['article_jump'] = ArticleItem::checkVip($dv['article_item'],$this->user_id);
  534. $dv['datum_jump'] = DatumUrl::checkVip($dv['datum_item'],$this->user_id);
  535. $dv['mp4_url'] = VideoUrl::getMp4Url($dv['ali_vid']);
  536. }
  537. // if($this->user_id){
  538. // TopSearch::seIncHotNum(input('get.id'),$this->request->controller());
  539. // }
  540. if($this->user_id){
  541. $General = new General();
  542. $General->label($detail['label']);
  543. }
  544. $this->success('ok',['detail'=>$detail]);
  545. }
  546. /**
  547. * @title 视频增加热搜量
  548. * @desc 视频增加热搜量
  549. * @author qc
  550. * @method POST
  551. * @url /api/Video/addTopSearch
  552. * @header name:Authorization require:1 desc:Token
  553. * @param name:url_id type:int default:-- desc:视频id
  554. */
  555. public function addTopSearch(){
  556. $url_id = input('url_id');
  557. if(!$url_id){
  558. $this->error('参数错误');
  559. }
  560. TopSearch::seIncHotNum($url_id,$this->request->controller());
  561. $this->success('操作成功');
  562. }
  563. /**
  564. * @title 获取视频列表(用户发布【审核通过的】)
  565. * @desc 用户发布【审核通过的】
  566. * @author qc
  567. * @method GET
  568. * @url /api/Video/getUserVideoList
  569. * @header name:Authorization require:1 desc:Token
  570. * @param name:title type:string default:-- desc:标题
  571. * @param name:first_classify type:int default:0 desc:视频一级分类
  572. * @param name:second_classify type:int default:0 desc:视频二级分类
  573. * @param name:page type:int default:0 desc:页数
  574. * @param name:page_num type:int default:20 desc:每页数
  575. * @return name:title type:string default:-- desc:标题
  576. * @return name:cover type:string default:-- desc:封面
  577. * @return name:video_url type:string default:-- desc:视频地址
  578. * @return name:first_classify type:int default:-- desc:视频一级分类
  579. * @return name:second_classify type:int default:-- desc:视频二级分类
  580. * @return name:read_num type:int default:-- desc:播放量
  581. * @return name:is_collect type:int default:-- desc:是否收藏
  582. */
  583. public function getUserVideoList()
  584. {
  585. $sel_where = [];
  586. $sel_where[] = ['is_deleted','=',0];
  587. $sel_where[] = ['status','=',1];
  588. $title = input('get.title');
  589. $first_classify = input('get.first_classify');
  590. $second_classify = input('get.second_classify');
  591. if($title) $sel_where[] = ['v.title|v.label','like','%'.$title.'%'];
  592. if($first_classify) $sel_where[] = ['v.first_classify','=',$first_classify];
  593. if($second_classify) $sel_where[] = ['v.second_classify','=',$second_classify];
  594. $list = UserVideo::field('v.*')->where($sel_where)->order('v.id asc')
  595. ->alias('v')
  596. ->leftJoin('User u','u.id = v.user_id')
  597. ->limit($this->off_set,$this->page_num)
  598. ->select()->toArray();
  599. $total_num = UserVideo::where($sel_where)->order('v.id asc')->alias('v')->leftJoin('User u','u.id = v.user_id')->count();
  600. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  601. }
  602. /**
  603. * @title ui我的发布--其他【获取我的视频列表【个人发布的】
  604. * @desc 获取我的视频列表
  605. * @author qc
  606. * @method GET
  607. * @url /api/Video/getMyVideoList
  608. * @header name:Authorization require:1 desc:Token
  609. * @param name:title type:string default:-- desc:标题
  610. * @param name:page type:int default:0 desc:页数
  611. * @param name:page_num type:int default:20 desc:每页数
  612. * @return name:title type:string default:-- desc:标题
  613. * @return name:cover type:string default:-- desc:封面
  614. * @return name:video_url type:string default:-- desc:视频地址
  615. * @return name:first_classify type:int default:-- desc:视频一级分类
  616. * @return name:second_classify type:int default:-- desc:视频二级分类
  617. * @return name:read_num type:int default:-- desc:播放量
  618. * @return name:is_collect type:int default:-- desc:是否收藏
  619. * @return name:status type:int default:-- desc:0待审核1审核通过2审核未通过
  620. */
  621. public function getMyVideoList()
  622. {
  623. $sel_where = [];
  624. $sel_where[] = ['is_deleted','=',0];
  625. $sel_where[] = ['user_id','=',$this->user_id];
  626. $title = input('get.title');
  627. if($title) $sel_where[] = ['title|label','like','%'.$title.'%'];
  628. $list = UserVideo::where($sel_where)->order('id asc')
  629. ->limit($this->off_set,$this->page_num)
  630. ->select()->toArray();
  631. $total_num = UserVideo::where($sel_where)->count();
  632. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  633. }
  634. /**
  635. * @title 获取视频详情(会员)
  636. * @desc 获取视频详情
  637. * @author qc
  638. * @method GET
  639. * @url /api/Video/getUserVideoDetail
  640. * @header name:Authorization require:1 desc:Token
  641. * @param name:id type:int default:0 desc:视频id
  642. * @param name:first_classify type:int default:0 desc:视频一级分类
  643. * @param name:second_classify type:int default:0 desc:视频二级分类
  644. * @param name:page type:int default:0 desc:页数
  645. * @param name:page_num type:int default:20 desc:每页数
  646. * @return name:title type:string default:-- desc:标题
  647. * @return name:cover type:string default:-- desc:封面
  648. * @return name:video_url type:string default:-- desc:视频地址
  649. * @return name:first_classify type:int default:-- desc:视频一级分类
  650. * @return name:second_classify type:int default:-- desc:视频二级分类
  651. * @return name:read_num type:int default:-- desc:播放量
  652. * @return name:is_collect type:int default:-- desc:是否收藏
  653. * @return name:collect_num type:int default:-- desc:收藏量
  654. * @return name:praise_num type:int default:-- desc:点赞量
  655. * @return name:is_praise type:int default:-- desc:是否点赞
  656. * @return name:transmit_num type:int default:-- desc:转发量
  657. */
  658. public function getUserVideoDetail()
  659. {
  660. $detail = UserVideo::where('id',input('get.id'))->find();
  661. if(!$detail)$this->error('该视频已下线');
  662. if($detail->status != 1)$this->error('该视频未通过审核');
  663. $detail->is_collect = 0;
  664. $detail->collect_num = 0;
  665. $detail->is_praise =0;
  666. $detail->praise_num = 0;
  667. $this->success('ok',['detail'=>$detail->toArray()]);
  668. }
  669. /**
  670. * @title 用户提交或修改视频
  671. * @desc 用户提交或修改视频
  672. * @author qc
  673. * @method POST
  674. * @url /api/Video/userReferVideo
  675. * @header name:Authorization require:1 desc:Token
  676. * @param name:id type:int default:-- desc:id(修改时必传)
  677. * @param name:title type:string default:-- desc:标题
  678. * @param name:desc type:string default:-- desc:描述
  679. * @param name:video_url type:string default:-- desc:视频地址
  680. * @param name:label type:string default:-- desc:视频标签(多个用逗号隔开)
  681. */
  682. public function userReferVideo()
  683. {
  684. $id = input('post.id',0);
  685. $title = input('post.title');
  686. $desc = input('post.desc');
  687. $video_url = input('post.video_url');
  688. $cover = $video_url.'?x-oss-process=video/snapshot,t_2000,m_fast';
  689. $first_classify = input('post.first_classify',0);
  690. $second_classify = input('post.second_classify',0);
  691. $label = input('post.label');
  692. if(!$video_url) $this->error('请上传视频');
  693. if($id){
  694. $check_status = UserVideo::where('id',$id)->value('status');
  695. if($check_status == 1) $this->error('视频已审核通过,不允许修改');
  696. }
  697. $data = [
  698. 'title' => $title,
  699. 'cover' => $cover,
  700. 'user_id' => $this->user_id,
  701. 'desc' => $desc,
  702. 'first_classify' => $first_classify,
  703. 'second_classify' => $second_classify,
  704. 'video_url' => $video_url,
  705. 'label' => $label,
  706. 'status' => 0,
  707. 'remark' => '',
  708. ];
  709. if($id) $data['id'] = $id;
  710. if($id){
  711. UserVideo::where('id',$id)->update($data);
  712. }else{
  713. $res= UserVideo::create($data) ;
  714. }
  715. // UserMessage::sendUserMessage($this->user_id,'video',1,0,0,$id ? $id:$res->id);
  716. $this->success('提交成功,请等待审核',['id'=> $id ? :$res->id]);
  717. }
  718. /**
  719. * @title 获取用户提交视频详情
  720. * @desc 获取用户提交视频详情
  721. * @author qc
  722. * @method GET
  723. * @url /api/Video/userReferVideoDetail
  724. * @header name:Authorization require:1 desc:Token
  725. * @param name:id type:int default:-- desc:id
  726. * @return name:title type:string default:-- desc:标题
  727. * @return name:cover type:string default:-- desc:封面
  728. * @return name:desc type:string default:-- desc:简介
  729. * @return name:video_url type:string default:-- desc:视频地址
  730. * @return name:first_classify type:int default:-- desc:视频一级分类id
  731. * @return name:second_classify type:int default:-- desc:视频二级分类id
  732. * @return name:label type:string default:-- desc:视频标签id(多个用逗号隔开)
  733. */
  734. public function userReferVideoDetail()
  735. {
  736. $detail = UserVideo::where('id',input('get.id'))->find()->toArray();
  737. if($detail['is_deleted'] == 1) $this->error('视频已删除');
  738. $detail['label_name'] = [];
  739. if($detail['label']) {
  740. $detail['label_name'] =explode(',',trim($detail['label'],','));
  741. }
  742. $this->success('获取成功',['detail'=>$detail]);
  743. }
  744. /**
  745. * @title 用户删除视频记录&&批量删除
  746. * @desc 用户删除视频记录
  747. * @author qc
  748. * @method POST
  749. * @url /api/Video/delUserVideo
  750. * @header name:Authorization require:1 desc:Token
  751. * @param name:id type:int default:-- desc:记录id【多个逗号隔开】
  752. */
  753. public function delUserVideo()
  754. {
  755. UserVideo::where(['user_id'=>$this->user_id])->where('id','in',input('post.id'))->update(['is_deleted'=>1]);
  756. $this->success('删除成功');
  757. }
  758. /**
  759. * @title 视频评论
  760. * @desc 视频评论
  761. * @author qc
  762. * @method POST
  763. * @url /api/Video/videoComment
  764. * @header name:Authorization require:1 desc:Token
  765. * @param name:video_type type:int default:1 desc:视频类型(1平台2会员)
  766. * @param name:video_id type:int default:-- desc:视频系列id
  767. * @param name:url_id type:int default:-- desc:平台类型必传
  768. * @param name:content type:string default:-- desc:内容
  769. */
  770. public function videoComment()
  771. {
  772. $video_type = input('post.video_type',1);
  773. $video_id = input('post.video_id');
  774. $url_id = input('post.url_id',0);
  775. $content = input('post.content',0);
  776. if(!$content) $this->error('请输入评论内容');
  777. $comment_switch = VideoUrl::where('id',$url_id)->value('comment_switch');
  778. if(!$comment_switch) $this->error('评论功能已关闭');
  779. $send_user = VideoUrl::where('id',$url_id)->value('user_id');
  780. $res = VideoComment::create([
  781. 'user_id'=>$this->user_id,
  782. 'content'=>$content,
  783. 'video_id'=>$video_id,
  784. 'url_id'=>$url_id,
  785. 'video_type'=>$video_type,
  786. 'is_read' => $send_user == $this->user_id ? 1 : 0,
  787. 'source_read' => $send_user == $this->user_id ? 1 : 0,
  788. ]);
  789. $detail =VideoComment::where('c.id',$res->id)
  790. ->alias('c')
  791. ->field('c.id,c.content,c.user_id,c.create_at,u.name,u.headimg')
  792. ->leftJoin('store_member u','u.id = c.user_id')
  793. ->find()->toArray();
  794. $user_info = $this->userInfo('name');
  795. 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);
  796. $this->success('评论成功',['detail'=>$detail]);
  797. }
  798. /**
  799. * @title 视频二级评论
  800. * @desc 视频二级评论
  801. * @author qc
  802. * @method POST
  803. * @url /api/Video/secondCommend
  804. * @header name:Authorization require:1 desc:Token
  805. * @param name:id type:int default:1 desc:评论id
  806. * @param name:content type:string default:-- desc:内容
  807. * @return name:name type:string default:-- desc:会员名称
  808. * @return name:headimg type:string default:-- desc:会员头像
  809. * @return name:content type:string default:-- desc:内容
  810. */
  811. public function secondCommend()
  812. {
  813. $comment = VideoComment::where('id',input('post.id'))->find()->toArray();
  814. $user_info = $this->userInfo('name');
  815. $content = input('post.content');
  816. 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']);
  817. $send_user = VideoUrl::where('id',$comment['url_id'])->value('user_id');
  818. $to_user = $comment['user_id'];
  819. $comment_switch = VideoUrl::where('id',$comment['url_id'])->value('comment_switch');
  820. if(!$comment_switch) $this->error('评论功能已关闭');
  821. //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']);
  822. unset($comment['id']);
  823. unset($comment['create_at']);
  824. unset($comment['to_deleted']);
  825. unset($comment['is_top']);
  826. unset($comment['is_deleted']);
  827. $comment['pid'] = input('post.id');
  828. $comment['user_id'] = $this->user_id;
  829. $comment['content'] = input('post.content');
  830. $comment['lev']++;
  831. $comment['is_read']= $this->user_id == $to_user ? 1 :0 ;
  832. $comment['source_read'] = $this->user_id == $send_user ? 1 :0 ;
  833. if(!$comment['source_id']) $comment['source_id'] = input('post.id');
  834. $res = VideoComment::create($comment);
  835. $detail = VideoComment::where('c.id',$res->id)
  836. ->alias('c')
  837. ->field('c.id,c.content,c.create_at,u.name,u.headimg')
  838. ->leftJoin('store_member u','u.id = c.user_id')
  839. ->find()->toArray();
  840. $this->success('评论成功',['detail'=>$detail]);
  841. }
  842. /**
  843. * @title 获取视频评论列表
  844. * @desc 获取视频评论列表
  845. * @author qc
  846. * @method GET
  847. * @url /api/Video/getVideoCommentList
  848. * @header name:Authorization require:1 desc:Token
  849. * @param name:video_type type:int default:1 desc:视频类型(1平台2会员)
  850. * @param name:video_id type:int default:-- desc:视频系列id
  851. * @param name:url_id type:int default:-- desc:url_id
  852. * @param name:sort_type type:int default:1 desc:排序规则1最新2热点
  853. * @param name:page type:int default:1 desc:页数
  854. * @param name:page_num type:int default:20 desc:每页数
  855. * @return name:name type:string default:-- desc:会员名称
  856. * @return name:headimg type:string default:-- desc:会员头像
  857. * @return name:content type:string default:-- desc:内容
  858. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  859. * @return name:is_deleted type:int default:-- desc:是否删除(大于0未删除状态)
  860. * @return name:parent type:array default:-- desc:评论上一级(数据同上【一维数组】)
  861. * @return name:children type:array default:-- desc:二级评论(数据同上【二维数组】)
  862. * @return name:like_num type:int default:-- desc:点赞数量
  863. * @return name:is_like type:int default:-- desc:是否点赞(0否1是)
  864. * @return name:can_delete type:int default:-- desc:是否可以删除(0否1是)
  865. * @return name:total_num type:int default:-- desc:总评论数(仅一级)
  866. *
  867. */
  868. public function getVideoCommentList()
  869. {
  870. $where = [];
  871. $where[] = ['c.video_id','=',input('get.video_id')];
  872. $where[] = ['c.url_id','=',input('get.url_id')];
  873. $where[] = ['c.video_type','=',input('get.video_type')];
  874. $where[] = ['c.is_deleted','=',0];
  875. $user_id = $this->user_id;
  876. $sort_type= input('sort_type',1);
  877. switch ($sort_type) {
  878. case 1:
  879. $order = ['c.is_top'=>'desc','c.id'=>'desc','c.like_times'=>'desc'];
  880. break;
  881. case 2:
  882. $order = ['c.is_top'=>'desc','c.like_times'=>'desc','c.id'=>'desc'];
  883. break;
  884. }
  885. $list =VideoComment::where($where)
  886. ->alias('c')
  887. ->field('c.*,u.name,u.headimg')
  888. ->leftJoin('store_member u','u.id = c.user_id')
  889. ->order($order)
  890. ->limit($this->off_set,$this->page_num)
  891. ->select()->toArray();
  892. array_walk($list,function (&$val,$k)use($user_id){
  893. $children = VideoComment::where(['c.pid'=>$val['id']])
  894. ->alias('c')
  895. ->field('c.*,u.name,u.headimg')
  896. ->leftJoin('store_member u','u.id = c.user_id')
  897. ->order('c.is_top,c.id asc')
  898. ->select()->toArray();
  899. $val['like_num'] = VideoCommentLike::where('like_id',$val['id'])->where('type',1)->count();
  900. $val['like_num'] = numTransform($val['like_num']);
  901. $val['children'] = $children;
  902. $val['is_like'] = VideoCommentLike::where(['like_id'=>$val['id'],'user_id'=>$user_id,'type'=>1])->count();
  903. $parent = VideoComment::where(['c.id'=>$val['pid']])
  904. ->alias('c')->field('c.*,u.name,u.headimg')
  905. ->leftJoin('store_member u','u.id = c.user_id')
  906. ->find();
  907. $val['parent'] = $parent ? $parent->toArray() : null;
  908. $val['parent_comment'] = $val['parent'] ;
  909. $val['can_delete'] = $val['user_id'] == $this->user_id ? 1 :0;
  910. });
  911. $total_num = VideoComment::where($where)->alias('c')->count();
  912. $this->success('ok',['list'=>$list,'total_num'=>numTransform($total_num),'total_count'=>$total_num,'page_num'=>$this->page_num]);
  913. }
  914. /**
  915. * @title 点赞||取消点赞--可以批量
  916. * @desc 点赞||取消点赞
  917. * @author qc
  918. * @method POST
  919. * @url /api/Video/videoTags
  920. * @header name:Authorization require:1 desc:Token
  921. * @param name:type type:int default:1 desc:1评论点赞,2平台视频点赞
  922. * @param name:like_id type:int default:1 desc:点赞id【多个逗号隔开】(平台视频点赞用video_arr的id或评论记录id或点赞记录的like_id)
  923. * @return name:tags type:int default:1 desc:0取消成功,1点赞成功
  924. */
  925. public function videoTags()
  926. {
  927. $type = input('post.type',1);
  928. $id = input('post.like_id');
  929. $ret_val = 0;
  930. foreach (explode(',',$id) as $like_id) {
  931. $check_tags = VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->value('id');
  932. if($check_tags) {
  933. VideoCommentLike::where(['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type])->delete();
  934. if($type == 1) VideoComment::where('id',$like_id)->setDec('like_times');
  935. }else{
  936. if($type == 2) {
  937. $p_user_id = VideoUrl::where('id',$like_id)->value('user_id');
  938. }else{
  939. $p_user_id = VideoComment::where('id',$like_id)->value('user_id');
  940. }
  941. $is_read = $p_user_id == $this->user_id ? 1 : 0;
  942. Data::save('VideoCommentLike',
  943. ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type,'is_read'=>$is_read],'user_id',
  944. ['user_id'=>$this->user_id,'like_id'=>$like_id,'type'=>$type]);
  945. $ret_val = 1;
  946. if($type == 1) VideoComment::where('id',$like_id)->setInc('like_times');
  947. }
  948. }
  949. $this->success($ret_val == 1 ?'点赞成功':'取消成功',['tags'=>$ret_val]);
  950. }
  951. /**
  952. * @title 视频转发【分享】(转发数量统计)
  953. * @desc 转发成功后调用
  954. * @author qc
  955. * @method POST
  956. * @url /api/Video/videoTransmit
  957. * @header name:Authorization require:1 desc:Token
  958. * @param name:video_id type:int default:-- desc:视频系列id
  959. * @param name:url_id type:int default:-- desc:类型必传
  960. */
  961. public function videoTransmit()
  962. {
  963. $video_type = input('post.video_type',1);
  964. $video_id = input('post.video_id');
  965. $url_id = input('post.url_id',0);
  966. if($video_type == 1) {
  967. VideoUrl::where('id',$url_id)->setInc('transmit_num');
  968. }else{
  969. UserVideo::where('id',$video_id)->setInc('transmit_num');
  970. }
  971. $this->success('ok');
  972. }
  973. /**
  974. * @title 视频播放(播放数量统计)
  975. * @desc 播放数量统计
  976. * @author qc
  977. * @method POST
  978. * @url /api/Video/videoPlay
  979. * @header name:Authorization require:1 desc:Token
  980. * @param name:video_id type:int require:1 default:-- desc:视频系列id
  981. * @param name:url_id type:int require:1 default:-- desc:url_id
  982. * @param name:track_time type:string require:0 default:-- desc:播放到位置
  983. */
  984. public function videoPlay()
  985. {
  986. $video_id = input('post.video_id');
  987. $url_id = input('post.url_id',0);
  988. $track_time = input('post.track_time',0);
  989. VideoUrl::where('id',$url_id)->setInc('read_num');
  990. VideoIntro::where('id',$video_id)->setInc('read_num');
  991. // if($this->user_id){
  992. // TopSearch::seIncHotNum($url_id,$this->request->controller());
  993. // }
  994. if(!$video_id) $video_id = VideoUrl::where('id',$url_id)->value('video_id');
  995. UserTrack::crateTrack($this->user_id,1,$video_id,$url_id,$track_time);
  996. $this->success('ok');
  997. }
  998. /**
  999. * @title 以下接口学习服务模块的
  1000. *
  1001. * @desc
  1002. * @author qc
  1003. * @method
  1004. * @url /api/Video/learn()
  1005. */
  1006. public function learn(){}
  1007. /**
  1008. * @title 视频学习历史
  1009. * @desc 视频学习历史
  1010. * @author qc
  1011. * @method GET
  1012. * @url /api/Video/getLearnHistory
  1013. * @header name:Authorization require:1 desc:Token
  1014. * @param name:title type:string default:-- desc:标题
  1015. * @param name:page type:int default:0 desc:页数
  1016. * @param name:page_num type:int default:20 desc:每页数
  1017. * @return name:title type:string default:-- desc:标题
  1018. * @return name:series_title type:string default:-- desc:系列标题
  1019. * @return name:video_id type:string default:-- desc:视频id
  1020. * @return name:url_id type:string default:-- desc:url_id
  1021. * @return name:cover type:string default:-- desc:封面
  1022. * @return name:time type:string default:-- desc:时间
  1023. * @return name:ali_vid type:string default:-- desc:云点播id
  1024. * @return name:ali_vid type:string default:-- desc:云点播id
  1025. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1026. * @return name:read_num type:int default:-- desc:播放量
  1027. * @return name:app_name type:string default:-- desc:发布者
  1028. * @return name:app_logo type:string default:-- desc:发布者头像
  1029. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1030. */
  1031. public function getLearnHistory()
  1032. {
  1033. $sel_where = [];
  1034. $sel_where[] = ['t.user_id','=',$this->user_id];
  1035. $sel_where[] = ['t.type','=',1];
  1036. $title = input('get.title');
  1037. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1038. $list = UserTrack::where($sel_where)
  1039. ->alias('t')
  1040. ->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')
  1041. ->leftJoin('VideoUrl i','t.second_id = i.id')
  1042. ->leftJoin('VideoIntro x','t.first_id = x.id')
  1043. ->order('update_int desc')
  1044. ->limit($this->off_set,$this->page_num)
  1045. ->select()->toArray();
  1046. foreach ($list as &$v) {
  1047. $v['time'] = date("Y-m-d H:i:s",$v['update_int']);
  1048. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1049. $v['read_num'] = numTransform($v['read_num']);
  1050. $video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
  1051. $v['app_name'] = $video_auth['app_name'];
  1052. $v['app_logo'] = $video_auth['app_logo'];
  1053. }
  1054. $total_num = UserTrack::where($sel_where)->alias('t')
  1055. ->leftJoin('VideoUrl i','t.second_id = i.id')->count();
  1056. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1057. }
  1058. /**
  1059. * @title 获取角标数量【未读数量统计】
  1060. * @desc 未读数量统计
  1061. * @author qc
  1062. * @method GET
  1063. * @url /api/Video/getMarkNum
  1064. * @header name:Authorization require:1 desc:Token
  1065. * @return name:reply_num type:int default:-- desc:回复我的
  1066. * @return name:comment_num type:int default:-- desc:评论我的
  1067. * @return name:praise_num type:int default:-- desc:点赞我的【包含视频点赞和评论点赞】
  1068. * @return name:video_praise_num type:int default:-- desc:-视频点赞
  1069. * @return name:comment_praise_num type:int default:-- desc:评论点赞
  1070. * @return name:follow_num type:int default:-- desc:追播
  1071. */
  1072. public function getMarkNum()
  1073. {
  1074. // 评论我的
  1075. $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]])
  1076. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1077. ->alias('t')->count();
  1078. // 回复我的
  1079. $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1080. $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;
  1081. // 点赞我的
  1082. $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1083. $video_praise_num = VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video],['user_id','<>',$this->user_id]])->count();
  1084. $comment_praise_num = VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$all_comment],['user_id','<>',$this->user_id]])->count();
  1085. $praise_num = $video_praise_num + $comment_praise_num;
  1086. // 追播未读量
  1087. $follow_num = UserMessage::getUnreadNum($this->user_id,'video',5);
  1088. $this->success('ok',compact(['reply_num','comment_num','praise_num','comment_praise_num','video_praise_num','follow_num']));
  1089. }
  1090. /**
  1091. * @title 删除评论
  1092. * @desc 删除评论
  1093. * @author qc
  1094. * @method POST
  1095. * @url /api/Video/delComment
  1096. * @header name:Authorization require:1 desc:Token
  1097. * @param name:id type:int default:1 desc:评论id
  1098. */
  1099. public function delComment(){
  1100. VideoComment::where(['id'=>input('post.id'),'user_id'=>$this->user_id])->update(['is_deleted'=>1]);
  1101. $this->success('删除成功');
  1102. }
  1103. /**
  1104. * @title 回复我的【回复我的--回复过我的评论】
  1105. * @desc 回复我的
  1106. * @author qc
  1107. * @method GET
  1108. * @url /api/Video/getReplayComment
  1109. * @header name:Authorization require:1 desc:Token
  1110. * @param name:title type:string default:-- desc:标题
  1111. * @param name:page type:int default:0 desc:页数
  1112. * @param name:page_num type:int default:20 desc:每页数
  1113. * @return name:title type:string default:-- desc:标题
  1114. * @return name:video_id type:string default:-- desc:视频系列id
  1115. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1116. * @return name:url_id type:string default:-- desc:url_id
  1117. * @return name:cover type:string default:-- desc:封面
  1118. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1119. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1120. * @return name:read_num type:int default:-- desc:播放量
  1121. * @return name:create_at type:string default:-- desc:时间
  1122. * @return name:app_name type:string default:-- desc:发布者
  1123. * @return name:app_logo type:string default:-- desc:发布者头像
  1124. * @return name:user_name type:string default:-- desc:用户名【其他会员】
  1125. * @return name:headimg type:string default:-- desc:用户头【其他会员】
  1126. * @return name:parent_comment type:array default:-- desc:你的评论内容【别人回复的那个评论】
  1127. * @return name:parent_comment.content type:string default:-- desc:内容
  1128. * @return name:parent_comment.name type:string default:-- desc:会员名称
  1129. * @return name:parent_comment.title type:string default:-- desc:视频标题
  1130. * @return name:parent_comment.series_title type:string default:-- desc:系列标题
  1131. * @return name:parent_comment.video_id type:string default:-- desc:视频id
  1132. * @return name:parent_comment.url_id type:string default:-- desc:url_id
  1133. * @return name:parent_comment.ali_vid:string default:-- desc:云点播id
  1134. * @return name:parent_comment.is_deleted:int default:-- desc:是否删除(0否,1,2已删除)
  1135. * @return name:parent_comment.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  1136. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1137. *
  1138. */
  1139. public function getReplayComment()
  1140. {
  1141. $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1142. if(empty($all_comment)) $this->success('ok',['list'=>[]]);
  1143. $sel_where = [];
  1144. $title = input('get.title');
  1145. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1146. $sel_where[] = ['t.is_deleted','=',0];
  1147. $sel_where[] = ['t.user_id','<>',$this->user_id];
  1148. $sel_where[] = ['t.to_deleted','=',0];
  1149. $sel_where[] = ['t.pid','in',implode(',',$all_comment)];
  1150. $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();
  1151. $list = VideoComment::where($sel_where)
  1152. ->alias('t')
  1153. ->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')
  1154. ->leftJoin('store_member u','t.user_id = u.id')
  1155. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1156. ->order('t.is_top desc,t.id desc')
  1157. ->limit($this->off_set,$this->page_num)
  1158. ->select()->toArray();
  1159. foreach ($list as &$v) {
  1160. $video_auth = VideoUrl::getVideoAuth($v['user_id'],APPNAME,APPLOGO);
  1161. $v['app_name'] = $video_auth['app_name'];
  1162. $v['app_logo'] = $video_auth['app_logo'];
  1163. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1164. $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
  1165. ->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')
  1166. ->alias('t')
  1167. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1168. ->leftJoin('VideoIntro x','t.video_id = x.id')
  1169. ->leftJoin('store_member u','t.user_id = u.id')
  1170. ->find()->toArray();
  1171. $v['parent_comment'] = $parent_comment;
  1172. $v['read_num'] = numTransform($v['read_num']);
  1173. }
  1174. $total_num = VideoComment::where($sel_where)->alias('t')
  1175. ->leftJoin('store_member u','t.user_id = u.id')
  1176. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1177. ->order('t.is_top desc,t.id desc')->count();
  1178. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1179. }
  1180. /**
  1181. * @title 我的回复【我的回复--我回复过的评论】
  1182. * @desc 我的回复
  1183. * @author qc
  1184. * @method GET
  1185. * @url /api/Video/getReplyVideo
  1186. * @header name:Authorization require:1 desc:Token
  1187. * @param name:title type:string default:-- desc:标题
  1188. * @param name:page type:int default:0 desc:页数
  1189. * @param name:page_num type:int default:20 desc:每页数
  1190. * @return name:title type:string default:-- desc:标题
  1191. * @return name:video_id type:string default:-- desc:视频系列id
  1192. * @return name:url_id type:string default:-- desc:url_id
  1193. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1194. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1195. * @return name:cover type:string default:-- desc:封面
  1196. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1197. * @return name:create_at type:string default:-- desc:时间
  1198. * @return name:app_name type:string default:-- desc:发布者
  1199. * @return name:app_logo type:string default:-- desc:发布者头像
  1200. * @return name:read_num type:string default:-- desc:播放量
  1201. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  1202. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  1203. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1204. * @return name:parent_comment type:array default:-- desc:上级评论内容【你评论的那个评论】
  1205. * @return name:parent_comment.content type:string default:-- desc:内容
  1206. * @return name:parent_comment.name type:string default:-- desc:会员名称
  1207. * @return name:parent_comment.title type:string default:-- desc:视频标题
  1208. * @return name:parent_comment.series_title type:string default:-- desc:系列标题
  1209. * @return name:parent_comment.video_id type:string default:-- desc:视频id
  1210. * @return name:parent_comment.url_id type:string default:-- desc:url_id
  1211. * @return name:parent_comment.ali_vid:string default:-- desc:云点播id
  1212. * @return name:parent_comment.is_deleted:int default:-- desc:是否删除(0否,1,2已删除)
  1213. * @return name:parent_comment.comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  1214. */
  1215. public function getReplyVideo()
  1216. {
  1217. $user_info = $this->userInfo();
  1218. $sel_where = [];
  1219. $title = input('get.title');
  1220. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1221. $sel_where[] = ['t.user_id','=',$this->user_id];
  1222. $sel_where[] = ['t.is_deleted','=',0];
  1223. $sel_where[] = ['t.lev','>=',2];
  1224. $list = VideoComment::where($sel_where)
  1225. ->alias('t')
  1226. ->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')
  1227. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1228. ->order('t.is_top,t.id desc')
  1229. ->limit($this->off_set,$this->page_num)
  1230. ->select()->toArray();
  1231. foreach ($list as &$v) {
  1232. $v['user_name'] = $user_info['name'];
  1233. $v['headimg'] = $user_info['headimg'];
  1234. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1235. $parent_comment = VideoComment::where([['t.id','=',$v['pid']]])
  1236. ->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')
  1237. ->alias('t')
  1238. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1239. ->leftJoin('VideoIntro x','i.video_id = x.id')
  1240. ->leftJoin('store_member u','t.user_id = u.id')
  1241. ->find()->toArray();
  1242. $v['parent_comment'] = $parent_comment;
  1243. $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
  1244. $v['app_name'] = $video_auth['app_name'];
  1245. $v['app_logo'] = $video_auth['app_logo'];
  1246. $v['read_num'] = numTransform($v['read_num']);
  1247. }
  1248. $total_num = VideoComment::where($sel_where)->alias('t')
  1249. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1250. ->order('t.is_top,t.id desc')
  1251. ->count();
  1252. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1253. }
  1254. /**
  1255. * @title 我的评论【学习服务--我评论过的视频】
  1256. * @desc 我的评论
  1257. * @author qc
  1258. * @method GET
  1259. * @url /api/Video/getCommentVideo
  1260. * @header name:Authorization require:1 desc:Token
  1261. * @param name:title type:string default:-- desc:标题
  1262. * @param name:page type:int default:0 desc:页数
  1263. * @param name:page_num type:int default:20 desc:每页数
  1264. * @return name:title type:string default:-- desc:标题
  1265. * @return name:series_title type:string default:-- desc:系列标题
  1266. * @return name:video_id type:string default:-- desc:视频系列id
  1267. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1268. * @return name:url_id type:string default:-- desc:url_id
  1269. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1270. * @return name:cover type:string default:-- desc:封面
  1271. * @return name:create_at type:string default:-- desc:时间
  1272. * @return name:user_name type:string default:-- desc:用户名【用户自己的】
  1273. * @return name:headimg type:string default:-- desc:用户头像【用户自己的】
  1274. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1275. * @return name:ali_vid:string default:-- desc:云点播id
  1276. * @return name:app_name type:string default:-- desc:发布者
  1277. * @return name:app_logo type:string default:-- desc:发布者头像
  1278. * @return name:read_num type:string default:-- desc:播放量
  1279. */
  1280. public function getCommentVideo()
  1281. {
  1282. $user_info = $this->userInfo();
  1283. $sel_where = [];
  1284. $title = input('get.title');
  1285. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1286. $sel_where[] = ['t.user_id','=',$this->user_id];
  1287. $sel_where[] = ['t.is_deleted','=',0];
  1288. $sel_where[] = ['t.pid','=',0];
  1289. $list = VideoComment::where($sel_where)
  1290. ->alias('t')
  1291. ->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')
  1292. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1293. ->leftJoin('VideoIntro x','t.video_id = x.id')
  1294. ->order('t.is_top desc, t.id desc')
  1295. ->limit($this->off_set,$this->page_num)
  1296. ->select()->toArray();
  1297. foreach ($list as &$v) {
  1298. $v['user_name'] = $user_info['name'];
  1299. $v['headimg'] = $user_info['headimg'];
  1300. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1301. $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
  1302. $v['app_name'] = $video_auth['app_name'];
  1303. $v['app_logo'] = $video_auth['app_logo'];
  1304. $v['read_num'] = numTransform($v['read_num']);
  1305. }
  1306. $total_num =VideoComment::where($sel_where)->alias('t')
  1307. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1308. ->count();
  1309. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1310. }
  1311. /**
  1312. * @title 评论我的【学习服务--评论我的】
  1313. * @desc 评论我的
  1314. * @author qc
  1315. * @method GET
  1316. * @url /api/Video/commentMyVideo
  1317. * @header name:Authorization require:1 desc:Token
  1318. * @param name:title type:string default:-- desc:标题
  1319. * @param name:page type:int default:0 desc:页数
  1320. * @param name:page_num type:int default:20 desc:每页数
  1321. * @return name:title type:string default:-- desc:标题
  1322. * @return name:is_read type:int default:-- desc:是否已读(0未读1已读)
  1323. * @return name:video_id type:string default:-- desc:视频系列id
  1324. * @return name:url_id type:string default:-- desc:url_id
  1325. * @return name:is_top type:int default:-- desc:是否置顶(0否1是)
  1326. * @return name:cover type:string default:-- desc:封面
  1327. * @return name:create_at type:string default:-- desc:时间
  1328. * @return name:user_name type:string default:-- desc:用户名
  1329. * @return name:headimg type:string default:-- desc:用户头像
  1330. * @return name:ali_vid:string default:-- desc:云点播id
  1331. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1332. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1333. * @return name:read_num type:int default:-- desc:播放量
  1334. * @return name:app_name type:string default:-- desc:发布者
  1335. * @return name:app_logo type:string default:-- desc:发布者头像
  1336. */
  1337. public function commentMyVideo()
  1338. {
  1339. $sel_where = [];
  1340. $title = input('get.title');
  1341. if($title) $sel_where[] = ['i.title|i.label|t.content','like','%'.$title.'%'];
  1342. $sel_where[] = ['t.is_deleted','=',0];
  1343. $sel_where[] = ['i.user_id','=',$this->user_id];
  1344. $sel_where[] = ['t.user_id','<>',$this->user_id];
  1345. $sel_where[] = ['t.source_deleted','=',0];
  1346. $sel_where[] = ['t.pid','=',0];
  1347. $user_info = $this->userInfo('name,headimg');
  1348. $list = VideoComment::where($sel_where)
  1349. ->alias('t')
  1350. ->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')
  1351. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1352. ->leftJoin('VideoIntro x','t.video_id = x.id')
  1353. ->leftJoin('store_member u','t.user_id = u.id')
  1354. ->order('t.id desc')
  1355. ->limit($this->off_set,$this->page_num)
  1356. ->select()->toArray();
  1357. array_walk($list,function (&$v)use ($user_info){
  1358. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1359. $v['read_num'] = numTransform($v['read_num']);
  1360. $v['app_name'] = $user_info['name'];
  1361. $v['app_logo'] = $user_info['headimg'];
  1362. });
  1363. $total_num = VideoComment::where($sel_where)
  1364. ->alias('t')
  1365. ->leftJoin('VideoUrl i','t.url_id = i.id')
  1366. ->leftJoin('store_member u','t.user_id = u.id')
  1367. ->count();
  1368. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1369. }
  1370. /**
  1371. * @title 我的已购
  1372. * @desc 已购视频列表
  1373. * @author qc
  1374. * @method GET
  1375. * @url /api/Video/getPurchaseVideo
  1376. * @header name:Authorization require:1 desc:Token
  1377. * @param name:title type:string default:-- desc:标题
  1378. * @param name:page type:int default:0 desc:页数
  1379. * @param name:page_num type:int default:20 desc:每页数
  1380. * @return name:title type:string default:-- desc:标题
  1381. * @return name:video_id type:string default:-- desc:视频系列id
  1382. * @return name:cover type:string default:-- desc:封面
  1383. * @return name:create_at type:string default:-- desc:时间
  1384. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1385. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1386. * @return name:total_sequel type:int default:-- desc:视频期数
  1387. * @return name:first_title type:int default:-- desc:第一期标题
  1388. * @return name:recently_title type:int default:-- desc:上次观看title
  1389. * @return name:is_over type:int default:-- desc:是否完结
  1390. */
  1391. public function getPurchaseVideo()
  1392. {
  1393. $sel_where = [];
  1394. $title = input('get.title');
  1395. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1396. $sel_where[] = ['t.user_id','=',$this->user_id];
  1397. $sel_where[] = ['t.type','=',1];
  1398. $sel_where[] = ['t.end_int','>',time()];
  1399. $sel_where[] = ['t.is_deleted','=',0];
  1400. $sel_where[] = ['i.is_deleted','=',0];
  1401. $list = UserLearn::where($sel_where)
  1402. ->alias('t')
  1403. ->field('t.id,t.create_at,t.first_id video_id,i.title,i.cover,i.is_vip,i.total_sequel,i.is_over')
  1404. ->leftJoin('VideoIntro i','t.first_id = i.id')
  1405. ->order('t.id desc')
  1406. ->limit($this->off_set,$this->page_num)
  1407. ->select()->toArray();
  1408. array_walk($list,function (&$v){
  1409. // $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1410. $all_title = VideoUrl::where(['video_id'=>$v['id'],'is_deleted'=>0])->column('title');
  1411. $v['first_title'] = empty($all_title) ? '' : $all_title[0];
  1412. $v['recently_title'] = UserTrack::getRecentlyTitle($this->user_id,1,$v['video_id']);
  1413. });
  1414. $total_num =UserLearn::where($sel_where)->alias('t')->leftJoin('VideoIntro i','t.first_id = i.id')->count();
  1415. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1416. }
  1417. /**
  1418. * @title 视频收藏记录【我的收藏】
  1419. * @desc 视频收藏记录
  1420. * @author qc
  1421. * @method GET
  1422. * @url /api/Video/getVideoCollect
  1423. * @header name:Authorization require:1 desc:Token
  1424. * @param name:title type:string default:-- desc:标题
  1425. * @param name:page type:int default:0 desc:页数
  1426. * @param name:page_num type:int default:20 desc:每页数
  1427. * @return name:title type:string default:-- desc:标题
  1428. * @return name:series_title type:string default:-- desc:系列标题
  1429. * @return name:video_id type:string default:-- desc:视频系列id
  1430. * @return name:url_id type:string default:-- desc:url_id
  1431. * @return name:cover type:string default:-- desc:封面
  1432. * @return name:create_at type:string default:-- desc:时间
  1433. * @return name:ali_vid type:string default:-- desc:云点播id
  1434. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1435. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1436. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1437. * @return name:transmit_num type:int default:-- desc:转发量
  1438. * @return name:comment_num type:int default:-- desc:评论量
  1439. * @return name:is_praise type:int default:-- desc:是否点赞
  1440. * @return name:praise_num type:int default:-- desc:点赞量
  1441. * @return name:praise_num type:int default:-- desc:点赞量
  1442. * @return name:is_collect type:int default:-- desc:是否收藏
  1443. * @return name:collect_num type:int default:-- desc:收藏量
  1444. * @return name:read_num type:int default:-- desc:播放量
  1445. * @return name:desc type:string default:-- desc:简介
  1446. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  1447. */
  1448. public function getVideoCollect()
  1449. {
  1450. $sel_where = [];
  1451. $title = input('get.title');
  1452. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1453. $sel_where[] = ['t.user_id','=',$this->user_id];
  1454. $sel_where[] = ['t.coll_type','=',1];
  1455. $list = UserCollect::where($sel_where)
  1456. ->alias('t')
  1457. ->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')
  1458. ->leftJoin('VideoUrl i','t.children_id = i.id')
  1459. ->leftJoin('VideoIntro x','t.coll_id = x.id')
  1460. ->order('id desc')
  1461. ->limit($this->off_set,$this->page_num)
  1462. ->select()->toArray();
  1463. array_walk($list,function (&$v){
  1464. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['url_id'],7);
  1465. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1466. $v['transmit_num'] = numTransform($v['transmit_num']);
  1467. $v['read_num'] = numTransform($v['read_num']);
  1468. $v['comment_num'] = VideoComment::getVideoCommentNum($v['url_id']);
  1469. $v['is_praise'] = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$v['url_id']])->count();
  1470. $v['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$v['url_id']])->count();
  1471. $v['praise_num'] = numTransform($v['praise_num']);
  1472. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['video_id'],$v['url_id']);
  1473. $v['collect_num'] = UserCollect::getCollectNum(1,$v['video_id'],$v['url_id']);
  1474. $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
  1475. $v['app_name'] = $video_auth['app_name'];
  1476. $v['app_logo'] = $video_auth['app_logo'];
  1477. });
  1478. $total_num = UserCollect::where($sel_where)->alias('t')
  1479. ->leftJoin('VideoUrl i','t.children_id = i.id')
  1480. ->count();
  1481. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1482. }
  1483. /**
  1484. * @title 用户视频收藏||取消收藏
  1485. * @desc 用户视频收藏
  1486. * @author qc
  1487. * @method POST
  1488. * @url /api/Video/videoCollect
  1489. * @header name:Authorization require:1 desc:Token
  1490. * @param name:coll_id type:int require:1 default:-- desc:收藏id(平台视频点赞用video_arr的iD)
  1491. * @param name:status type:int default:0 desc:收藏状态(0取消收藏【未收藏】,1收藏)
  1492. */
  1493. public function videoCollect()
  1494. {
  1495. $coll_type = input('post.coll_type',1);
  1496. $url_id = input('post.coll_id',0);
  1497. $video_id = VideoUrl::where('id',$url_id)->value('video_id');
  1498. $collect_check = UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->find();
  1499. if($collect_check) {
  1500. UserCollect::where(['user_id'=>$this->user_id,'coll_type'=>$coll_type,'coll_id'=>$video_id,'children_id'=>$url_id])->delete();
  1501. $this->success('取消收藏成功',['status'=>0]);
  1502. }else{
  1503. Data::save('UserCollect', [
  1504. 'user_id'=>$this->user_id,
  1505. 'coll_type'=>$coll_type,
  1506. 'coll_id'=>$video_id,
  1507. 'children_id'=>$url_id,
  1508. 'create_int'=>time()],'user_id',['user_id'=>$this->user_id,'coll_type'=>$coll_type, 'coll_id'=>$video_id,'children_id'=>$url_id]);
  1509. $this->success('收藏成功',['status'=>1]);
  1510. }
  1511. }
  1512. /**
  1513. * @title 视频点赞列表【我的点赞】
  1514. * @desc 视频点赞列表
  1515. * @author qc
  1516. * @method GET
  1517. * @url /api/Video/getTagsVideo
  1518. * @header name:Authorization require:1 desc:Token
  1519. * @param name:title type:string default:-- desc:标题
  1520. * @param name:page type:int default:0 desc:页数
  1521. * @param name:page_num type:int default:20 desc:每页数
  1522. * @return name:title type:string default:-- desc:标题
  1523. * @return name:series_title type:string default:-- desc:系列标题
  1524. * @return name:video_id type:string default:-- desc:视频id
  1525. * @return name:url_id type:string default:-- desc:url_id
  1526. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1527. * @return name:cover type:string default:-- desc:封面
  1528. * @return name:create_at type:string default:-- desc:时间
  1529. * @return name:ali_vid type:string default:-- desc:云点播id
  1530. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1531. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1532. * @return name:transmit_num type:int default:-- desc:转发量
  1533. * @return name:comment_num type:int default:-- desc:评论量
  1534. * @return name:is_praise type:int default:-- desc:是否点赞
  1535. * @return name:praise_num type:int default:-- desc:点赞量
  1536. * @return name:is_collect type:int default:-- desc:是否收藏
  1537. * @return name:collect_num type:int default:-- desc:收藏量
  1538. * @return name:desc type:string default:-- desc:简介
  1539. * @return name:switch_open type:int default:-- desc:通知开关【0关闭1开启】
  1540. */
  1541. public function getTagsVideo()
  1542. {
  1543. $sel_where = [];
  1544. $title = input('get.title');
  1545. if($title) $sel_where[] = ['i.title|i.label','like','%'.$title.'%'];
  1546. $sel_where[] = ['t.user_id','=',$this->user_id];
  1547. $sel_where[] = ['t.type','=',2];
  1548. $list = VideoCommentLike::where($sel_where)
  1549. ->alias('t')
  1550. ->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')
  1551. ->leftJoin('VideoUrl i','t.like_id = i.id')
  1552. ->leftJoin('VideoIntro x','i.video_id = x.id')
  1553. ->order('id desc')
  1554. ->limit($this->off_set,$this->page_num)
  1555. ->select()->toArray();
  1556. array_walk($list,function (&$v){
  1557. $v['switch_open'] = PlatformSwitch::checkSwitch($this->user_id,$v['url_id'],7);
  1558. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1559. $v['transmit_num'] = numTransform($v['transmit_num']);
  1560. $v['comment_num'] = VideoComment::getVideoCommentNum($v['url_id']);
  1561. $v['is_praise'] = VideoCommentLike::where(['user_id'=>$this->user_id,'type'=>2,'like_id'=>$v['url_id']])->count();
  1562. $v['praise_num'] = VideoCommentLike::where(['type'=>2,'like_id'=>$v['url_id']])->count();
  1563. $v['is_collect'] = UserCollect::checkCollectByType($this->user_id,1,$v['video_id'],$v['url_id']);
  1564. $v['collect_num'] = UserCollect::getCollectNum(1,$v['video_id'],$v['url_id']);
  1565. $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
  1566. $v['app_name'] = $video_auth['app_name'];
  1567. $v['app_logo'] = $video_auth['app_logo'];
  1568. });
  1569. $total_num = VideoCommentLike::where($sel_where)->alias('t')
  1570. ->leftJoin('VideoUrl i','t.like_id = i.id')->count();
  1571. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1572. }
  1573. /**
  1574. * @title 以下接口为二期需求
  1575. * @desc 以下接口为二期需求
  1576. * @author qc
  1577. * @url /api/Video/secondPhase
  1578. * @method
  1579. * @return name:1 type:string default:-- desc:以下接口为二期需求
  1580. */
  1581. public function secondPhase(){}
  1582. /**
  1583. * @title ui我的发布-审核成功【后台视频绑定该会员】
  1584. * @desc ui我的发布-审核成功
  1585. * @author qc
  1586. * @method GET
  1587. * @url /api/Video/getBoundList
  1588. * @header name:Authorization require:1 desc:Token
  1589. * @param name:title type:string default:-- desc:标题
  1590. * @param name:page type:int default:0 desc:页数
  1591. * @param name:page_num type:int default:20 desc:每页数
  1592. * @return name:id type:string default:-- desc:记录id【url_id】
  1593. * @return name:title type:string default:-- desc:标题
  1594. * @return name:series_title type:string default:-- desc:系列标题
  1595. * @return name:video_id type:string default:-- desc:视频系列id
  1596. * @return name:duration type:int default:-- desc:时长(单位:秒)
  1597. * @return name:cover type:string default:-- desc:封面
  1598. * @return name:create_at type:string default:-- desc:时间
  1599. * @return name:ali_vid type:string default:-- desc:云点播id
  1600. * @return name:is_vip type:int default:-- desc:是否是vip[0否1是]
  1601. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1602. */
  1603. public function getBoundList()
  1604. {
  1605. $sel_where = [];
  1606. $title = input('get.title');
  1607. $sel_where[] = ['t.user_id','=',$this->user_id];
  1608. $sel_where[] = ['t.is_deleted','=',0];
  1609. if($title) $sel_where[] = ['t.title|t.label','like','%'.$title.'%'];
  1610. $list = VideoUrl::where($sel_where)
  1611. ->alias('t')
  1612. ->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')
  1613. ->leftJoin('VideoIntro x','x.id = t.video_id')
  1614. ->order('id desc')
  1615. ->limit($this->off_set,$this->page_num)
  1616. ->select()->toArray();
  1617. foreach ($list as &$v) {
  1618. $v['read_num'] = numTransform($v['read_num']);
  1619. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['id'],$this->request->controller());
  1620. }
  1621. $total_num = VideoUrl::where($sel_where)->alias('t')->count();
  1622. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1623. }
  1624. /**
  1625. * @title 我的追番列表
  1626. * @desc 我的追番列表
  1627. * @author qc
  1628. * @method GET
  1629. * @url /api/Video/getFollowUpList
  1630. * @header name:Authorization require:1 desc:Token
  1631. * @param name:title type:string default:-- desc:标题
  1632. * @param name:page type:int default:0 desc:页数
  1633. * @param name:page_num type:int default:20 desc:每页数
  1634. * @return name:create_at type:string default:-- desc:追更设置时间
  1635. * @return name:video_id type:int default:-- desc:视频系列id
  1636. * @return name:title type:string default:-- desc:标题
  1637. * @return name:cover type:string default:-- desc:封面
  1638. * @return name:total_sequel type:string default:-- desc:总期数
  1639. * @return name:is_vip type:int default:-- desc:是否vip
  1640. * @return name:is_over type:int default:-- desc:是否完结
  1641. * @return name:recently_title type:int default:-- desc:上次观看title
  1642. * @return name:recently_id type:int default:-- desc:上次观看记录id
  1643. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1644. */
  1645. public function getFollowUpList()
  1646. {
  1647. $sel_where = [];
  1648. $sel_where[] = ['p.user_id','=',$this->user_id];
  1649. $sel_where[] = ['p.type','=',2];
  1650. $sel_where[] = ['p.switch_value','=',1];
  1651. $title = input('title');
  1652. if($title) $sel_where[] = ['a.title','like','%'.$title.'%'];
  1653. $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';
  1654. $list = PlatformSwitch::field($field)
  1655. ->alias('p')
  1656. ->leftJoin('VideoIntro a','p.switch_id = a.id')
  1657. ->where($sel_where)
  1658. ->limit($this->off_set,$this->page_num)
  1659. ->order('p.id desc')
  1660. ->select()->toArray();
  1661. array_walk($list,function (&$v){
  1662. $v['is_normal'] = $v['status'] == 1 && $v['is_deleted'] == 0 ? 1 : 0;
  1663. $v['recently_title'] = UserTrack::getRecentlyTitle($this->user_id,1,$v['video_id']);
  1664. $recently_id = UserTrack::getRecentlyTrack($this->user_id,1,$v['video_id']);
  1665. $v['recently_id'] = $recently_id ? $recently_id: 0;
  1666. });
  1667. $total_num =PlatformSwitch::field($field)->alias('p')
  1668. ->leftJoin('VideoIntro a','p.switch_id = a.id')
  1669. ->where($sel_where)->count();
  1670. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1671. }
  1672. /**
  1673. * @title 评论点赞列表--我的点赞
  1674. * @desc 评论点赞列表
  1675. * @author qc
  1676. * @method GET
  1677. * @url /api/Video/getTagsComment
  1678. * @header name:Authorization require:1 desc:Token
  1679. * @param name:title type:string default:-- desc:标题
  1680. * @return name:series_title type:string default:-- desc:系列标题
  1681. * @param name:page type:int default:0 desc:页数
  1682. * @param name:page_num type:int default:20 desc:每页数
  1683. * @return name:create_at type:string default:-- desc:时间
  1684. * @return name:user_name type:string default:-- desc:会员名称
  1685. * @return name:headimg type:string default:-- desc:会员头像
  1686. * @return name:content type:string default:-- desc:评论内容
  1687. * @return name:cover type:string default:-- desc:封面
  1688. * @return name:ali_vid type:string default:-- desc:云点播id
  1689. * @return name:title type:string default:-- desc:标题
  1690. * @return name:read_num type:string default:-- desc:播放量
  1691. * @return name:app_name type:string default:-- desc:发布者
  1692. * @return name:app_logo type:string default:-- desc:发布者头像
  1693. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1694. * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  1695. */
  1696. public function getTagsComment()
  1697. {
  1698. $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')
  1699. ->alias('l')
  1700. ->where(['l.user_id'=>$this->user_id,'l.type'=>1])
  1701. ->leftJoin('VideoComment c','l.like_id = c.id')
  1702. ->leftJoin('VideoUrl i','i.id = c.url_id')
  1703. ->leftJoin('VideoIntro x','x.id = i.video_id')
  1704. ->leftJoin('store_member u','u.id = c.user_id')
  1705. ->order('l.id desc')
  1706. ->limit($this->off_set,$this->page_num)
  1707. ->select()->toArray();
  1708. array_walk($list,function (&$v){
  1709. $video_auth = VideoUrl::getVideoAuth($v['buid'],APPNAME,APPLOGO);
  1710. $v['app_name'] = $video_auth['app_name'];
  1711. $v['app_logo'] = $video_auth['app_logo'];
  1712. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1713. });
  1714. $total_num =VideoCommentLike::where(['l.user_id'=>$this->user_id,'l.type'=>1])
  1715. ->alias('l')
  1716. ->leftJoin('VideoComment c','l.like_id = c.id')
  1717. ->leftJoin('VideoUrl i','i.id = c.url_id')
  1718. ->leftJoin('store_member u','u.id = c.user_id')
  1719. ->count();
  1720. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1721. }
  1722. /**
  1723. * @title 追番消息
  1724. * @desc 追番消息
  1725. * @author qc
  1726. * @method GET
  1727. * @url /api/Video/getFollowUpMessage
  1728. * @header name:Authorization require:1 desc:Token
  1729. * @param name:title type:int default:-- desc:搜索内容
  1730. * @param name:page type:int default:-- desc:页数
  1731. * @param name:page_num type:int default:-- desc:每页数
  1732. *
  1733. * @return name:id type:int default:-- desc:记录id
  1734. * @return name:title type:string default:-- desc:标题
  1735. * @return name:content type:string default:-- desc:内容
  1736. * @return name:create_at type:string default:-- desc:时间
  1737. * @return name:is_read type:int default:-- desc:是否已读【0否1是】
  1738. * @return name:video_title type:string default:-- desc:系列标题
  1739. * @return name:video_id type:int default:-- desc:系列id
  1740. * @return name:children_id type:int default:-- desc:详情id
  1741. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1742. */
  1743. public function getFollowUpMessage()
  1744. {
  1745. $title = input('title');
  1746. $list = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'video','m.type_id'=>5])
  1747. ->alias('m')
  1748. ->when($title,function ($query)use ($title){
  1749. if($title) $query->where('m.content','like','%'.$title.'%');})
  1750. ->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')
  1751. ->leftJoin('VideoIntro v','v.id= m.relation_id')
  1752. ->limit($this->off_set,$this->page_num)
  1753. ->order(['m.id'=>'desc'])
  1754. ->select()->toArray();
  1755. foreach ($list as &$v) {
  1756. $v['series_title'] =$v['video_title'];
  1757. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['children_id'],$this->request->controller());
  1758. }
  1759. $total_num = UserMessage::where(['m.user_id'=>$this->user_id,'m.is_deleted'=>0,'m.module'=>'video','m.type_id'=>5])
  1760. ->alias('m')
  1761. ->leftJoin('VideoIntro v','v.id= m.relation_id')->count();
  1762. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1763. }
  1764. /**
  1765. * @title 点赞我的--视频
  1766. * @desc 点赞我的--视频
  1767. * @author qc
  1768. * @method GET
  1769. * @url /api/Video/praiseMyVideoList
  1770. * @header name:Authorization require:1 desc:Token
  1771. * @param name:page type:int default:-- desc:页数
  1772. * @param name:page_num type:int default:-- desc:每页数
  1773. *
  1774. * @return name:id type:int default:-- desc:记录id
  1775. * @return name:title type:string default:-- desc:标题
  1776. * @return name:series_title type:string default:-- desc:系列标题
  1777. * @return name:create_at type:string default:-- desc:时间
  1778. * @return name:read_num type:int default:-- desc:播放量
  1779. * @return name:user_name type:string default:-- desc:会员名称
  1780. * @return name:headimg type:string default:-- desc:会员头像
  1781. * @return name:cover type:string default:-- desc:封面
  1782. * @return name:duration type:string default:-- desc:时长
  1783. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1784. * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  1785. *
  1786. */
  1787. public function praiseMyVideoList()
  1788. {
  1789. // 我的视频
  1790. $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1791. $user_info = $this->userInfo('name,headimg');
  1792. $list = VideoCommentLike::where([['l.type','=',2],['l.like_id','in',$all_video],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1793. ->alias('l')
  1794. ->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')
  1795. ->leftJoin('StoreMember m','m.id = l.user_id')
  1796. ->leftJoin('VideoUrl v','v.id = l.like_id')
  1797. ->leftJoin('VideoIntro x','x.id = v.video_id')
  1798. ->limit($this->off_set,$this->page_num)
  1799. ->select()->toArray();
  1800. array_walk($list,function (&$v,$k)use ($user_info){
  1801. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['like_id'],$this->request->controller());
  1802. $v['app_name'] = $user_info['name'] ;
  1803. $v['app_logo'] = $user_info['headimg'];
  1804. $v['read_num'] = numTransform($v['read_num']);
  1805. });
  1806. $total_num = VideoCommentLike::where([['type','=',2],['like_id','in',$all_video],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1807. ->alias('l')
  1808. ->leftJoin('StoreMember m','m.id = l.user_id')
  1809. ->leftJoin('VideoUrl v','v.id = l.like_id')
  1810. ->count();
  1811. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1812. }
  1813. /**
  1814. * @title 点赞我的--评论
  1815. * @desc 点赞我的--评论
  1816. * @author qc
  1817. * @method GET
  1818. * @url /api/Video/praiseMyComment
  1819. * @header name:Authorization require:1 desc:Token
  1820. * @param name:page type:int default:-- desc:页数
  1821. * @param name:page_num type:int default:-- desc:每页数
  1822. *
  1823. * @return name:id type:int default:-- desc:记录id
  1824. * @return name:title type:string default:-- desc:标题
  1825. * @return name:series_title type:string default:-- desc:系列标题
  1826. * @return name:create_at type:string default:-- desc:时间
  1827. * @return name:read_num type:int default:-- desc:播放量
  1828. * @return name:user_name type:string default:-- desc:会员名称
  1829. * @return name:headimg type:string default:-- desc:会员头像
  1830. * @return name:cover type:string default:-- desc:封面
  1831. * @return name:duration type:string default:-- desc:时长
  1832. * @return name:content type:string default:-- desc:内容
  1833. * @return name:like_id type:int default:-- desc:评论id
  1834. * @return name:is_normal type:int default:-- desc:是否是正常记录(0已删除或是已禁用1可以正常跳转详情)
  1835. * @return name:comment_switch type:int default:-- desc:评论开关【0关闭1开启】
  1836. */
  1837. public function praiseMyComment()
  1838. {
  1839. $user_info = $this->userInfo('name,headimg');
  1840. $list = VideoCommentLike::where([['l.type','=',1],['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1841. ->alias('l')
  1842. ->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')
  1843. ->leftJoin('StoreMember m','m.id = l.user_id')
  1844. ->leftJoin('VideoComment c','c.id = l.like_id')
  1845. ->leftJoin('VideoUrl v','v.id = c.url_id')
  1846. ->leftJoin('VideoIntro x','x.id = v.video_id')
  1847. ->order('l.id desc')
  1848. ->limit($this->off_set,$this->page_num)
  1849. ->select()->toArray();
  1850. array_walk($list,function (&$v,$k)use ($user_info){
  1851. $v['is_normal'] = CheckPower::checkModulesPower($v['video_id'],$v['url_id'],$this->request->controller());
  1852. $v['app_name'] = $user_info['name'] ;
  1853. $v['app_logo'] = $user_info['headimg'];
  1854. $v['read_num'] = numTransform($v['read_num']);
  1855. });
  1856. $total_num = VideoCommentLike::where([['l.type','=',1],['c.user_id','=',$this->user_id],['l.to_deleted','=',0],['l.user_id','<>',$this->user_id]])
  1857. ->alias('l') ->leftJoin('StoreMember m','m.id = l.user_id')
  1858. ->leftJoin('VideoComment c','c.id = l.like_id')
  1859. ->leftJoin('VideoUrl v','v.id = c.url_id')->count();
  1860. $this->success('ok',['list'=>$list,'total_count'=>$total_num,'page_num'=>$this->page_num]);
  1861. }
  1862. /**
  1863. * @title 消息已读&&未读变更
  1864. * @desc 支持批量选择
  1865. * @author qc
  1866. * @method POST
  1867. * @url /api/Video/unreadChange
  1868. * eadChange
  1869. * @header name:Authorization require:1 desc:Token
  1870. * @param name:id type:string default:-- desc:记录id(多个逗号隔开,不传修改全部])
  1871. * @param name:type type:string default:1 desc:消息类型【1评论我的,2回复我的,3追番消息,4点赞我的--视频,5点赞我的--评论】
  1872. * @param name:is_read type:int default:1 desc:变更类型【0消息变更为未读,1变更为已读】
  1873. */
  1874. public function unreadChange()
  1875. {
  1876. $type = input('post.type',1);
  1877. $id = input('post.id');
  1878. $where = [];
  1879. switch ($type) {
  1880. case 1:
  1881. VideoComment::where([['i.user_id','=',$this->user_id],['t.pid','=',0]])
  1882. ->when($id ,function ($query)use ($id){
  1883. if($id) return $query->where('t.id','in',$id);
  1884. })->leftJoin('VideoUrl i','t.url_id = i.id')
  1885. ->alias('t') ->update(['is_read'=>input('post.is_read')]);
  1886. break;
  1887. case 2:
  1888. $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1889. VideoComment::where([['t.pid','in',implode(',',$all_comment)]])
  1890. ->when($id ,function ($query)use ($id){
  1891. if($id) return $query->where('t.id','in',$id);
  1892. })->alias('t')->update(['is_read'=>input('post.is_read')]);
  1893. break;
  1894. case 3:
  1895. $where[] = ['user_id','=',$this->user_id];
  1896. if($id) $where[] = ['id','in',$id];
  1897. UserMessage::where($where)->update(['is_read'=>input('post.is_read')]);
  1898. break;
  1899. case 4:
  1900. $all_video = VideoUrl::where('user_id',$this->user_id)->where('is_deleted',0)->column('id');
  1901. VideoCommentLike::where([['type','=',2],['is_read','=',0],['like_id','in',$all_video]])->update(['is_read'=>1]);
  1902. break;
  1903. case 5:
  1904. $all_comment = VideoComment::where(['user_id'=>$this->user_id,'is_deleted'=>0])->column('id');
  1905. VideoCommentLike::where([['type','=',1],['is_read','=',0],['like_id','in',$all_comment]])->update(['is_read'=>1]);
  1906. break;
  1907. }
  1908. $this->success('消息变更成功');
  1909. }
  1910. /**
  1911. * @title 批量删除||批量取消
  1912. * @desc 删除||取消
  1913. * @author qc
  1914. * @method POST
  1915. * @url /api/Video/batchesDel
  1916. * @header name:Authorization require:1 desc:Token
  1917. * @param name:id type:string default:1 desc:记录id【多个用逗号隔开=>'1,2'】
  1918. * @param name:type type:string default:1 desc:消息类型【1我的评论,2评论我的,3我的回复,4我的已购,5用户视频删除,6追番记录,7追番消息,8我的点赞-视频,9我的点赞-评论,10回复我的,11点赞我的--视频,12点赞我的--评论,13我的收藏】
  1919. */
  1920. public function batchesDel(){
  1921. $type = input('post.type',1);
  1922. $del_where = [];
  1923. $del_where[] = ['id','in',input('post.id')];
  1924. if(in_array($type,[1,3,4,5,6,7,8,9])) $del_where[] = ['user_id','=',$this->user_id];
  1925. if(in_array($type,[1,3])) VideoComment::where($del_where)->update(['is_deleted'=>1]);
  1926. if(in_array($type,[2])) VideoComment::where($del_where)->update(['source_deleted'=>1,'source_read'=>1,'is_read'=>1]);
  1927. if(in_array($type,[10])) VideoComment::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1928. if(in_array($type,[4])) UserLearn::where($del_where)->update(['is_deleted'=>1]);
  1929. if(in_array($type,[5])) UserVideo::where($del_where)->update(['is_deleted'=>1]);
  1930. if(in_array($type,[6])) PlatformSwitch::where($del_where)->delete();
  1931. if(in_array($type,[7])) UserMessage::where($del_where)->update(['is_deleted'=>1]);
  1932. if(in_array($type,[8,9])) VideoCommentLike::where($del_where)->delete();
  1933. if(in_array($type,[11,12])) VideoCommentLike::where($del_where)->update(['to_deleted'=>1,'is_read'=>1]);
  1934. if(in_array($type,[13])) UserCollect::where($del_where)->delete();
  1935. $this->success('操作成功');
  1936. }
  1937. }