diff --git a/application/adminapi/controller/User.php b/application/adminapi/controller/User.php index 6015929e..af6d76dc 100644 --- a/application/adminapi/controller/User.php +++ b/application/adminapi/controller/User.php @@ -9,6 +9,7 @@ use think\Db; use think\Hook; use think\Session; use think\Validate; +use app\common\library\Token as TokenLib; /** * 后台首页 @@ -272,6 +273,9 @@ class User extends adminApi Db::name('block')->where($map)->delete(); Db::name('sms_error')->where(['mobile' => $user_info['mobile']])->delete(); } + $token = db::name('user_token')->where('user_id', $user_id)->value('token'); + // 删除这个Token,使其失效 + TokenLib::delete($token); return V(1,"成功", null); } diff --git a/application/api/model/Friend.php b/application/api/model/Friend.php index 580d71fe..a98f9475 100644 --- a/application/api/model/Friend.php +++ b/application/api/model/Friend.php @@ -123,6 +123,7 @@ class Friend extends Model }else{ // 修改当前交友阶段 db::name('vs_room')->where(['id' => $room_id])->update(['step' => $step,'updatetime' => time()]); + db::name('vs_user_friending')->where(['id' => $id])->update(['update_time' => time()]); } }else{ $step = 1;//结束下一轮 diff --git a/application/api/model/RoomSong.php b/application/api/model/RoomSong.php index ff9c936d..67053ddf 100644 --- a/application/api/model/RoomSong.php +++ b/application/api/model/RoomSong.php @@ -175,7 +175,7 @@ class RoomSong extends Model public function song($room_id,$user_id,$song_code,$song_name,$singer,$poster,$duration){ $action = 0;//初始值,1-申请点歌,2-切歌,3-下一首歌曲变化,4-拒绝申请点歌 //查询当前房间中的场次状态 - $times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('did desc')->find(); + $times_status = db::name('vs_room_song')->where('room_id',$room_id)->field('times,times_status')->order('sort desc')->find(); if(!empty($times_status)){//已经有歌曲 if($times_status['times_status'] == 2){//这一场次结束了 $data['sort'] = 10000;//排序,新场次第一首歌 @@ -261,13 +261,16 @@ class RoomSong extends Model //把这个信息存储到redis Cache::set("api:room:song:nextInfo:" . $room_id, $did); } - $text = [ - 'action' => $action, - 'total' => $total, - 'songInfo' => $nowInfo, - 'nextInfo' => $nextInfo - ]; - model('Chat')->sendMsg(1013,$room_id,$text); + if($action){ + $text = [ + 'action' => $action, + 'total' => $total, + 'songInfo' => $nowInfo, + 'nextInfo' => $nextInfo + ]; + model('Chat')->sendMsg(1013,$room_id,$text); + } + //1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK', model('Room')->room_operation_record($user_id,$room_id,10,0,0,$did); return ['code'=>1,'msg'=>'申请成功','data'=>null]; @@ -328,6 +331,7 @@ class RoomSong extends Model if($sort_up[0]['did'] == $room_song_id){ return ['code'=>0,'msg'=>'已经是第一首歌了','data'=>null]; } + if($type == 1){ //上移 foreach ($sort_up as $k=>$v){ if($v['did'] == $room_song_id){ @@ -347,8 +351,61 @@ class RoomSong extends Model if(!$res){ return ['code'=>0,'msg'=>'操作失败','data'=>null]; } + $data = db::name('vs_room_song')->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1]) ->order('sort desc')->select(); + + //查询当前是否有正在演唱的歌曲 + $now_room_song = db::name('vs_room_song') ->where('room_id',$sort['room_id']) + ->where('times',$sort['times']) + ->where('status',2) + ->find(); + if(empty($now_room_song)){ + $total = db::name('vs_room_song') + ->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1]) + ->count(); + $nowInfo = [ + 'did' => $data[0]['did'], + 'song_code' => $data[0]['song_code'], + 'song_name' => $data[0]['song_name'], + 'singer' => $data[0]['singer'], + 'poster' => $data[0]['poster'], + 'duration' => $data[0]['duration'], + 'user_id' => $data[0]['user_id'], + 'dress' => model('Decorate')->user_decorate_detail($data[0]['user_id'], 1), + 'nickname' => db::name('user')->where('id',$data[0]['user_id'])->value('nickname'), + 'avatar' => db::name('user')->where('id',$data[0]['user_id'])->value('avatar'), + 'charm' => db::name('vs_room_user_charm')->where(['user_id' => $data[0]['user_id'],'room_id' => $sort['room_id']])->value('charm'), + ]; + if(isset($data[1]['did'])){ + $nextInfo = [ + 'did' => $data[1]['did'], + 'song_code' => $data[1]['song_code'], + 'song_name' => $data[1]['song_name'], + 'singer' => $data[1]['singer'], + 'poster' => $data[1]['poster'], + 'duration' => $data[1]['duration'], + 'user_id' => $data[1]['user_id'], + 'dress' => model('Decorate')->user_decorate_detail($data[1]['user_id'], 1), + 'nickname' => db::name('user')->where('id',$data[1]['user_id'])->value('nickname'), + 'avatar' => db::name('user')->where('id',$data[1]['user_id'])->value('avatar'), + 'charm' => db::name('vs_room_user_charm')->where(['user_id' =>$data[1]['user_id'],'room_id' => $sort['room_id']])->value('charm'), + ]; + }else{ + $nextInfo = null; + } + + $text = [ + 'action' => 2, + 'total' => $total, + 'songInfo' => $nowInfo, + 'nextInfo' => $nextInfo + ]; + model('Chat')->sendMsg(1013,$sort['room_id'],$text); + Cache::set("api:room:song:nextInfo:" . $sort['room_id'],$data[0]['did']); + return ['code'=>1,'msg'=>'操作成功','data'=>$data]; + } + $did = Cache::get("api:room:song:nextInfo:" . $sort['room_id']); //歌曲移动后,下一首播放歌曲信息 发生改变 推送给前端 if($data[0]['did'] != $did){ diff --git a/application/api/model/UserMessage.php b/application/api/model/UserMessage.php index 694fd0d5..84a493c7 100644 --- a/application/api/model/UserMessage.php +++ b/application/api/model/UserMessage.php @@ -142,6 +142,7 @@ class UserMessage extends Model //获取消息 $list = db::name('system_message') + ->field('id,type,title,content,url,admin_id,image,createtime,room_id,user_id,remind_type,status,updatetime') ->where($where) ->where('FIND_IN_SET(:user_id, receiving_id)', ['user_id' => $uid]) ->order('id desc')