2025-08-07 20:21:47 +08:00
< ? php
namespace app\api\model ;
2026-01-03 20:50:23 +08:00
2025-12-25 16:49:55 +08:00
use think\Cache ;
2025-08-07 20:21:47 +08:00
use think\Model ;
use think\Db ;
use think\Session ;
/**
* 装饰模型
*/
class Decorate extends Model
{
// 开启自动写入时间戳字段
protected $autoWriteTimestamp = true ;
// 定义时间戳字段名
protected $createTime = 'createtime' ;
protected $updateTime = 'updatetime' ;
2025-10-20 09:59:39 +08:00
// 定义字段类型 1头像框 2坐骑 3麦圈 6个人靓号 7房间靓号 8公会靓号
2025-11-25 15:22:39 +08:00
public $TypeArray = [ 1 => '头像框' , 12 => '降身卡' , 2 => '坐骑' , 9 => '聊天气泡' , 6 => '个人靓号' , 7 => '房间靓号' , 8 => '公会靓号' , 3 => '麦圈' , 10 => 'CP特效' , 11 => 'CP装扮' ];
2025-12-12 11:38:09 +08:00
protected $FromType = [ 1 => '购买' , 2 => '后台赠送' , 3 => '礼盒开奖' , 4 => '好友赠送' , 5 => '首充赠送' , 6 => '天降好礼获得' , 7 => '财富等级特权赠送' , 8 => '新人充值好礼' , 9 => '爵位购买赠送' , 10 => '任务奖励' , 11 => " 每日签到 " ];
2025-08-07 20:21:47 +08:00
public function __construct ( $data = [])
{
parent :: __construct ( $data );
$this -> table = 'vs_decorate' ;
}
//获取装扮类型
public function get_type_list ( $have_hot = 0 )
{
2025-12-08 15:38:27 +08:00
$no_show_ids = [ 7 , 8 , 3 , 10 , 11 ];
2025-08-07 20:21:47 +08:00
$label = $this -> TypeArray ;
if ( $have_hot ) {
$label = [ 100 => '热门' ] + array_filter ( $this -> TypeArray , fn ( $key ) => $key != 100 , ARRAY_FILTER_USE_KEY );
}
$data = [];
$i = 0 ;
foreach ( $label as $k => $v ) {
2025-11-21 14:53:50 +08:00
if ( in_array ( $k , $no_show_ids )) {
continue ;
}
2025-08-07 20:21:47 +08:00
$data [ $i ][ 'id' ] = $k ;
$data [ $i ][ 'name' ] = $v ;
++ $i ;
}
return [ 'code' => 1 , 'msg' => '获取成功' , 'data' => $data ];
}
//拉去装扮列表
public function get_decorate_list ( $type = 100 )
{
$map = [];
if ( $type == 100 ) {
$map = [
'a.delete_time' => 0 ,
'a.show_status' => 1 ,
'a.is_buy' => 1 ,
'a.is_hot' => 1 ,
'b.is_delete' => 1 ,
];
} elseif ( in_array ( $type , [ 6 , 7 , 8 ])) {
$map = [
'a.delete_time' => 0 ,
'a.show_status' => 1 ,
'a.is_buy' => 1 ,
'b.is_delete' => 1 ,
'a.type' => $type ,
'a.is_user_buy' => 2
];
} else {
$map = [
'a.delete_time' => 0 ,
'a.show_status' => 1 ,
'a.is_buy' => 1 ,
'b.is_delete' => 1 ,
'a.type' => $type ,
];
}
2025-11-25 18:29:45 +08:00
if ( $type == 12 ){
$map = [
'type' => 12 ,
'delete_time' => 0 ,
'show_status' => 1 ,
'is_buy' => 1
];
$list = DB :: name ( $this -> table ) -> where ( $map ) -> field ( 'did,title,type,base_image,play_image,price' )
-> order ( 'price asc' )
-> select ();
} else {
2026-01-03 14:48:42 +08:00
$list = DB :: name ( $this -> table )
-> alias ( 'a' ) -> join ( 'fa_vs_decorate_price b' , 'a.did = b.did' )
-> field ( 'a.did,a.title,a.type,a.base_image,a.play_image,min(b.price) as price,special_num,b.original_price,b.discount' ) -> where ( $map ) -> group ( 'b.did' ) -> order ( 'price asc' ) -> select ();
2025-11-25 18:29:45 +08:00
}
2025-08-07 20:21:47 +08:00
foreach ( $list as $k => & $v ) {
$v [ 'base_image' ] = localpath_to_netpath ( $v [ 'base_image' ]);
$v [ 'play_image' ] = localpath_to_netpath ( $v [ 'play_image' ]);
$v [ 'price' ] = ( int ) $v [ 'price' ];
2026-01-03 18:51:30 +08:00
if ( isset ( $v [ 'discount' ])){
if ( $v [ 'discount' ] <= 0 || $v [ 'discount' ] >= 10 ){
$v [ 'discount' ] = 0 ;
$v [ 'discount_str' ] = " 无折扣 " ;
} else {
$v [ 'discount_str' ] = $v [ 'discount' ] . " 折 " ;
}
2026-01-03 14:48:42 +08:00
}
2025-08-07 20:21:47 +08:00
}
return [ 'code' => 1 , 'msg' => '获取成功' , 'data' => $list ];
}
// 获取礼物详情
public function get_decorate_detail ( $did )
{
$decorate = DB :: name ( $this -> table ) -> where ([ 'did' => $did , 'delete_time' => 0 , 'show_status' => 1 ]) -> find ();
if ( ! $decorate ) {
return [ 'code' => 0 , 'msg' => '参数错误' ];
}
2025-11-25 18:29:45 +08:00
if ( $decorate [ 'type' ] == 12 ){
2025-11-26 10:22:57 +08:00
$result [ 'title' ] = $decorate [ 'title' ];
$result [ 'price' ] = ( int ) $decorate [ 'price' ];
$result [ 'base_image' ] = localpath_to_netpath ( $decorate [ 'base_image' ]);
} else {
2025-11-25 18:29:45 +08:00
$decorate_price = DB :: name ( 'vs_decorate_price' ) -> where ([ 'did' => $did , 'is_delete' => 1 ]) -> order ( 'day asc' ) -> select ();
if ( ! $decorate_price ) {
return [ 'code' => 0 , 'msg' => '参数错误' ];
}
$result [ 'title' ] = $decorate [ 'title' ];
foreach ( $decorate_price as $k => $v ) {
$result [ 'price_list' ][ $k ][ 'price' ] = ( int ) $v [ 'price' ];
2026-01-03 14:48:42 +08:00
$result [ 'price_list' ][ $k ][ 'original_price' ] = $v [ 'original_price' ];
2025-11-25 18:29:45 +08:00
$result [ 'price_list' ][ $k ][ 'discount' ] = $v [ 'discount' ];
$result [ 'price_list' ][ $k ][ 'day' ] = $v [ 'day' ];
//月
$result [ 'price_list' ][ $k ][ 'month' ] = $v [ 'day' ] / 30 ;
//有效期至
$result [ 'price_list' ][ $k ][ 'end_time' ] = date ( 'Y-m-d' , strtotime ( " + " . $v [ 'day' ] . " day " ));
}
2025-08-07 20:21:47 +08:00
}
return [ 'code' => 1 , 'msg' => '获取成功' , 'data' => $result ];
}
//购买/赠送 装扮
/*
* @ param $uid ( 接受 ) 用户id
* @ param $did 装扮id
* @ param $day 天数
* @ param $give_uid 赠送用户id 0 为系统赠送
* @ param $from_type 购买来源 1 购买 2 后台赠送 3 礼盒开奖 4 好友赠送 7 财富等级特权赠送
* @ param $log_remark 日志备注
*
*/
2025-11-25 18:29:45 +08:00
public function pay_decorate ( $uid , $did , $day = 0 , $from_type = 1 , $give_uid = 0 , $log_remark = " " , $num = 1 ){
2026-01-16 09:00:55 +08:00
if ( empty ( $day ) && $from_type == 12 ){
$day = 0 ;
} else {
$day = db :: name ( 'vs_decorate_price' ) -> where ([ 'did' => $did ]) -> order ( 'day asc' ) -> value ( 'day' );
}
2025-08-07 20:21:47 +08:00
if ( empty ( $log_remark )){
$log_remark = $this -> FromType [ $from_type ];
}
$user_info = db :: name ( 'user' ) -> find ( $uid );
if ( ! $user_info ){
return [ 'code' => 0 , 'msg' => '参数错误' , 'data' => null ];
}
//该装扮是否存在
$map = [];
$map = [
'did' => $did ,
'delete_time' => 0 ,
];
$decorate_info = DB :: name ( $this -> table ) -> where ( $map ) -> find ();
if ( ! $decorate_info ){
return [ 'code' => 0 , 'msg' => '该装扮不存在' . $did , 'data' => null ];
}
2025-11-25 18:29:45 +08:00
if ( $decorate_info [ 'type' ] != 12 ){
//该天数是否存在
$map = [];
$map = [
'did' => $did ,
'day' => $day ,
'is_delete' => 1 ,
];
$decorate_price_info = db :: name ( 'vs_decorate_price' ) -> where ( $map ) -> find ();
if ( ! $decorate_price_info ){
return [ 'code' => 0 , 'msg' => '该装扮天数不存在' , 'data' => null ];
}
if ( $decorate_info [ 'type' ] == 6 && $decorate_info [ 'is_user_buy' ] == 1 ){
return [ 'code' => 0 , 'msg' => '该个人靓号已被购买' , 'data' => null ];
}
if ( $decorate_info [ 'type' ] == 7 && $decorate_info [ 'is_user_buy' ] == 1 ){
return [ 'code' => 0 , 'msg' => '该房间靓号已被购买' , 'data' => null ];
}
if ( $decorate_info [ 'type' ] == 8 && $decorate_info [ 'is_user_buy' ] == 1 ){
return [ 'code' => 0 , 'msg' => '该公会靓号已被购买' , 'data' => null ];
}
} else {
$decorate_price_info = [
2026-01-04 11:13:21 +08:00
'price' => $decorate_info [ 'price' ] * $num ,
2025-11-25 18:29:45 +08:00
'day' => 0
];
2025-08-07 20:21:47 +08:00
}
$start_time = $now_time = time ();
Db :: startTrans ();
try {
$pay_price = $decorate_price_info [ 'price' ];
if ( $from_type == 1 ){
$log_remark = " 购买 " ;
//购买操作用户资金 金币是否足够
$reslut = model ( 'common/UserWallet' ) -> change_user_money ( $user_info [ 'id' ], $pay_price , 1 , model ( 'common/UserWallet' ) :: OPERATION_DECORATION , model ( 'common/UserWallet' ) :: ChangeTypeLable ( model ( 'common/UserWallet' ) :: OPERATION_DECORATION ));
if ( $reslut [ 'code' ] != 1 ) {
Db :: rollback ();
return [ 'code' => 0 , 'msg' => $reslut [ 'msg' ], 'data' => null ];
}
} else if ( $from_type == 4 && $give_uid ){
//购买操作用户资金 金币是否足够
$give_user_info = db :: name ( 'user' ) -> find ( $give_uid );
if ( ! $give_user_info ){
return [ 'code' => 0 , 'msg' => '赠送用户不存在' , 'data' => null ];
}
$log_remark = $give_user_info [ 'nickname' ] . " 赠送 " ;
$reslut = model ( 'common/UserWallet' ) -> change_user_money ( $give_uid , $pay_price , 1 , model ( 'common/UserWallet' ) :: OPERATION_DECORATION , model ( 'common/UserWallet' ) :: ChangeTypeLable ( model ( 'common/UserWallet' ) :: OPERATION_DECORATION ));
if ( $reslut [ 'code' ] != 1 ) {
Db :: rollback ();
return [ 'code' => 0 , 'msg' => $reslut [ 'msg' ], 'data' => null ];
}
}
//该用户是否有该装扮
$map = [];
$map = [
'user_id' => $user_info [ 'id' ],
'did' => $did ,
];
$user_decorate_data = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> find ();
$change_time = 0 ;
if ( empty ( $user_decorate_data )){
$data = [];
$data [ 'user_id' ] = $uid ;
$data [ 'did' ] = $did ;
$data [ 'type' ] = $decorate_info [ 'type' ];
if ( $decorate_price_info [ 'day' ] == 0 ){ //如果礼物购买配置的天数为0, 则永久有效
$data [ 'is_using' ] = 1 ;
$data [ 'end_time' ] = 0 ;
2025-11-25 18:29:45 +08:00
$data [ 'is_perpetual' ] = 1 ;
2025-08-07 20:21:47 +08:00
} else {
$change_time = $day * 24 * 3600 ;
$data [ 'is_using' ] = 2 ;
$data [ 'end_time' ] = $now_time + $change_time ;
}
$data [ 'createtime' ] = $now_time ;
2025-11-25 18:29:45 +08:00
$data [ 'special_num' ] = $decorate_info [ 'special_num' ] ? ? '' ;
2025-12-07 16:39:47 +08:00
$data [ 'num' ] = 1 ;
2025-08-07 20:21:47 +08:00
$result = db :: name ( 'vs_user_decorate' ) -> insert ( $data );
} else {
2025-11-25 18:29:45 +08:00
if ( $decorate_info [ 'type' ] == 12 ){
$result = db :: name ( 'vs_user_decorate' ) -> where ( 'udid' , $user_decorate_data [ 'udid' ]) -> update ([
'is_using' => 2 ,
'num' => $user_decorate_data [ 'num' ] + $num ,
'end_time' => 0
]);
} else {
if ( $decorate_price_info [ 'day' ] > 0 ){ //是不是永久礼物
if ( $decorate_price_info [ 'price' ] <= 0 && $user_decorate_data [ 'end_time' ] > $now_time + $change_time ){
return [ 'code' => 0 , 'msg' => '您已购买过此装扮,请勿重复购买' , 'data' => null ];
}
if ( $user_decorate_data [ 'end_time' ] < $now_time ){
2025-12-10 10:56:30 +08:00
$user_decorate_data [ 'end_time' ] = time ();
2025-11-25 18:29:45 +08:00
}
$change_time = $day * 24 * 3600 ;
$update [ 'is_using' ] = 2 ;
$update [ 'end_time' ] = $user_decorate_data [ 'end_time' ] + $change_time ;
$result = db :: name ( 'vs_user_decorate' ) -> where ( 'udid' , $user_decorate_data [ 'udid' ]) -> update ( $update );
$start_time = $update [ 'end_time' ];
2025-10-20 09:59:39 +08:00
}
2025-08-07 20:21:47 +08:00
}
}
if ( ! $result ){
Db :: rollback ();
return [ 'code' => 0 , 'msg' => '操作失败' , 'data' => null ];
}
//记录日志
$insert_data = [];
$insert_data [ 'user_id' ] = $uid ;
$insert_data [ 'type' ] = $decorate_info [ 'type' ];
$insert_data [ 'did' ] = $did ;
$insert_data [ 'createtime' ] = $now_time ;
$insert_data [ 'remark' ] = $log_remark ;
$insert_data [ 'from_type' ] = $from_type ;
$insert_data [ 'start_time' ] = $start_time ;
$insert_data [ 'end_time' ] = $start_time + $change_time ;
if ( $decorate_price_info [ 'day' ] == 0 ){
$insert_data [ 'end_time' ] = 0 ; //永久礼物
}
$insert_data [ 'day_num' ] = $day ;
$insert_data [ 'pay_price' ] = $pay_price ;
$insert_data [ 'special_num' ] = $decorate_info [ 'special_num' ];
$insert_data [ 'give_uid' ] = $give_uid ;
$result = db :: name ( 'vs_user_decorate_log' ) -> insert ( $insert_data );
if ( ! $result ){
Db :: rollback ();
return [ 'code' => 0 , 'msg' => '操作失败' , 'data' => null ];
}
//如果购买个人或房间靓号
if ( $decorate_info [ 'type' ] == 6 || $decorate_info [ 'type' ] == 7 || $decorate_info [ 'type' ] == 8 ) {
Db :: name ( 'vs_decorate' ) -> where ( 'did' , $decorate_info [ 'did' ]) -> update ([ 'is_user_buy' => 1 , 'updatetime' => time ()]);
}
// 提交事务
Db :: commit ();
return [ 'code' => 1 , 'msg' => " 购买成功 " , 'data' => null ];
} catch ( \Exception $e ) {
// 回滚事务
Db :: rollback ();
return [ 'code' => 0 , 'msg' => " 请重试 " , 'data' => null ];
}
}
//用户装扮列表
public function user_decorate ( $uid , $type , $page = 1 , $limit = 10 ){
2025-11-25 18:29:45 +08:00
if ( $type == 12 ){
$reslut = db :: name ( 'vs_user_decorate' )
-> alias ( 'ud' ) -> join ( 'vs_decorate d' , 'ud.did = d.did' )
2025-11-26 15:15:19 +08:00
-> field ( 'ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type,ud.num,d.ext_value' )
2025-11-25 18:29:45 +08:00
-> where ( 'ud.user_id' , $uid )
-> where ( 'ud.type' , $type )
-> where ([ 'ud.num' => [ " > " , 0 ]])
-> page ( $page , $limit )
-> select ();
} else {
$reslut = db :: name ( 'vs_user_decorate' )
-> alias ( 'ud' ) -> join ( 'vs_decorate d' , 'ud.did = d.did' )
-> field ( 'ud.udid,ud.user_id,ud.is_using,ud.end_time,ud.is_perpetual,ud.special_num,d.title,d.base_image,d.play_image,d.type' )
-> where ( 'ud.user_id' , $uid )
-> where ( 'ud.type' , $type )
-> where ([ 'ud.end_time' => [ " >= " , time ()]])
-> page ( $page , $limit )
-> select ();
foreach ( $reslut as $k => & $v ){
$remaining_day = ceil (( $v [ 'end_time' ] - time ()) / 86400 );
if ( $remaining_day <= 0 ){
$remaining_day = 0 ;
}
//剩余天数 取整
$v [ 'remaining_day' ] = $v [ 'is_perpetual' ] == 1 ? '永久' : $remaining_day ;
$v [ 'end_time' ] = date ( 'Y-m-d H:i:s' , $v [ 'end_time' ]);
}
2025-08-07 20:21:47 +08:00
}
return [ 'code' => 1 , 'msg' => " 获取成功 " , 'data' => $reslut ];
}
// 设置用户装修
public function set_user_decorate ( $uid , $udid )
{
$map = [];
$map = [
'user_id' => $uid ,
'udid' => $udid
];
$info = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> find ();
if ( empty ( $info )) {
return [ 'code' => 0 , 'msg' => '装扮不存在' , 'data' => null ];
}
2025-11-25 18:29:45 +08:00
if ( $info [ 'type' ] == 12 ){
if ( $info [ 'num' ] - 1 < 0 ) {
return [ 'code' => 0 , 'msg' => '无可用装扮' , 'data' => null ];
}
} else {
if ( $info [ 'end_time' ] < time ()) {
return [ 'code' => 0 , 'msg' => '装扮已过期' , 'data' => null ];
}
2025-08-07 20:21:47 +08:00
}
Db :: startTrans ();
try {
//清理该类型装扮使用状态
$map = [];
$map = [
'user_id' => $uid ,
'type' => $info [ 'type' ]
];
$data = [];
$data [ 'is_using' ] = 2 ;
$data [ 'updatetime' ] = time ();
$reslut = Db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> update ( $data );
if ( ! $reslut ) {
Db :: rollback ();
return [ 'code' => 0 , 'msg' => " 设置失败 " , 'data' => null ];
}
//设置使用中状态
$map = [];
$map = [
'udid' => $info [ 'udid' ]
];
$data = [];
$data [ 'is_using' ] = 1 ;
$data [ 'updatetime' ] = time ();
2025-11-25 18:29:45 +08:00
if ( $info [ 'type' ] == 12 ){
$data [ 'num' ] = $info [ 'num' ] - 1 ;
}
2025-08-07 20:21:47 +08:00
$reslut = Db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> update ( $data );
if ( ! $reslut ) {
Db :: rollback ();
return [ 'code' => 0 , 'msg' => " 设置失败 " , 'data' => null ];
}
// 提交事务
Db :: commit ();
2025-11-25 18:29:45 +08:00
if ( $info [ 'type' ] == 12 ){
//使用降身卡,降低用户身价
2025-11-26 16:05:01 +08:00
$reduce_ratio = db :: name ( 'vs_decorate' ) -> where ([ 'did' => $info [ 'did' ]]) -> value ( 'ext_value' ) ? ? 0 ;
2025-11-25 18:29:45 +08:00
$market_value = db :: name ( 'user' ) -> where ([ 'id' => $uid ]) -> value ( 'market_value' );
if ( $reduce_ratio ){
2025-12-02 16:46:53 +08:00
$reduce_market_value = $market_value * ( $reduce_ratio / 100 );
2025-11-25 18:29:45 +08:00
} else {
$reduce_market_value = 0 ;
}
if ( $reduce_market_value > 0 ){
$up_market_value = $market_value - $reduce_market_value ;
if ( $up_market_value < 1 ){
$up_market_value = 1 ;
}
db :: name ( 'user' ) -> where ([ 'id' => $uid ]) -> update ([ 'market_value' => $up_market_value ]);
//记录一条日志
db :: name ( 'vs_user_market_value_log' ) -> insert ([
2025-11-26 16:05:01 +08:00
'user_id' => $uid ,
2025-11-25 18:29:45 +08:00
'before' => $market_value ,
2025-11-26 16:05:01 +08:00
'change_value' => $reduce_market_value ,
2025-11-25 18:29:45 +08:00
'afterwards' => $up_market_value ,
'type' => 2 ,
'createtime' => time ()
]);
}
} else {
//推送信息去所在房间
//查询当前所在房间
$room_id = db :: name ( 'vs_room_visitor' ) -> where ([ 'user_id' => $uid ]) -> order ( 'id' , 'desc' ) -> value ( 'room_id' );
if ( $room_id ){
//当前用户信息
//推送信息
$text [ 'jia_jia' ] = model ( 'Decorate' ) -> user_decorate_detail ( $uid , 2 );
$text [ 'FromUserInfo' ] = db :: name ( 'user' ) -> where ( 'id' , $uid ) -> field ( 'id as user_id,nickname,avatar,sex' ) -> find ();
$text [ 'FromUserInfo' ][ 'dress' ] = model ( 'Decorate' ) -> user_decorate_detail ( $uid , 1 );
$text [ 'FromUserInfo' ][ 'mic_cycle' ] = model ( 'Decorate' ) -> user_decorate_detail ( $uid , 3 );
$text [ 'FromUserInfo' ][ 'chat_dress' ] = model ( 'Decorate' ) -> user_decorate_detail ( $uid , 5 );
$text [ 'text' ] = '用户 ' . $text [ 'FromUserInfo' ][ 'nickname' ] . ' 修改了信息' ;
model ( 'Chat' ) -> sendMsg ( 1035 , $room_id , $text , $uid );
}
2025-08-07 20:21:47 +08:00
}
2025-12-25 16:49:55 +08:00
//更新装备缓存
$cache_key = 'user_base_info_' . $uid ;
Cache :: rm ( $cache_key );
2025-08-07 20:21:47 +08:00
return [ 'code' => 1 , 'msg' => " 设置成功 " , 'data' => null ];
} catch ( \Exception $e ) {
// 回滚事务
Db :: rollback ();
return [ 'code' => 0 , 'msg' => " 设置失败 " , 'data' => null ];
}
}
//取消装扮
public function cancel_user_decorate ( $uid , $type )
{
//查询当前用户装扮
$user_decorate = db :: name ( 'vs_user_decorate' ) -> where ([ 'user_id' => $uid , 'type' => $type , 'is_using' => 1 , 'end_time' => [ '>' , time ()]]) -> find ();
if ( ! $user_decorate ) {
return [ 'code' => 0 , 'msg' => " 取消装扮失败,当前用户还未装扮 " , 'data' => null ];
}
$data = [];
$data [ 'is_using' ] = 2 ;
$data [ 'updatetime' ] = time ();
$reslut = Db :: name ( 'vs_user_decorate' ) -> where ( 'udid' , $user_decorate [ 'udid' ]) -> update ( $data );
if ( ! $reslut ) {
return [ 'code' => 0 , 'msg' => " 取消装扮失败 " , 'data' => null ];
}
2025-12-25 16:49:55 +08:00
//更新装备缓存
$cache_key = 'user_base_info_' . $uid ;
Cache :: rm ( $cache_key );
2025-08-07 20:21:47 +08:00
return [ 'code' => 1 , 'msg' => " 取消成功 " , 'data' => null ];
}
//用户装扮详情
/*
* @ param $id 对象id
2025-10-20 09:59:39 +08:00
* @ param $type 装扮类型 1 头像框 2 坐骑 3 麦圈 6 个人靓号 7 房间靓号 8 公会靓号
2025-08-07 20:21:47 +08:00
*/
2025-11-21 17:59:46 +08:00
public function user_decorate_detail ( $id , $type ){
//根据$type 组装查询条件
$reslut = " " ;
$map = [
'type' => $type ,
'is_using' => 1
];
if ( $type == 7 ){ //7房间靓号 8工会靓号
$room = db :: name ( 'vs_room' ) -> where ( 'id' , $id ) -> field ( 'user_id,room_number' ) -> find ();
if ( empty ( $room )){
return $reslut ;
}
$map [ 'user_id' ] = $room [ 'user_id' ];
$user_decorate = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> order ( 'createtime' , 'desc' ) -> find ();
if ( empty ( $user_decorate )){
2025-11-22 14:24:11 +08:00
return $room [ 'room_number' ];
2025-11-21 17:59:46 +08:00
}
if ( $user_decorate [ 'is_perpetual' ] == 2 && $user_decorate [ 'end_time' ] < time ()){
2025-11-22 14:24:11 +08:00
return $room [ 'room_number' ];
2025-11-21 17:59:46 +08:00
}
$reslut = $user_decorate [ 'special_num' ] ? ? $room [ 'room_number' ];
} elseif ( $type == 8 ){
$guild = db :: name ( 'vs_guild' ) -> where ( 'id' , $id ) -> field ( 'user_id,guild_special_id' ) -> find ();
if ( empty ( $guild )){
return $reslut ;
}
$map [ 'user_id' ] = $guild [ 'user_id' ];
$user_decorate = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> order ( 'createtime' , 'desc' ) -> find ();
if ( empty ( $user_decorate )){
2025-11-22 14:24:11 +08:00
return $guild [ 'guild_special_id' ];
2025-11-21 17:59:46 +08:00
}
if ( $user_decorate [ 'is_perpetual' ] == 2 && $user_decorate [ 'end_time' ] < time ()){
2025-11-22 14:24:11 +08:00
return $guild [ 'guild_special_id' ];
2025-11-21 17:59:46 +08:00
}
$reslut = $user_decorate [ 'special_num' ] ? ? $guild [ 'guild_special_id' ];
} elseif ( $type == 6 ){
$user_code = db :: name ( 'user' ) -> where ( 'id' , $id ) -> value ( 'user_code' );
if ( empty ( $user_code )){
return $reslut ;
}
$map [ 'user_id' ] = $id ;
$user_decorate = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> order ( 'createtime' , 'desc' ) -> find ();
if ( empty ( $user_decorate )){
2025-11-22 14:24:11 +08:00
return $user_code ;
2025-11-21 17:59:46 +08:00
}
if ( $user_decorate [ 'is_perpetual' ] == 2 && $user_decorate [ 'end_time' ] < time ()){
2025-11-22 14:24:11 +08:00
return $user_code ;
2025-11-21 17:59:46 +08:00
}
$reslut = $user_decorate [ 'special_num' ] ? ? $user_code ;
} else {
$map [ 'user_id' ] = $id ;
$user_decorate = db :: name ( 'vs_user_decorate' ) -> where ( $map ) -> order ( 'createtime' , 'desc' ) -> find ();
if ( empty ( $user_decorate )){
return $reslut ;
}
if ( $user_decorate [ 'is_perpetual' ] == 2 && $user_decorate [ 'end_time' ] < time ()){
return $reslut ;
}
2025-11-25 18:29:45 +08:00
if ( in_array ( $type , [ 9 , 12 ])){
2025-11-21 17:59:46 +08:00
$reslut = db :: name ( 'vs_decorate' ) -> where ( 'did' , $user_decorate [ 'did' ]) -> value ( 'base_image' );
} else {
$reslut = db :: name ( 'vs_decorate' ) -> where ( 'did' , $user_decorate [ 'did' ]) -> value ( 'play_image' );
}
}
return $reslut ;
}
2025-08-07 20:21:47 +08:00
}