2025-11-18 10:07:09 +08:00
< ? php
namespace app\guildadmin\controller ;
use app\admin\command\Menu ;
use app\guildadmin\model\AuthGroup ;
use app\guildadmin\model\AuthGroupAccess ;
use app\guildadmin\model\AuthRule ;
2025-11-20 16:38:59 +08:00
use app\common\controller\GuildAdmin ;
2025-11-18 10:07:09 +08:00
use fast\Random ;
use fast\Tree ;
use think\Cache ;
use think\Db ;
use think\Exception ;
use think\Hook ;
use think\Session ;
use think\Validate ;
/**
* 管理员管理
*
* @ icon fa fa - users
* @ remark 一个管理员可以有多个角色组 , 左侧的菜单根据管理员所拥有的权限进行生成
*/
class Room extends GuildAdmin
{
protected $noNeedLogin = [];
protected $noNeedRight = [];
protected $layout = '' ;
2025-11-20 16:38:59 +08:00
protected $table = 'vs_room' ;
2025-11-18 10:07:09 +08:00
protected $table_guild_subsidy_config = 'vs_guild_subsidy_config' ;
protected $table_guild_subsidy = 'vs_guild_subsidy' ;
protected $table_guild_user = 'vs_guild_user' ;
protected $table_guild_data = 'vs_guild_data' ;
protected $table_guild = 'vs_guild' ;
public function _initialize ()
{
parent :: _initialize ();
}
// 房间列表
public function index ()
{
2025-11-21 17:45:00 +08:00
echo model ( 'api/Decorate' ) -> user_decorate_detail ( $room_data [ 'id' ], 7 );
2025-11-18 10:07:09 +08:00
$guild_id = $this -> guildId ;
$page = input ( 'page' , 1 );
$page_limit = input ( 'page_limit' , 30 );
$room_id = input ( 'room_id' , '' );
$search_user_id = input ( 'user_id' , '' );
$status = input ( 'status' , '' );
$search_stime_str = input ( 'search_stime' , '' );
$search_etime_str = input ( 'search_etime' , '' );
$s_money_search = input ( 's_money_search' , '' );
$e_money_search = input ( 'e_money_search' , '' );
$where [ 'a.guild_id' ] = $guild_id ;
$where [ 'a.status' ] = 1 ;
$where [ 'a.room_id' ] = [ '>' , 0 ];
if ( $room_id ){
if ( is_numeric ( $room_id )){
$where [ 'b.room_number' ] = $room_id ;
} else {
$where [ 'b.room_name' ] = [ 'like' , '%' . $room_id . '%' ];
}
}
if ( $search_user_id ){
$user_id = db :: name ( 'user' ) -> where ( 'user_code' , $search_user_id ) -> value ( 'id' );
$where [ 'a.user_id' ] = $user_id ;
}
if ( $status ){
$where [ 'room_status' ] = $status ;
}
$count = db :: name ( $this -> table_guild_user ) -> alias ( 'a' )
-> join ( 'vs_room b' , 'a.room_id = b.id' , 'left' ) -> where ( $where ) -> count ();
$lists = db :: name ( $this -> table_guild_user ) -> alias ( 'a' )
-> join ( 'vs_room b' , 'a.room_id = b.id' , 'left' )
-> field ( 'a.*,b.room_name,b.room_number,b.room_cover,b.type_id,b.label_id,b.room_status' )
-> where ( $where )
-> page ( $page , $page_limit )
-> select ();
$rum_lists = [];
//总流水
$total_consumption = 0 ;
foreach ( $lists as $k => $v ){
$search_stime = $search_stime_str ;
$search_etime = $search_etime_str ;
if ( $search_stime != " " ){
if ( $search_stime != " " && $v [ 'createtime' ] < strtotime ( $search_stime )){
$search_stime = $search_stime ;
} else {
$search_stime = date ( 'Y-m-d H:i:s' , $v [ 'createtime' ]) ;
}
} else {
$search_stime = $search_stime ;
}
if ( $search_etime != " " ){
if ( $v [ 'quit_time' ]){
if ( $search_etime != " " && $v [ 'quit_time' ] > strtotime ( $search_etime )){
$search_etime = $search_etime ;
} else {
$search_etime = date ( 'Y-m-d H:i:s' , $v [ 'quit_time' ]);
}
} else {
$search_etime = $search_etime ;
}
} else {
$search_etime = $search_etime ;
}
$room_info = db :: name ( 'vs_room' ) -> where ([ 'id' => $v [ 'room_id' ]]) -> find ();
2025-11-21 17:29:26 +08:00
$rum_lists [ $k ][ 'id' ] = $v [ 'id' ] ? ? 0 ;
$rum_lists [ $k ][ 'room_id' ] = $v [ 'room_id' ] ? ? 0 ;
2025-11-18 10:07:09 +08:00
$rum_lists [ $k ][ 'room_code' ] = $v [ 'room_number' ];
//靓号
$room_number = model ( 'api/Decorate' ) -> user_decorate_detail ( $v [ 'room_id' ], 7 );
$rum_lists [ $k ][ 'room_number' ] = $room_number == $v [ 'room_number' ] ? '无' : $room_number ;
//房主
$room_user = db :: name ( 'user' ) -> where ([ 'id' => $v [ 'user_id' ]]) -> find ();
$rum_lists [ $k ][ 'room_user' ] = $room_user [ 'user_code' ] . '-' . $room_user [ 'nickname' ];
$rum_lists [ $k ][ 'room_name' ] = $room_info [ 'room_name' ] ? ? '' ;
$rum_lists [ $k ][ 'room_cover' ] = $room_info [ 'room_cover' ] ? ? '' ;
//房间分类
$rum_lists [ $k ][ 'room_type' ] = db :: name ( 'vs_room_type' ) -> where ( 'id' , $v [ 'type_id' ]) -> value ( 'type_name' ) ? ? '' ;
//房间标签
$rum_lists [ $k ][ 'room_label' ] = db :: name ( 'vs_room_label' ) -> where ( 'id' , $v [ 'label_id' ]) -> value ( 'label_name' ) ? ? '' ;
//房间粉丝
$stime = $search_stime_str == " " ? strtotime ( date ( 'Y-m-d' , time ())) : strtotime ( $search_stime_str );
$etime = time ();
$rum_lists [ $k ][ 'follow_num' ] = Db :: name ( 'user_follow' ) -> where ([
'follow_id' => $v [ 'room_id' ],
'type' => 2 ,
'createtime' => [ '<' , $etime ],
]) -> count ();
$rum_lists [ $k ][ 'follow_num_new' ] = Db :: name ( 'user_follow' ) -> where ([
'follow_id' => $v [ 'room_id' ],
'type' => 2 ,
'createtime' => [ '<' , $etime ],
]) -> where ( 'createtime' , '>' , $stime ) -> count ();
//房间状态
$rum_lists [ $k ][ 'room_status' ] = $v [ 'room_status' ] == 1 ? '正常' : '封禁' ;
//房间流水
$rum_lists [ $k ][ 'consumption' ] = model ( 'adminapi/Room' ) -> getRoomFlow ( $v [ 'room_id' ], $search_stime , $search_etime );
$rum_lists [ $k ][ 'add_time' ] = date ( 'Y-m-d H:i:s' , $v [ 'createtime' ]);
$total_consumption += $rum_lists [ $k ][ 'consumption' ];
}
usort ( $rum_lists , function ( $a , $b ) {
return $b [ 'consumption' ] - $a [ 'consumption' ];
});
//按流水查询
if ( $s_money_search != " " && $e_money_search != " " ){
$rum_lists = array_filter ( $rum_lists , function ( $v ) use ( $s_money_search , $e_money_search ) {
return $v [ 'consumption' ] >= $s_money_search && $v [ 'consumption' ] <= $e_money_search ;
});
}
//分页
$rum_lists = array_slice ( $rum_lists , ( $page - 1 ) * $page_limit , $page_limit );
$return_data = [
'page' => $page ,
'page_limit' => $page_limit ,
'total_consumption' => $total_consumption ,
'count' => $count ,
'lists' => $rum_lists
];
return V ( 1 , " 成功 " , $return_data );
}
2025-11-20 16:38:59 +08:00
//房间详情
public function room_info (){
$room_id = input ( 'room_id' , '' );
if ( $room_id == '' ){
return V ( 0 , " 参数错误 " );
}
$room_data = db :: name ( $this -> table ) -> where ([ 'id' => $room_id ]) -> find ();
if ( ! $room_data ){
return V ( 0 , " 房间不存在 " );
}
$room_data [ 'createtime' ] = date ( 'Y-m-d H:i:s' , $room_data [ 'createtime' ]);
$room_data [ 'updatetime' ] = date ( 'Y-m-d H:i:s' , $room_data [ 'updatetime' ]);
$room_data [ 'room_type_str' ] = db :: name ( 'vs_room_type' ) -> where ([ 'id' => $room_data [ 'type_id' ]]) -> value ( 'type_name' );
$room_data [ 'liang' ] = model ( 'api/Decorate' ) -> user_decorate_detail ( $room_data [ 'id' ], 7 );
$room_data [ 'owner' ] = db :: name ( 'user' ) -> where ([ 'id' => $room_data [ 'user_id' ]]) -> value ( 'nickname' );
$room_data [ 'is_robot_num' ] = $room_data [ 'robot_num' ] == 0 ? 2 : 1 ;
$room_data [ 'guild_name' ] = '' ;
$guild_id = db :: name ( 'vs_guild_user' ) -> where ( 'user_id' , $room_data [ 'user_id' ]) -> value ( 'guild_id' );
if ( $guild_id ){
$room_data [ 'guild_name' ] = db :: name ( 'vs_guild' ) -> where ( 'id' , $guild_id ) -> value ( 'guild_name' );
}
$room_data [ 'jiqirennum' ] = 0 ;
$roomUser = db :: name ( 'vs_room_visitor' ) -> where ( 'room_id' , $room_data [ 'id' ]) -> select ();
if ( $roomUser ){
foreach ( $roomUser as $key => $value ){
if ( db :: name ( 'user' ) -> where ( 'id' , $value [ 'user_id' ]) -> value ( 'is_robot' )){
$room_data [ 'jiqirennum' ] += 1 ;
}
}
}
//前天的收益
$room_data [ 'two_day_ago_earnings' ] = $this -> get_room_today_profit ( $room_id , 4 );
//昨天的收益
$room_data [ 'yesterday_earnings' ] = $this -> get_room_today_profit ( $room_id , 3 );
//今日的收益
$room_data [ 'today_earnings' ] = $this -> get_room_today_profit ( $room_id , 2 );
// 计算今日收益比昨日收益的增长百分比
if ( $room_data [ 'yesterday_earnings' ] > 0 ) {
$growthPercentage = (( $room_data [ 'today_earnings' ] - $room_data [ 'yesterday_earnings' ]) / $room_data [ 'yesterday_earnings' ]) * 100 ;
} else {
// 如果昨日收益为0, 避免除以零错误
$growthPercentage = $room_data [ 'today_earnings' ] > 0 ? 100 : 0 ; // 如果今天有收益而昨天没有, 则视为增长100%
}
//比昨日收益增长百分之多少
$room_data [ 'growth_percentage' ] = round ( $growthPercentage , 2 ); // 保留两位小数
//计算昨日比前天的收益增长百分比
if ( $room_data [ 'two_day_ago_earnings' ] > 0 ) {
$yesterdayGrowthPercentage = (( $room_data [ 'yesterday_earnings' ] - $room_data [ 'two_day_ago_earnings' ]) / $room_data [ 'two_day_ago_earnings' ]) * 100 ;
} else {
// 如果前天收益为0, 避免除以零错误
$yesterdayGrowthPercentage = $room_data [ 'yesterday_earnings' ] > 0 ? 100 : 0 ; // 如果昨天有收益而前天没有, 则视为增长100%
}
//昨日比前天的收益增长百分之多少
$room_data [ 'yesterday_growth_percentage' ] = round ( $yesterdayGrowthPercentage , 2 ); // 保留两位小数
//今日访客
$room_data [ 'visitor' ] = $this -> get_room_visitor ( $room_id , 1 );
//昨日访客
$room_data [ 'yesterday_visitor' ] = $this -> get_room_visitor ( $room_id , 2 );
//今日比昨日访客增长百分比
if ( $room_data [ 'yesterday_visitor' ] > 0 ) {
$yesterdayVisitor = (( $room_data [ 'visitor' ] - $room_data [ 'yesterday_visitor' ]) / $room_data [ 'yesterday_visitor' ]) * 100 ;
} else {
// 如果前天收益为0, 避免除以零错误
$yesterdayVisitor = $room_data [ 'visitor' ] > 0 ? 100 : 0 ; // 如果今天有而昨天没有, 则视为增长100%
}
$room_data [ 'growth_visitor' ] = round ( $yesterdayVisitor , 2 ); // 保留两位小数
//补贴
$roomSubsidy = model ( 'api/Room' ) -> room_ubsidy ( $room_id );
//上周补贴
$room_data [ 'last_week_subsidy' ] = $roomSubsidy [ 'lastweek' ][ 'subsidy_amount' ];
//本周补贴
$room_data [ 'this_week_subsidy' ] = $roomSubsidy [ 'thisweek' ][ 'subsidy_amount' ];
//本周补贴比上周增长百分比
if ( $room_data [ 'last_week_subsidy' ] > 0 ) {
$weekSubsidy = (( $room_data [ 'this_week_subsidy' ] - $room_data [ 'last_week_subsidy' ]) / $room_data [ 'last_week_subsidy' ]) * 100 ;
} else {
// 如果上周收益为0, 避免除以零错误
$weekSubsidy = $room_data [ 'this_week_subsidy' ] > 0 ? 100 : 0 ; // 如果本周有收益而上周没有, 则100%
}
$room_data [ 'growth_week_subsidy' ] = round ( $weekSubsidy , 2 );
return V ( 1 , " 成功 " , $room_data );
}
//房间收益
//type 1:总收益 2:今日收益 3:昨日收益 4:前天的收益
public function get_room_today_profit ( $room_id , $type )
{
if ( $type == 2 ){
$start_time = strtotime ( date ( 'Y-m-d' ));
$end_time = $start_time + 86400 ;
} elseif ( $type == 3 ){
$start_time = strtotime ( date ( 'Y-m-d' , strtotime ( '-1 day' )));
$end_time = $start_time + 86400 ;
} elseif ( $type == 4 ){
$start_time = strtotime ( date ( 'Y-m-d' , strtotime ( '-2 day' )));
$end_time = $start_time + 86400 ;
} elseif ( $type == 1 ){
$start_time = 1748676768 ; //2025-06-00 15:32:48
$end_time = time ();
}
$profit = db :: name ( 'vs_give_gift' ) -> where ( 'from_id' , $room_id ) -> where ( 'from' , 2 ) -> where ( 'createtime' , 'between' , [ $start_time , $end_time ]) -> sum ( 'total_price' );
return $profit ;
}
//房间访客
//type 1:今日 2:昨日 3: 所有
public function get_room_visitor ( $room_id , $type )
{
if ( $type == 1 ){
$start_time = strtotime ( date ( 'Y-m-d' ));
$end_time = $start_time + 86400 ;
} elseif ( $type == 2 ){
$start_time = strtotime ( date ( 'Y-m-d' , strtotime ( '-1 day' )));
$end_time = $start_time + 86400 ;
} elseif ( $type == 3 ){
$start_time = 1748676768 ; //2025-06-00 15:32:48
$end_time = time ();
}
$profit = db :: name ( 'user_visit_log' ) -> where ([ 'to_id' => $room_id , 'type' => 2 ]) -> where ( 'createtime' , 'between' , [ $start_time , $end_time ]) -> count ();
return $profit ;
}
//房间流水
public function room_flow ()
{
$room_id = input ( 'room_id' , '' );
$page = input ( 'page' , 1 );
$page_limit = input ( 'page_limit' , 10 );
$type = input ( 'type' , 1 ); //1:全部流水 2:日流水 3:周流水 4:月流水
if ( $room_id == '' ){
return V ( 0 , " 参数错误 " );
}
if ( $type == 1 ){
$begin_time = 1748676768 ; //2025-06-00 15:32:48
$end_time = time ();
$where [ 'a.createtime' ] = [ 'between' , [ $begin_time , $end_time ]];
} elseif ( $type == 2 ){
//日流水
$begin_time = strtotime ( date ( 'Y-m-d 00:00:00' , time ()));
$end_time = time ();
$where [ 'a.createtime' ] = [ 'between' , [ $begin_time , $end_time ]];
}
elseif ( $type == 3 ){
//周流水
//本周一
$begin_time = strtotime ( date ( 'Y-m-d 00:00:00' , strtotime ( 'this week' )));
$end_time = time ();
$where [ 'a.createtime' ] = [ 'between' , [ $begin_time , $end_time ]];
}
elseif ( $type == 4 ){
$begin_time = strtotime ( date ( 'Y-m-01' ));
$end_time = time ();
$where [ 'a.createtime' ] = [ 'between' , [ $begin_time , $end_time ]];
}
$count = db :: name ( 'vs_give_gift' ) -> alias ( 'a' )
-> field ( 'a.id' )
-> join ( 'user b' , 'a.user_id = b.id' , 'left' )
-> join ( 'user c' , 'a.gift_user = c.id' , 'left' )
-> join ( 'vs_gift d' , 'a.gift_id = d.gid' , 'left' )
-> where ( 'a.from' , 2 )
-> where ( 'a.from_id' , $room_id )
-> where ( $where )
-> count ();
$list = db :: name ( 'vs_give_gift' ) -> alias ( 'a' )
-> field ( 'a.number,a.createtime,a.total_price,a.type,b.nickname,b.avatar,c.nickname as gift_nickname,c.avatar as gift_avatar,d.gift_name,a.from,a.from_id' )
-> join ( 'user b' , 'a.user_id = b.id' , 'left' )
-> join ( 'user c' , 'a.gift_user = c.id' , 'left' )
-> join ( 'vs_gift d' , 'a.gift_id = d.gid' , 'left' )
-> where ( 'a.from' , 2 )
-> where ( 'a.from_id' , $room_id )
-> where ( $where )
-> order ( 'a.id desc' )
-> page ( $page , $page_limit )
-> select ();
if ( $list ){
foreach ( $list as & $v ){
$v [ 'createtime' ] = date ( 'Y-m-d H:i:s' , $v [ 'createtime' ]);
$v [ 'content' ] = $v [ 'nickname' ] . ' 给 ' . $v [ 'gift_nickname' ] . ' 送了 ' . $v [ 'gift_name' ] . ' x ' . $v [ 'number' ];
// 来源: 1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏
$v [ 'from_str' ] = model ( 'adminapi/Gift' ) -> GiveGiftFromStr [ $v [ 'from' ]];
}
}
$return_data = [
'page' => $page ,
'page_limit' => $page_limit ,
'count' => $count ,
'lists' => $list ,
'total' => [
'total_price' => db :: name ( 'vs_give_gift' ) -> alias ( 'a' )
-> join ( 'user b' , 'a.user_id = b.id' , 'left' )
-> where ( 'a.from' , 2 )
-> where ( 'a.from_id' , $room_id )
-> where ( $where ) -> sum ( 'total_price' )
]
];
return V ( 1 , " 成功 " , $return_data );
}
//房间用户进入记录
public function room_user_log ()
{
$room_id = input ( 'room_id' , '' );
$page = input ( 'page' , 1 );
$page_limit = input ( 'page_limit' , 10 );
if ( $room_id == '' ){
return V ( 0 , " 参数错误 " );
}
$count = db :: name ( 'user_visit_log' ) -> alias ( 'a' )
-> field ( 'a.id,a.createtime,b.nickname,b.user_code' )
-> join ( 'user b' , 'a.from_uid = b.id' , 'left' )
-> where ( 'a.to_id' , $room_id )
-> where ( 'a.type' , 2 )
-> count ();
$list = db :: name ( 'user_visit_log' ) -> alias ( 'a' )
-> field ( 'a.id,a.createtime,b.nickname,b.user_code' )
-> join ( 'user b' , 'a.from_uid = b.id' , 'left' )
-> where ( 'a.to_id' , $room_id )
-> where ( 'a.type' , 2 )
-> order ( 'a.id desc' )
-> page ( $page , $page_limit )
-> select ();
if ( $list ){
foreach ( $list as & $v ){
$v [ 'createtime' ] = date ( 'Y-m-d H:i:s' , $v [ 'createtime' ]);
}
}
$return_data = [
'page' => $page ,
'page_limit' => $page_limit ,
'count' => $count ,
'lists' => $list
];
return V ( 1 , " 成功 " , $return_data );
}
//编辑房间
public function edit_room ()
{
$room_id = input ( 'room_id' , '' ); //固定值不可变
$admin_id = Session :: get ( 'admin_id' );
$room_number = input ( 'room_number' , '' ); //房间编号
if ( $room_number ){
$data [ 'room_number' ] = $room_number ;
}
$room_name = input ( 'room_name' , '' ); //房间名称
if ( $room_name ){
$data [ 'room_name' ] = $room_name ;
}
$room_intro = input ( 'room_intro' , '' ); //房间简介(公告)
if ( $room_intro ){
$data [ 'room_intro' ] = $room_intro ;
}
$room_cover = input ( 'room_cover' , '' ); //房间封面
if ( $room_cover ){
$data [ 'room_cover' ] = $room_cover ;
}
$room_background_id = input ( 'room_background' , '' ); //房间背景url
if ( $room_background_id ){
$data [ 'room_background' ] = $room_background_id ;
}
$type_id = input ( 'type_id' , '' ); //房间类型id
if ( $type_id ){
$data [ 'type_id' ] = $type_id ;
}
$is_earnings = input ( 'is_earnings' , '' ); //是否获取收益 1是 2否
if ( $is_earnings ){
$data [ 'is_earnings' ] = $is_earnings ;
}
$is_top = input ( 'is_top' , '' ); //是否置顶 1非置顶 2置顶
if ( $is_top ){
$data [ 'is_top' ] = $is_top ;
}
$is_hot = input ( 'is_hot' , '' ); //是否热门 1非热门 2热门
if ( $is_hot ){
$data [ 'is_hot' ] = $is_hot ;
}
$is_recommend = input ( 'is_recommend' , '' ); //是否推荐 1非推荐 2推荐
if ( $is_recommend ){
$data [ 'is_recommend' ] = $is_recommend ;
}
$room_status = input ( 'room_status' , '' ); //房间状态 1正常 2封禁 3关闭
if ( $room_status ){
$data [ 'room_status' ] = $room_status ;
}
$is_show_room = input ( 'is_show_room' , '' ); //是否显示房间 1是 2否
if ( $is_show_room ){
$data [ 'is_show_room' ] = $is_show_room ;
}
$room_password = input ( 'room_password' , '' ); //房间密码
$is_room_password = input ( 'is_room_password' , '' ); //是否密码房 1是 2否
if ( $is_room_password == 1 ){
if ( $room_password == '' ){
return V ( 0 , " 请填写房间密码 " );
}
$data [ 'room_password' ] = $room_password ;
} elseif ( $is_room_password == 2 ){
$data [ 'room_password' ] = '' ;
}
$robot_num = input ( 'robot_num' , '' ); //机器人数量
$is_robot_num = input ( 'is_robot_num' , '' ); //是否投送机器人 1是 2否
if ( $is_robot_num == 1 ){
if ( $robot_num == '' ){
return V ( 0 , " 请填写机器人数量 " );
}
$data [ 'robot_num' ] = $robot_num ;
//在用户表里找 $robot_num 个机器人 进入到房间
$user_list = db :: name ( 'user' ) -> field ( 'id' ) -> where ( 'is_robot' , 1 ) -> limit ( $robot_num ) -> orderRaw ( 'rand()' ) -> select ();
if ( $user_list ){
if ( count ( $user_list ) != $robot_num ){
return V ( 0 , " 机器人数量不足 " );
}
foreach ( $user_list as $v ){
model ( 'api/Room' ) -> join_room ( $v [ 'id' ], $room_id , $room_password );
}
} else {
return V ( 0 , " 没有可用机器人 " );
}
} elseif ( $is_robot_num == 2 || $robot_num == 0 ){
$data [ 'robot_num' ] = 0 ;
//查询在房间中的机器人 并退出
$user_list = db :: name ( 'vs_room_visitor' ) -> alias ( 'a' ) -> join ( 'user b' , 'a.user_id = b.id' , 'left' )
-> field ( 'a.id,a.user_id' )
-> where ( 'a.room_id' , $room_id )
-> where ( 'b.is_robot' , 1 )
-> select ();
if ( $user_list ){
foreach ( $user_list as $v ){
model ( 'api/Room' ) -> quit_room ( 1 , $room_id , $v [ 'user_id' ], 0 );
}
}
}
$is_open_blind_box_turntable = input ( 'is_open_blind_box_turntable' , '' ); //是否开启盲盒转盘: 0 否 1是
if ( $is_open_blind_box_turntable !== " " ){
$data [ 'is_open_blind_box_turntable' ] = $is_open_blind_box_turntable ;
if ( $is_open_blind_box_turntable == 1 ){
$room_data = db :: name ( 'vs_room' ) -> find ( $room_id );
if ( $room_data [ 'is_open_blind_box_turntable' ] == 0 ){
model ( 'Room' ) -> bindPan ( $room_id );
}
}
}
//排序
$sort = input ( 'sort' , '' ); //排序 越大越靠前
if ( $sort !== " " ){
$data [ 'sort' ] = $sort ;
}
$res = db :: name ( 'vs_room' ) -> where ( 'id' , $room_id ) -> update ( $data );
if ( $res ){
return V ( 1 , " 成功 " );
}
else {
return V ( 0 , " 失败 " );
}
}
//房间状态修改
public function room_status_edit (){
$room_id = input ( 'room_id' , '' );
$room_status = input ( 'room_status' , '' );
if ( $room_status == 1 ){
$data [ 'room_status' ] = 1 ;
} elseif ( $room_status == 2 ){
$data [ 'room_status' ] = 3 ;
}
$res = db :: name ( 'vs_room' ) -> where ( 'id' , $room_id ) -> update ( $data );
if ( $res ){
return V ( 1 , " 成功 " );
}
else {
return V ( 0 , " 失败 " );
}
}
2025-11-18 10:07:09 +08:00
}