k歌房 有已点歌曲 但是没有正在演唱的歌 置顶解决
This commit is contained in:
@@ -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){
|
||||
|
||||
Reference in New Issue
Block a user