Livepk.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <?php
  2. namespace App\Model;
  3. use PhalApi\Model\NotORMModel as NotORM;
  4. class Livepk extends NotORM {
  5. /* 直播中用户列表 */
  6. public function getLiveList($uid,$where,$p) {
  7. if($p<1){
  8. $p=1;
  9. }
  10. $pnum=50;
  11. $start=($p-1)*$pnum;
  12. $list=\PhalApi\DI()->notorm->user_live
  13. ->select('uid,stream,pkuid,starttime')
  14. ->where('islive=1 and isvideo=0')
  15. ->where($where)
  16. ->order('starttime desc')
  17. ->limit($start,$pnum)
  18. ->fetchAll();
  19. foreach($list as $k=>$v){
  20. $userinfo=\App\getUserInfo($v['uid']);
  21. $v['avatar']=$userinfo['avatar'];
  22. $v['avatar_thumb']=$userinfo['avatar_thumb'];
  23. $v['user_nickname']=$userinfo['user_nickname'];
  24. $list[$k]=$v;
  25. }
  26. return $list;
  27. }
  28. /* 直播中用户列表 */
  29. public function checkLive($stream) {
  30. $isexist=\PhalApi\DI()->notorm->user_live
  31. ->select('uid')
  32. ->where('islive=1 and isvideo=0 and stream=?',$stream)
  33. ->fetchOne();
  34. if($isexist){
  35. return true;
  36. }
  37. return false;
  38. }
  39. /* 更新连麦用户信息 */
  40. public function changeLive($uid,$pkuid,$type) {
  41. if($type == 1){
  42. /* 连麦 */
  43. $uid_live=\PhalApi\DI()->notorm->user_live
  44. ->select('uid,stream,pkuid')
  45. ->where('islive=1 and isvideo=0 and uid=?',$uid)
  46. ->fetchOne();
  47. $pkuid_live=\PhalApi\DI()->notorm->user_live
  48. ->select('uid,stream,pkuid')
  49. ->where('islive=1 and isvideo=0 and uid=?',$pkuid)
  50. ->fetchOne();
  51. if($uid_live && $pkuid_live && $uid_live['pkuid']==0 && $pkuid_live['pkuid']==0){
  52. \PhalApi\DI()->notorm->user_live
  53. ->where(" uid={$uid} ")
  54. ->update( array('pkuid'=>$pkuid_live['uid'],'pkstream'=>$pkuid_live['stream']) );
  55. \PhalApi\DI()->notorm->user_live
  56. ->where(" uid={$pkuid} ")
  57. ->update( array('pkuid'=>$uid_live['uid'],'pkstream'=>$uid_live['stream']) );
  58. }
  59. }else{
  60. /* 断麦 */
  61. \PhalApi\DI()->notorm->user_live
  62. ->where(" uid={$uid} or pkuid={$uid}")
  63. ->update( array('pkuid'=>0,'pkstream'=>'') );
  64. }
  65. return true;
  66. }
  67. }