VideoEndAction.class.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Fanwe 方维直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class VideoEndAction extends CommonAction{
  10. //直播结束列表
  11. public function endline_index()
  12. {
  13. $now=get_gmtime();
  14. if(strim($_REQUEST['nick_name'])!=''){//name
  15. $user=M("User")->where("nick_name like '%".strim($_REQUEST['nick_name'])."%' ")->findAll();
  16. $user_arr_id = array();
  17. foreach($user as $k=>$v){
  18. $user_arr_id[$k] =intval($v['id']);
  19. }
  20. //$user_str_id = implode(',',$user_arr_id);
  21. $map['user_id'] = array('in',$user_arr_id);
  22. }
  23. if(intval($_REQUEST['cate_id'])>0)
  24. {
  25. $map['cate_id'] = intval($_REQUEST['cate_id']);
  26. }
  27. if(intval($_REQUEST['room_id'])>0)
  28. {
  29. $map['id'] = intval($_REQUEST['room_id']);
  30. }
  31. if(intval($_REQUEST['user_id'])>0)
  32. {
  33. $map['user_id'] = intval($_REQUEST['user_id']);
  34. }
  35. $create_time_2=empty($_REQUEST['create_time_2'])?to_date($now,'Y-m-d'):strim($_REQUEST['create_time_2']);
  36. $create_time_2=to_timespan($create_time_2)+24*3600;
  37. if(trim($_REQUEST['create_time_1'])!='')
  38. {
  39. $map['create_time'] = array('between',array(to_timespan($_REQUEST['create_time_1']),$create_time_2));
  40. }
  41. //$map['live_in'] = 0;
  42. if (method_exists ( $this, '_filter' )) {
  43. $this->_filter ( $map );
  44. }
  45. //$name=$this->getActionName();
  46. $model = D ('VideoHistory');
  47. if (! empty ( $model )) {
  48. $this->_list ( $model, $map );
  49. }
  50. $list = $this->get("list");
  51. foreach($list as &$v){
  52. if(function_exists('time_len')) {
  53. $v['len_time'] = time_len(intval($v['len_time']));
  54. }
  55. $v['pay_editable'] = 0;
  56. if (defined('OPEN_LIVE_PAY') && OPEN_LIVE_PAY == 1 && defined('OPEN_EDIT_VIDEO_PAY') && OPEN_EDIT_VIDEO_PAY == 1) {
  57. $v['pay_editable'] = 1;
  58. if ($v['is_live_pay'] == 1 && $v['live_pay_type'] == 0) {
  59. $v['pay_editable'] = 0;
  60. }
  61. }
  62. }
  63. $this->assign ( 'list', $list );
  64. //print_r($list);exit;
  65. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  66. $this->assign ( 'is_pay_live', 1 );
  67. }else{
  68. $this->assign ( 'is_pay_live', 0 );
  69. }
  70. $cate_list = M("VideoCate")->findAll();
  71. $this->assign("cate_list",$cate_list);
  72. $this->display ();
  73. }
  74. /**
  75. * 印票贡献榜
  76. */
  77. public function contribution_list()
  78. {
  79. $video_id = intval($_REQUEST['id']);
  80. $video = M("VideoHistory")->getById($video_id);
  81. $this->assign("video",$video);
  82. $user="select prop_table from ".DB_PREFIX."video_history where id=$video_id";
  83. $userlist=$GLOBALS['db']->getOne($user,true,true);
  84. if(defined('OPEN_LIVE_PAY')&&OPEN_LIVE_PAY==1){
  85. $prop = "select u.id as user_id ,u.nick_name,u.head_image,sum(v.total_diamonds) as num,sum(v.total_ticket) as total_ticket
  86. from $userlist as v LEFT JOIN ".DB_PREFIX."user as u on u.id = v.from_user_id
  87. where v.video_id=".$video_id." and prop_id<>12 GROUP BY v.from_user_id order BY sum(v.total_diamonds)";
  88. $proplist=$GLOBALS['db']->getAll($prop,true,true);
  89. $pay = "select u.id as user_id ,u.nick_name,u.head_image,sum(v.total_diamonds) as num,sum(v.total_ticket) as total_ticket
  90. from ".DB_PREFIX."live_pay_log_history as v
  91. LEFT JOIN ".DB_PREFIX."user as u
  92. on u.id = v.from_user_id
  93. where v.video_id=".$video_id."
  94. GROUP BY u.nick_name order BY sum(v.total_diamonds)";
  95. $paylist=$GLOBALS['db']->getAll($pay,true,true);
  96. $list_arr=array_merge($proplist,$paylist);
  97. $list=array();
  98. foreach($list_arr as $k=>$v){
  99. if(!isset($list[$v['user_id']])){
  100. $list[$v['user_id']]=$v;
  101. }else{
  102. $list[$v['user_id']]['num']+=$v['num'];
  103. $list[$v['user_id']]['total_ticket']+=$v['total_ticket'];
  104. }
  105. }
  106. }else{
  107. $prop = "select u.id as user_id ,u.nick_name,u.head_image,sum(v.total_diamonds) as num,sum(v.total_ticket) as total_ticket
  108. from $userlist as v LEFT JOIN ".DB_PREFIX."user as u on u.id = v.from_user_id
  109. where v.video_id=".$video_id." and prop_id<>12 GROUP BY v.from_user_id order BY sum(v.total_diamonds)";
  110. $list=$GLOBALS['db']->getAll($prop,true,true);
  111. }
  112. foreach($list as $k=>$v){
  113. $list[$k]['total_ticket'] =floatval($list[$k]['total_ticket']);
  114. $list[$k]['head_image']= get_spec_image($v['head_image']);
  115. $list[$k]['nick_name'] = emoji_decode($v['nick_name']);
  116. }
  117. $count=count($list);
  118. $p = new Page($count, $listRows = 20);
  119. $this->assign("list",$list);
  120. $this->assign("page", $p->show());
  121. $this->display();
  122. // if($video)
  123. // {
  124. // $page = intval($_REQUEST['p']);
  125. // if($page<=0)
  126. // $page = 1;
  127. // $map['video_id'] = $video['id'];
  128. // $map['user_id'] = $video['user_id'];
  129. // require_once APP_ROOT_PATH."/admin/Lib/Action/RedisCommon.class.php";
  130. // $redisCommon = new Ridescommon();
  131. // $redis = $redisCommon->video_contribute_list($map['user_id'],$map['video_id'],0,$page);
  132. // $model = D ("VideoContributionHistory");
  133. // if (! empty ( $model )) {
  134. // $this->_list ( $model, $map,'','',1,$redis);
  135. // }
  136. //
  137. // /*$map['video_id'] = $video['id'];
  138. // $model = D ("VideoContributionHistory");
  139. // if (! empty ( $model )) {
  140. // $this->_list ( $model, $map );
  141. // }*/
  142. // }
  143. }
  144. /**
  145. * 删除印票贡献榜
  146. */
  147. public function del_contribution_list()
  148. {
  149. $ajax = intval($_REQUEST['ajax']);
  150. $id = $_REQUEST ['id'];
  151. if (isset ( $id )) {
  152. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  153. $rel_data = M("VideoContributionHistory")->where($condition)->findAll();
  154. foreach($rel_data as $data)
  155. {
  156. $deal_id = $data['video_id'];
  157. $info[] = $data['id'];
  158. }
  159. if($info) $info = implode(",",$info);
  160. $info = "视频ID".$deal_id."的印票贡献榜:".$info;
  161. $list = M("VideoContributionHistory")->where ( $condition )->delete();
  162. if ($list!==false) {
  163. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  164. $this->success (l("FOREVER_DELETE_SUCCESS"),$ajax);
  165. } else {
  166. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  167. $this->error (l("FOREVER_DELETE_FAILED"),$ajax);
  168. }
  169. } else {
  170. $this->error (l("INVALID_OPERATION"),$ajax);
  171. }
  172. }
  173. //检查视频
  174. public function check_video(){
  175. $id = $_REQUEST['id'];
  176. $condition['id'] = $id;
  177. $video = M('VideoHistory')->where($condition)->find();
  178. if(!empty($video)){
  179. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/BaseRedisService.php');
  180. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/VideoRedisService.php');
  181. require_once APP_ROOT_PATH."/mapi/lib/core/common.php";
  182. if (defined('UPLOAD_OSS') && UPLOAD_OSS == 1)
  183. {
  184. $ret = array();
  185. $ret['total_count'] = 0;
  186. $bucket = $GLOBALS['distribution_cfg']['OSS_BUCKET_NAME'];
  187. $sql = "select play_url from ".DB_PREFIX."video_history where id = ".$id;
  188. $url = $GLOBALS['db']->getOne($sql,true,true);
  189. if($url)
  190. {
  191. $pathinfo = parse_url($url);
  192. $object = ltrim($pathinfo['path'],'/');
  193. require_once APP_ROOT_PATH."system/alioss/sdk.class.php";
  194. $oss_sdk_service = new ALIOSS();
  195. $info = (array)$oss_sdk_service->is_object_exist($bucket,$object);
  196. if ($info['status']==200)
  197. {
  198. $ret['total_count'] = 1;
  199. }
  200. }
  201. }
  202. else
  203. {
  204. $ret = get_vodset_by_video_id($id);
  205. }
  206. if ($ret['total_count'] > 0){
  207. //视频存在
  208. $sql = "update ".DB_PREFIX."video_history set is_del_vod = 0 where id = ".$video['id'];
  209. $GLOBALS['db']->query($sql);
  210. $video_redis = new VideoRedisService();
  211. $data = array();
  212. $data['is_del_vod'] = 0;
  213. $video_redis->update_db($video['id'], $data);
  214. $result['status'] = 1;
  215. $result['info'] = '视频存在';
  216. }else{
  217. $result['status'] = 0;
  218. $result['info'] = '视频不存在';
  219. }
  220. }else{
  221. $result['status'] = 0;
  222. $result['info'] = '直播记录不存在';
  223. }
  224. admin_ajax_return($result);
  225. }
  226. //删除直播记录
  227. public function delete(){
  228. $ajax = intval($_REQUEST['ajax']);
  229. $id = $_REQUEST['id'];
  230. $result['status'] = 0;
  231. if (isset ( $id )) {
  232. $condition = array ('id' => array ('in', explode ( ',', $id ) ) );
  233. $rel_data = M('VideoHistory')->where($condition)->findAll();
  234. $url_str = '';
  235. foreach($rel_data as $data)
  236. {
  237. if($data['video_vid']!='' && $data['is_del_vod']==0 && $data['is_delete']==0){//判断是否存在视频文件
  238. if($url_str!=''){
  239. $url_str.=',';
  240. }
  241. $url_str.=$data['id'];
  242. }
  243. $info[] = $data['id'];
  244. $forbid_del[] = $data['group_id'];
  245. }
  246. if($url_str!=''){
  247. $result['info'] = $url_str."存在视频文件,请先到回播列表删除视频文件!";
  248. }else{
  249. if($info) $info = implode(",",$info);
  250. $list = M('VideoHistory')->where ( $condition )->delete();
  251. if ($list!==false) {
  252. $del_condition = array ('video_id' => array ('in', explode ( ',', $id ) ) );
  253. //删除对应印票贡献
  254. M('VideoContributionHistory')->where ( $del_condition )->delete();
  255. //删除redis印票贡献
  256. //删除禁言记录
  257. $forbid_condition = array ('group_id' => array ('in', $forbid_del ) );
  258. M('VideoForbidSendMsg')->where ( $forbid_condition )->delete();
  259. //删除举报记录
  260. M('Tipoff')->where ( $del_condition )->delete();
  261. //删除连麦记录
  262. M('VideoLianmaiHistory')->where ( $del_condition )->delete();
  263. //删除主播心跳监听
  264. M('VideoMonitorHistory')->where ( $del_condition )->delete();
  265. //删除私聊邀请好友
  266. M('VideoPrivateHistory')->where ( $del_condition )->delete();
  267. //删除送礼记录
  268. M('VideoPropHistory')->where ( $del_condition )->delete();
  269. //删除用户抢到红包记录
  270. M('VideoRedEnvelopeHistory')->where ( $del_condition )->delete();
  271. //删除会员分享记录
  272. M('VideoShareHistory')->where ( $del_condition )->delete();
  273. //删除直播观众记录
  274. M('VideoViewerHistory')->where ( $del_condition )->delete();
  275. //删除虚拟人数计划
  276. $vir_condition = array ('room_id' => array ('in', explode ( ',', $id ) ) );
  277. M('VideoVirtual')->where ( $vir_condition )->delete();
  278. save_log($info.l("FOREVER_DELETE_SUCCESS"),1);
  279. clear_auto_cache("get_help_cache");
  280. $result['info'] = $url_str."删除成功!";
  281. $result['status'] = 1;
  282. } else {
  283. save_log($info.l("FOREVER_DELETE_FAILED"),0);
  284. $result['info'] = $url_str."删除失败!";
  285. }
  286. }
  287. } else {
  288. $result['info'] = '编号错误';
  289. }
  290. admin_ajax_return($result);
  291. }
  292. }
  293. ?>