歌曲置顶切歌处理

This commit is contained in:
2026-01-16 10:14:33 +08:00
parent b0b6ef72a5
commit 91d19f413a

View File

@@ -386,21 +386,25 @@ class RoomSong extends Model
$fa_zhi = 0;
}else{ //置顶
$sort_ups = $sort_up[0]['did'];
foreach ($sort_up as $k=>$v){
if($v['status'] == 2){
$now_room_song = 1;
}
}
$now_room_song = db::name('vs_room_song')
->where(['room_id' => $sort['room_id'],'status' => 2,'times' =>$sort['times'],'times_status' => 1])
->find() ? 1 : 0;
$fa_zhi = 9;//阈值 为了防止置顶后被上移歌曲覆盖
}
//获取现在正在排队的第一的排序号
$sortt = db::name('vs_room_song')->where('did',$sort_ups)->value('sort');
$sort_upp = $sortt + 1 + $fa_zhi;
$sort_upp = $sortt + 1 + $fa_zhi;//计算需要挪动的歌曲的排序号并修改它
$res = db::name('vs_room_song')->where('did',$room_song_id)->update(['sort'=>$sort_upp]);
if(!$res){
return ['code'=>0,'msg'=>'操作失败','data'=>null];
}
if(!$now_room_song){
//移动后重新按照排序查找歌曲新排序
$sort_up = db::name('vs_room_song')
->where(['room_id' => $sort['room_id'],'status' => 1,'times' =>$sort['times'],'times_status' => 1])
->field('did,status,song_code,song_name,singer,poster,duration,user_id')->order('sort desc')->select();
if(!$now_room_song){//没有正在演唱的歌曲
$total = db::name('vs_room_song')
->where(['room_id' => $sort['room_id'],'status' => 1,'times_status' => 1])
->count();