147 lines
5.8 KiB
PHP
147 lines
5.8 KiB
PHP
<?php
|
||
|
||
namespace app\api\controller;
|
||
|
||
use app\common\controller\BaseCom;
|
||
use think\Db;
|
||
|
||
class RoomPit extends BaseCom
|
||
{
|
||
//申请上麦
|
||
public function apply_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$pit_number = input('pit_number', 0);
|
||
if($room_id == 0){
|
||
return V(0, '房间ID不能为空', null);
|
||
}
|
||
$res = model('Room')->get_room_label($room_id);
|
||
if($res['code'] != 1){
|
||
return V(0, '房间不存在', null);
|
||
}
|
||
// //查询房间主持麦有人吗
|
||
// $room_host_info = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => 9])->value('user_id');
|
||
// //房主,管理,主持不受此限制
|
||
// $room_owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $this->uid])->find();
|
||
// //管理
|
||
// $room_manager = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 2,'delete_time' => null])->find();
|
||
// //主持
|
||
// $room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $this->uid,'type' => 1,'delete_time' => null])->find();
|
||
// if($room_host_info == 0 && !$room_owner && !$room_manager && !$room_host){
|
||
// return V(0, '上麦请联系主持', null);
|
||
// }
|
||
$room_label = $res['data']['label_id'];
|
||
$room_type = $res['data']['type_id'];
|
||
|
||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4))|| $room_type == 2 || $room_type == 7){
|
||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||
}else{
|
||
return V(0, '房间不存在', null);
|
||
}
|
||
//1-禁麦位,2-清空消息,3-清空魅力值,4-加入黑名单,5-踢出房间,6-关闭麦克风,7-申请上麦,8-同意上麦,9-拒绝上麦,10-点歌,11-开启PK',
|
||
model('Room')->room_operation_record($this->uid,$room_id,7,0,$pit_number);
|
||
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//申请上麦列表
|
||
public function apply_pit_list()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//上麦助力
|
||
public function help_apply_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$user_id = input('user_id', 0);
|
||
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//同意上麦
|
||
public function agree_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$user_id = input('user_id', 0);//逗号分割
|
||
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//拒绝上麦
|
||
public function refuse_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$user_id = input('user_id', 0);//逗号分割
|
||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id, $user_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//清空上麦申请列表
|
||
public function clear_apply_pit_list()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//设置房间插麦礼物
|
||
public function set_room_pit_apply_help_gift()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$gift_id = input('gift_id', 0);
|
||
$gift_price = input('gift_price', 0);
|
||
$reslut = model('RoomPit')->set_room_pit_apply_help_gift($this->uid, $room_id, $gift_id, $gift_price);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//下麦
|
||
public function down_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$pit_number = input('pit_number', 0);
|
||
if($room_id == 0){
|
||
return V(0, '房间ID不能为空', null);
|
||
}
|
||
$res = model('Room')->get_room_label($room_id);
|
||
if($res['code'] != 1){
|
||
return V(0, '房间不存在', null);
|
||
}
|
||
$room_label = $res['data']['label_id'];
|
||
$room_type = $res['data']['type_id'];
|
||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4)) || $room_type == 2){
|
||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||
}
|
||
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//修改房间上麦模式
|
||
public function change_room_up_pit_type()
|
||
{
|
||
$key_name = "api:room:change_room_up_pit_type:" . $this->uid;
|
||
redis_lock_exit($key_name);
|
||
$room_id = input('room_id', 0);
|
||
// $user_id = input('user_id', 0);
|
||
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
|
||
redis_unlock($key_name);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
|
||
//抱麦/踢麦
|
||
public function host_user_pit()
|
||
{
|
||
$room_id = input('room_id', 0);
|
||
$pit_number = input('pit_number', 0);
|
||
$user_id = input('user_id', 0);//
|
||
$type = input('type', 0);//1-抱麦 2-踢下去
|
||
$reslut = model('RoomPit')->host_user_pit($this->uid, $room_id,$pit_number,$user_id,$type);
|
||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||
}
|
||
} |