Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2025-12-25 16:29:20 +08:00

View File

@@ -1,6 +1,7 @@
<?php <?php
namespace app\api\model; namespace app\api\model;
use think\Cache;
use think\Model; use think\Model;
use think\Db; use think\Db;
use think\Session; use think\Session;
@@ -19,6 +20,7 @@ class Gift extends Model
//获取礼物类型 //获取礼物类型
public function get_gift_label() public function get_gift_label()
{ {
$giftType = [];
$giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->where('tid',1)->order("sort asc,id desc")->select(); $giftTypeData = db::name('vs_gift_label')->where('delete_time',0)->where('tid',1)->order("sort asc,id desc")->select();
foreach ($giftTypeData as $key => $value) { foreach ($giftTypeData as $key => $value) {
$giftType[$key]['id'] = $value['id']; $giftType[$key]['id'] = $value['id'];
@@ -27,9 +29,30 @@ class Gift extends Model
return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType]; return ['code' => 1, 'msg' => '获取成功', 'data' => $giftType];
} }
//拉礼物列表 //拉礼物列表
public function get_gift_list($label = 0,$room_id = 0,$user_id = 0) public function get_gift_list($label = 0,$room_id = 0,$user_id = 0)
{ {
$is_lock = 0;
if ($label == 13) { // 专属礼物
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
$power_list_ids = array_column($Nobility['power_list'],'id');
if(!in_array(5,$power_list_ids)){
$is_lock = 1;
}
}
//先从缓存获取
if($is_lock){
$cache_key = 'gift_list_'.$label.'_'.$is_lock;
}else{
$cache_key = 'gift_list_'.$label;
}
$list = json_decode(Cache::get($cache_key), true);
if($list){
return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
}
$map['delete_time'] = 0; $map['delete_time'] = 0;
$where['is_show'] = 1; $where['is_show'] = 1;
if ($label && $label != 99) { if ($label && $label != 99) {
@@ -40,7 +63,7 @@ class Gift extends Model
$where['gift_price'] = ['>',$gift_price]; $where['gift_price'] = ['>',$gift_price];
$where['label'] = ['<>',2]; $where['label'] = ['<>',2];
} }
$is_lock = 0;
$is_open_blind_box_turntable = 1; $is_open_blind_box_turntable = 1;
// if($room_id){ // if($room_id){
// $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable'); // $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable');
@@ -86,13 +109,7 @@ class Gift extends Model
// }); // });
$list = $list_data; $list = $list_data;
} }
if ($label == 13) { // 专属礼物
$Nobility = model('api/Nobility')->getUserNobilityInfo($user_id);
$power_list_ids = array_column($Nobility['power_list'],'id');
if(!in_array(5,$power_list_ids)){
$is_lock = 1;
}
}
//获取配置里面的CP礼物 //获取配置里面的CP礼物
$cp_gift_ids = explode(',', get_system_config_value('cp_gift_id')); $cp_gift_ids = explode(',', get_system_config_value('cp_gift_id'));
$teacher_gift_ids = explode(',', get_system_config_value('master_special_gift')); $teacher_gift_ids = explode(',', get_system_config_value('master_special_gift'));
@@ -122,6 +139,8 @@ class Gift extends Model
if ($teacher_gift) { if ($teacher_gift) {
array_unshift($list, ...$teacher_gift); array_unshift($list, ...$teacher_gift);
} }
//设置缓存
Cache::set($cache_key, json_encode($list), 3600);
return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; return ['code' => 1, 'msg' => '获取成功', 'data' => $list];
} }
} }