酒吧房相关
This commit is contained in:
@@ -122,6 +122,9 @@ class Room extends BaseCom
|
||||
public function before_join_room_check()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->before_join_room_check($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -157,7 +160,6 @@ class Room extends BaseCom
|
||||
return V(0, '内侧房间,不可访问');
|
||||
}
|
||||
|
||||
|
||||
$reslut = model('Room')->join_room($this->uid, $room_id, $password);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -166,6 +168,9 @@ class Room extends BaseCom
|
||||
public function quit_room()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if(!$room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->quit_room($this->uid, $room_id,$user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -231,6 +236,9 @@ class Room extends BaseCom
|
||||
public function room_online_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$page = input('page', 1);
|
||||
$limit = input('limit', 15);
|
||||
$reslut = model('Room')->room_online_list($room_id, $page, $limit);
|
||||
@@ -241,6 +249,9 @@ class Room extends BaseCom
|
||||
public function room_user_home()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
$reslut = model('Room')->room_user_home($this->uid,$room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -315,7 +326,7 @@ class Room extends BaseCom
|
||||
public function change_room_type()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约
|
||||
$type = input('type', 1);//1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
||||
$reslut = model('Room')->change_room_type($this->uid, $room_id, $type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -341,6 +352,9 @@ class Room extends BaseCom
|
||||
public function room_info()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id){
|
||||
return V(0, '房间不存在');
|
||||
}
|
||||
$reslut = model('Room')->room_info($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -453,22 +467,7 @@ class Room extends BaseCom
|
||||
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$reslut = model('Room')->user_reconnect($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
$type = input('type', 1);//1-切后台,2-切前台
|
||||
$reslut = model('Room')->user_in_room_background($this->uid, $room_id,$type);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
|
||||
//给用户发送房间内消息
|
||||
public function send_room_message()
|
||||
|
||||
@@ -7,33 +7,38 @@ use think\Db;
|
||||
|
||||
class RoomPit extends BaseCom
|
||||
{
|
||||
|
||||
//申请上麦
|
||||
public function apply_pit()
|
||||
{
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
|
||||
$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){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$key_name = "api:room:apply_pit:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
redis_lock_exits($key_name);
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8))|| $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->apply_kpit($this->uid, $room_id,$pit_number);
|
||||
}elseif($room_type == 11){
|
||||
$gift_id = input('gift_id', 0);
|
||||
if($gift_id == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->apply_pit_bar($this->uid, $room_id,$gift_id,$pit_number);
|
||||
}else{
|
||||
redis_unlocks($key_name);
|
||||
return V(0, '房间不存在', null);
|
||||
$reslut = model('RoomPit')->apply_pit($this->uid, $room_id,$pit_number);
|
||||
}
|
||||
redis_unlocks($key_name);
|
||||
|
||||
//用户操作记录
|
||||
//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);
|
||||
|
||||
@@ -44,6 +49,9 @@ class RoomPit extends BaseCom
|
||||
public function apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -52,7 +60,13 @@ class RoomPit extends BaseCom
|
||||
public function help_apply_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择助力用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->help_apply_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -61,7 +75,13 @@ class RoomPit extends BaseCom
|
||||
public function agree_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$user_id = input('user_id', 0);//逗号分割
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择同意用户', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->agree_pit($this->uid, $room_id, $user_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -70,6 +90,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$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']);
|
||||
@@ -79,6 +102,9 @@ class RoomPit extends BaseCom
|
||||
public function clear_apply_pit_list()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->clear_apply_pit_list($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
@@ -87,7 +113,13 @@ class RoomPit extends BaseCom
|
||||
public function set_room_pit_apply_help_gift()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$gift_id = input('gift_id', 0);
|
||||
if($gift_id == 0){
|
||||
return V(0, '请选择礼物', null);
|
||||
}
|
||||
$gift_price = input('gift_price', 0);
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){
|
||||
@@ -101,26 +133,27 @@ class RoomPit extends BaseCom
|
||||
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){
|
||||
$pit_number = input('pit_number', 0);
|
||||
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 0){
|
||||
return V(0, '房间不存在', null);
|
||||
}
|
||||
$room_label = $res['data']['label_id'];
|
||||
$room_type = $res['data']['type_id'];
|
||||
|
||||
if($room_type == 10){
|
||||
$upit = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $this->uid])->value('pit_number');
|
||||
if($upit == 2){
|
||||
return V(0, '师父麦,不能操作', null);
|
||||
}
|
||||
}
|
||||
if(($room_label == 1 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)) || $room_type == 2 || $room_type == 7 || $room_type == 9 || $room_type == 10){
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4 || $room_type == 8)){
|
||||
|
||||
if($room_type == 2){
|
||||
$reslut = model('RoomSong')->down_kpit($this->uid, $room_id);
|
||||
}else{
|
||||
$reslut = model('RoomPit')->DownPit($this->uid, $room_id,$pit_number);
|
||||
}
|
||||
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -132,7 +165,10 @@ class RoomPit extends BaseCom
|
||||
$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);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
|
||||
$reslut = model('RoomPit')->change_room_up_pit_type($this->uid, $room_id);
|
||||
redis_unlock($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
@@ -142,8 +178,14 @@ class RoomPit extends BaseCom
|
||||
public function host_user_pit()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$pit_number = input('pit_number', 0);
|
||||
$user_id = input('user_id', 0);//
|
||||
$user_id = input('user_id', 0);
|
||||
if($user_id == 0){
|
||||
return V(0, '请选择用户', null);
|
||||
}
|
||||
$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']);
|
||||
@@ -154,6 +196,9 @@ class RoomPit extends BaseCom
|
||||
public function refuse_sign_room_host_invite()
|
||||
{
|
||||
$room_id = input('room_id', 0);
|
||||
if($room_id == 0){
|
||||
return V(0, '房间ID不能为空', null);
|
||||
}
|
||||
$reslut = model('RoomPit')->refuse_sign_room_host_invite($this->uid, $room_id);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
|
||||
56
application/api/controller/SendGift.php
Normal file
56
application/api/controller/SendGift.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\BaseCom;
|
||||
use think\Db;
|
||||
|
||||
class SendGift extends BaseCom
|
||||
{
|
||||
|
||||
/*
|
||||
* 送礼
|
||||
* @param int $gift_id
|
||||
*/
|
||||
public function send_gift()
|
||||
{
|
||||
$key_name = "api:send:gift:" . $this->uid;
|
||||
redis_lock_exits($key_name);
|
||||
$room_id = input('room_id', 0);//房间ID
|
||||
$gift_id = input('gift_id', 0);//礼物ID
|
||||
$gift_num = (int)input('gift_num', 1);//礼物数量
|
||||
$to_uid = input('to_uid', 0);//收礼人ID,逗号隔开的字符串
|
||||
$type = input('type', 1);//1金币购买 2送背包礼物
|
||||
$pit_number = input('pit_number', 0);
|
||||
$heart_id = input('heart_id', 0);//助力时的 ID
|
||||
|
||||
//获取幸运币
|
||||
$pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value');
|
||||
if($gift_id == $pool_gift_id){//送的是幸运币
|
||||
$reslut = model('Lottery')->gift($this->uid, $to_uid, $gift_id, $room_id,$gift_num);
|
||||
}else{
|
||||
//获取房间类型
|
||||
$room_type = model('Room')->get_room_type($room_id);
|
||||
if($room_type == 1){
|
||||
$reslut = model('GiveGift')->give_gift($this->uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
}elseif ($room_type == 2){
|
||||
$reslut = model('GiveGift')->give_gift($this->uid, $to_uid, $gift_id, $gift_num,2,$type, $room_id,$pit_number,0,$give_gift_ext);
|
||||
if($reslut['code'] == 1){
|
||||
$room_pits = model('RoomSong')->get_charm_rank($room_id);
|
||||
if($room_pits['code'] == 1){
|
||||
$room_pit = $room_pits['data'];
|
||||
//推送给前端
|
||||
$text = [
|
||||
'userCharmList' => $room_pit,
|
||||
];
|
||||
model('Chat')->sendMsg(1019,$room_id,$text);//K歌房送礼后魅力变化 排序变化
|
||||
}
|
||||
}
|
||||
}
|
||||
$reslut = model('Room')->room_gift($this->uid, $to_uid, $gift_id, $gift_num, $type, $room_id, $pit_number,$heart_id);
|
||||
}
|
||||
|
||||
redis_unlocks($key_name);
|
||||
return V($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
}
|
||||
@@ -560,9 +560,7 @@ class Room extends Model
|
||||
//进入房间前的判断
|
||||
public function before_join_room_check($user_id, $room_id) {
|
||||
$room = db::name('vs_room')->where(['id' => $room_id,'apply_status' => ['in',[1,2]]])->find();
|
||||
if (!isset($room)) {
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => ''];
|
||||
}
|
||||
|
||||
if($room['apply_status'] == 1){
|
||||
return ['code' => 0, 'msg' => '房间正在审核中……', 'data' => ''];
|
||||
}
|
||||
@@ -1054,6 +1052,9 @@ class Room extends Model
|
||||
if($room_info['type_id'] == 10){
|
||||
return 10;//签约房
|
||||
}
|
||||
if($room_info['type_id'] == 11){
|
||||
return 11;//酒吧房
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1688,9 +1689,6 @@ class Room extends Model
|
||||
public function quit_room($uid, $room_id,$user_id,$type = 0)
|
||||
{
|
||||
//拍卖位,交友过程中1-6号麦位,签约过程中签约麦位不能退出房间
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if($user_id == 0){
|
||||
$nickname = db::name('user')->where('id', $uid)->value('nickname');
|
||||
}else{
|
||||
@@ -1727,6 +1725,8 @@ class Room extends Model
|
||||
$apply_type = 5;
|
||||
}elseif ($room_type == 2){
|
||||
$apply_type = 6;
|
||||
}else{
|
||||
$apply_type = 1;
|
||||
}
|
||||
|
||||
if($apply_type == 1){
|
||||
@@ -2266,9 +2266,6 @@ class Room extends Model
|
||||
//房间在线列表
|
||||
public function room_online_list($room_id, $page = 1, $limit = 15)
|
||||
{
|
||||
if (!$room_id) {
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$room_type = $this->get_room_type($room_id);
|
||||
$lists['on_pit'] = [];
|
||||
$lists['off_pit'] = [];
|
||||
@@ -2713,7 +2710,7 @@ class Room extends Model
|
||||
|
||||
|
||||
//修改房间类型
|
||||
// $type 1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约
|
||||
// $type 1-交友,2-拍卖,7-互娱,8-交友(不要了),9-点唱,10-签约,11-酒吧房
|
||||
public function change_room_type($uid,$room_id,$type)
|
||||
{
|
||||
if(!$uid || !$room_id || !$type){
|
||||
@@ -2815,6 +2812,15 @@ class Room extends Model
|
||||
'room_up_pit_type' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
//酒吧房
|
||||
if($type == 11){
|
||||
$data = [
|
||||
'label_id' => 8,
|
||||
'type_id' => $type,
|
||||
'room_up_pit_type' => 1,
|
||||
];
|
||||
}
|
||||
$res = db::name('vs_room')->where(['id' => $room_id])->update($data);
|
||||
|
||||
if(!$res){
|
||||
@@ -2835,7 +2841,7 @@ class Room extends Model
|
||||
//申请上麦的全部下麦
|
||||
model('RoomPit')->clear_apply_pit_list($uid, $room_id);
|
||||
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8 || $type == 9 || $type == 10){
|
||||
if($type == 1 || $type == 3 || $type == 4 || $type == 7 || $type == 8 || $type == 9 || $type == 10 || $type == 11){
|
||||
//查询拍卖房的状态
|
||||
$room_auction = db::name('vs_room_auction')->where(['room_id' => $room_id,'status' => 2])->select();
|
||||
if($room_auction){
|
||||
@@ -3920,87 +3926,11 @@ class Room extends Model
|
||||
}
|
||||
|
||||
//用户重连
|
||||
public function user_reconnect($user_id,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
// $room_id = Db::name('user_data')->where('user_id', $user_id)->value('room_id');
|
||||
}
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
//查询用户在几个房间
|
||||
$room = db::name('vs_room_visitor')->where('user_id', $user_id)->select();
|
||||
if($room){
|
||||
$userinroom = 0;
|
||||
foreach ($room as $v){
|
||||
if($v['room_id'] == $room_id){
|
||||
$userinroom = $room_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if($userinroom == $room_id){
|
||||
$room_info = db::name('vs_room_visitor')->where(['id' => $room_id])->update(['room_id' => $room_id, 'user_id' => $user_id, 'updatetime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '更新加入房间失败', 'data' => null];
|
||||
}
|
||||
}else
|
||||
{
|
||||
$room_info = db::name('vs_room_visitor')->insert(['room_id' => $room_id, 'user_id' => $user_id, 'createtime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '加入房间失败', 'data' => null];
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
$room_info = db::name('vs_room_visitor')->insert(['room_id' => $room_id, 'user_id' => $user_id, 'createtime' => time(),'remarks' =>'断线后重连']);
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '加入房间失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//用户在房间内切后台保留机制
|
||||
public function user_in_room_background($user_id,$room_id,$type)
|
||||
{
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];//没啥用了
|
||||
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '参数错误', 'data' => null];
|
||||
}
|
||||
$room_t = db::name('vs_room')->field('type_id,label_id')->where('id',$room_id)->find();
|
||||
if(!(($room_t['type_id'] == 1 || $room_t['type_id'] == 8) && $room_t['label_id'] == 1)){
|
||||
if($type == 1){//1-切后台,2-切前台
|
||||
$is_bg = db::name('vs_user_in_room_bg')->where(['user_id' => $user_id,'room_id' => $room_id])->find();
|
||||
if($is_bg){
|
||||
$up_bg = [
|
||||
'updatetime' => time(),
|
||||
];
|
||||
db::name('vs_user_in_room_bg')->where('id',$is_bg['id'])->update($up_bg);
|
||||
}else{
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'room_id' => $room_id,
|
||||
'createtime' => time(),
|
||||
'updatetime' => time(),
|
||||
];
|
||||
$room_background = db::name('vs_user_in_room_bg')->insert($data);
|
||||
if(!$room_background){
|
||||
return ['code' => 0, 'msg' => '操作失败', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
db::name('vs_user_in_room_bg')->where(['user_id' => $user_id,'room_id' => $room_id])->delete();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
//任务跳转房间推荐
|
||||
|
||||
@@ -91,6 +91,10 @@ class RoomPit extends Model
|
||||
$pit_text = $pit_number . '号麦';
|
||||
}
|
||||
}
|
||||
if($roomtype == 11){
|
||||
$pit_time = db::name('vs_room_bar')->where('id',$room_id)->value('pit_time') ?? 5;
|
||||
$text['end_time'] = time()+$pit_time * 60;
|
||||
}
|
||||
|
||||
$text['text'] = $FromUserInfo['nickname'].' 上了 ' . $pit_text;
|
||||
$text['FromUserInfo'] = $FromUserInfo;
|
||||
@@ -142,7 +146,7 @@ class RoomPit extends Model
|
||||
}
|
||||
|
||||
//用户下麦
|
||||
public function DownPit($user_id,$room_id,$pit_number,$type = 0)
|
||||
public function DownPit($user_id,$room_id,$pit_number = 0,$type = 0)
|
||||
{
|
||||
$roomtype = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
|
||||
@@ -166,6 +170,7 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($roomtype == 10){
|
||||
if($pit_number == 1){
|
||||
$pit_text = '签约麦';
|
||||
@@ -272,9 +277,6 @@ class RoomPit extends Model
|
||||
//申请上麦
|
||||
public function apply_pit($user_id,$room_id,$pit_number = 0)
|
||||
{
|
||||
if($room_id <= 0){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,type_id,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
@@ -333,7 +335,7 @@ class RoomPit extends Model
|
||||
//自由麦
|
||||
if($room_info['room_up_pit_type'] == 2){
|
||||
if($pit_number > 0){
|
||||
if($room_info['label_id'] == 5){//交友(互娱)
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '该麦位已锁定了', 'data' => null];
|
||||
}
|
||||
@@ -353,7 +355,7 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '该麦位被锁定', 'data' => null];
|
||||
}
|
||||
}else{
|
||||
if($room_info['label_id'] == 5){//交友
|
||||
if($room_info['label_id'] == 5 || $room_info['label_id'] == 8){//互娱||酒吧
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$pit_number = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
@@ -483,22 +485,83 @@ class RoomPit extends Model
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function apply_pit_bar($user_id,$room_id,$gift_id,$pit_number = 0)
|
||||
{
|
||||
//查询房间状态
|
||||
$room_info = db::name('vs_room')->where(['id' => $room_id, 'apply_status' => 2])->field('id,room_status,room_up_pit_type,type_id,label_id,step')->find();
|
||||
if(!$room_info){
|
||||
return ['code' => 0, 'msg' => '房间不存在', 'data' => null];
|
||||
}
|
||||
if($room_info['room_status'] != 1){
|
||||
return ['code' => 0, 'msg' => '房间违规或关闭', 'data' => null];
|
||||
}
|
||||
|
||||
//检查是否在坑位上
|
||||
$pit_infos = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id])->field('id,pit_number')->find();
|
||||
if($pit_number == 9){
|
||||
//检查用户是否是房主或主持
|
||||
$is_room_owner =db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '没有权限', 'data' => null];
|
||||
}
|
||||
if($pit_infos){
|
||||
return ['code' => 0, 'msg' => '您已在麦上', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
if($pit_number == 10){
|
||||
return ['code' => 0, 'msg' => '请等待主持抱麦', 'data' => null];
|
||||
}
|
||||
|
||||
if($pit_number){
|
||||
//查询麦位是否有用户
|
||||
$pit_info = db::name('vs_room_pit')->where(['room_id' => $room_id, 'pit_number' => $pit_number])->field('id,user_id')->find();
|
||||
if($pit_info){
|
||||
if($pit_info['user_id']){
|
||||
return ['code' => 0, 'msg' => '麦位有人', 'data' => null];
|
||||
}
|
||||
}
|
||||
}else{
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
if (!$empty_pit) {
|
||||
return ['code' => 0, 'msg' => '没有空麦位', 'data' => null];
|
||||
}
|
||||
}
|
||||
|
||||
//上麦成功后设置礼物
|
||||
$gift_info = model('api/BarRoom')->join_pit_choose_gift($user_id,$room_id,$gift_id);
|
||||
if($gift_info['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '设置礼物失败', 'data' => null];
|
||||
}
|
||||
|
||||
$ompit = $this->OnPit($user_id,$room_id,$pit_number);//用户上了这个房间的几号麦位
|
||||
if($ompit['code'] != 1){
|
||||
return ['code' => 0, 'msg' => '上麦失败', 'data' => null];
|
||||
}
|
||||
|
||||
return ['code' => 1, 'msg' => '上麦成功', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
|
||||
//申请上麦列表
|
||||
public function apply_pit_list($userId,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
$where = [
|
||||
'a.room_id' => $room_id,
|
||||
'a.status' => 0,
|
||||
];
|
||||
|
||||
//常规通道 type: 0普通通道,1优先通道
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')->select();
|
||||
$list['regular'] = db::name('vs_room_pit_apply')->alias('a')
|
||||
->join('user b','a.user_id = b.id')
|
||||
->where($where)->where('a.type',0)
|
||||
->field('a.user_id,a.rank_value,b.nickname,b.avatar')
|
||||
->order('a.rank_value desc')
|
||||
->select();
|
||||
foreach ($list['regular'] as $k => $v){
|
||||
//查询用户的爵位
|
||||
$jue_wei = model('Nobility')->getUserNobilityInfo($v['user_id']);
|
||||
@@ -554,12 +617,6 @@ class RoomPit extends Model
|
||||
//上麦助力
|
||||
public function help_apply_pit($user_id,$room_id,$apply_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择助力用户', 'data' => null];
|
||||
}
|
||||
|
||||
//查询当前房间设置的助力;礼物
|
||||
$gift_info = db::name('vs_room_pit_apply_help_gift')->where(['room_id' => $room_id])->field('id,gift_id,gift_price')->find();
|
||||
@@ -567,24 +624,15 @@ class RoomPit extends Model
|
||||
return ['code' => 0, 'msg' => '当前房间没有设置助力礼物', 'data' => null];
|
||||
}
|
||||
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $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)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }
|
||||
|
||||
//助力
|
||||
$data = [
|
||||
'user_id' => $user_id,
|
||||
'help_user_id' => $apply_id,
|
||||
'room_id' => $room_id,
|
||||
'rank_value' => $gift_info['gift_price'],
|
||||
// 'apply_type' => $apply_type,
|
||||
'createtime'=> time(),
|
||||
];
|
||||
|
||||
//开启事务
|
||||
db::startTrans();
|
||||
$reslut = db::name('vs_room_pit_apply_help')->insert($data);
|
||||
@@ -628,12 +676,6 @@ class RoomPit extends Model
|
||||
//同意上麦
|
||||
public function agree_pit($user_id,$room_id,$apply_id,$tpe = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$apply_id){
|
||||
return ['code' => 0, 'msg' => '请选择申请用户', 'data' => null];
|
||||
}
|
||||
|
||||
$res = model('Room')->get_room_label($room_id);
|
||||
$room_label = $res['data']['label_id'];
|
||||
@@ -644,29 +686,14 @@ class RoomPit extends Model
|
||||
$apply_type = 2;//K歌
|
||||
}elseif($room_type == 2){
|
||||
$apply_type = 3;//拍卖
|
||||
}elseif($room_type == 7){
|
||||
$apply_type = 7;//交友
|
||||
}elseif($room_type == 7 || $room_type == 11){//互娱和酒吧
|
||||
$apply_type = 7;
|
||||
}elseif($room_type == 10){
|
||||
$apply_type = 10;//签约
|
||||
}else{
|
||||
$apply_type = 1;//聊天
|
||||
}
|
||||
|
||||
// if($apply_type == 1){
|
||||
// //判断当前用户是否是房主或在主持麦位上的主持
|
||||
// $is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_owner && !$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不是房主 或 不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }else{
|
||||
// $is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $user_id,'pit_number' => 9])->field('id')->find();
|
||||
// if(!$is_room_host){
|
||||
// return ['code' => 0, 'msg' => '您不在主持位,没有权限操作', 'data' => null];
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
$to_user = explode(',',$apply_id);
|
||||
|
||||
if(count($to_user) >= 1){
|
||||
@@ -885,25 +912,12 @@ class RoomPit extends Model
|
||||
//清空上麦申请
|
||||
public function clear_apply_pit_list($userId,$room_id,$apply_id = 0)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
//判断当前用户是否是房主或主持
|
||||
$is_room_owner = model('Room')->where(['id' => $room_id, 'user_id' => $userId])->field('id')->find();
|
||||
$is_room_host = db::name('vs_room_pit')->where(['room_id' => $room_id, 'user_id' => $userId,'pit_number' => 9])->field('id')->find();
|
||||
if(!$is_room_owner && !$is_room_host){
|
||||
return ['code' => 0, 'msg' => '您不是房主 或 不在主持麦,没有权限操作', 'data' => null];
|
||||
}
|
||||
// $res = model('Room')->get_room_label($room_id);
|
||||
// $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)){
|
||||
// $apply_type = 1;
|
||||
// }elseif ($room_label == 2 && ($room_type == 1 || $room_type == 3 || $room_type == 4)){
|
||||
// $apply_type = 2;
|
||||
// }else{
|
||||
// $apply_type = 1;
|
||||
// }
|
||||
|
||||
if($apply_id){
|
||||
$to_user = explode(',',$apply_id);
|
||||
@@ -937,12 +951,6 @@ class RoomPit extends Model
|
||||
//设置插麦礼物
|
||||
public function set_room_pit_apply_help_gift($user_id,$room_id,$gift_id,$gift_price)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
if(!$gift_id){
|
||||
return ['code' => 0, 'msg' => '请选择礼物', 'data' => null];
|
||||
}
|
||||
//礼物不能是CP礼物
|
||||
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if (in_array($gift_id, $cp_gift_ids)) {
|
||||
@@ -990,10 +998,6 @@ class RoomPit extends Model
|
||||
//修改房间上麦模式
|
||||
public function change_room_up_pit_type($user_id,$room_id)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
//判断当前用户是否有权限
|
||||
$owner = db::name('vs_room')->where(['id' => $room_id, 'user_id' => $user_id])->field('id')->find();
|
||||
$host = db::name('vs_room_host')->where(['room_id' => $room_id, 'user_id' => $user_id,'delete_time' => null])->find();
|
||||
@@ -1031,15 +1035,6 @@ class RoomPit extends Model
|
||||
//1-抱麦 2-踢下去
|
||||
public function host_user_pit($user_id,$room_id,$pit_number,$accept_user_id,$type)
|
||||
{
|
||||
if(!$room_id){
|
||||
return ['code' => 0, 'msg' => '请选择房间', 'data' => null];
|
||||
}
|
||||
|
||||
if(!$accept_user_id){
|
||||
return ['code' => 0, 'msg' => '请选择用户', 'data' => null];
|
||||
}
|
||||
|
||||
|
||||
$room_type = db::name('vs_room')->where(['id' => $room_id])->value('type_id');
|
||||
if($type == 1){//抱麦
|
||||
//判断该用户是否在主持麦上
|
||||
@@ -1051,8 +1046,10 @@ class RoomPit extends Model
|
||||
if($accept_user_is_on_pit){
|
||||
return ['code' => 0, 'msg' => '该用户已在麦位上', 'data' => null];
|
||||
}
|
||||
if($room_type == 7 && ($pit_number == 7 || $pit_number == 8)){
|
||||
return ['code' => 0, 'msg' => '互娱房 不能上7、8号麦位', 'data' => null];
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
if($pit_number == 7 || $pit_number == 8){
|
||||
return ['code' => 0, 'msg' => '此类型房间 不能上7、8号麦位', 'data' => null];
|
||||
}
|
||||
}
|
||||
$room_label = db::name('vs_room')->where(['id' => $room_id])->value('label_id');
|
||||
if($room_type == 1 && $room_label == 2 && !$pit_number){
|
||||
@@ -1184,11 +1181,11 @@ class RoomPit extends Model
|
||||
return ['code' => 1, 'msg' => '操作成功', 'data' => null];
|
||||
}
|
||||
}
|
||||
if($room_type == 7){
|
||||
if($room_type == 7 || $room_type == 11){
|
||||
//查询当前空麦位
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [7,8,9,10]);
|
||||
}else{
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9, 10]);
|
||||
$empty_pit = $this->getRoomNullPitWithout($room_id, [9,10]);
|
||||
}
|
||||
|
||||
if(!$empty_pit){
|
||||
|
||||
Reference in New Issue
Block a user