From 434caca2b05fe0467aa8a05066ecd9d01a1f28e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Thu, 25 Dec 2025 16:20:02 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A4=BC=E7=89=A9=E5=88=97=E8=A1=A8=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Gift.php | 36 +++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/application/api/model/Gift.php b/application/api/model/Gift.php index 957f5ad2..a135f467 100644 --- a/application/api/model/Gift.php +++ b/application/api/model/Gift.php @@ -1,6 +1,7 @@ 1, 'msg' => '获取成功', 'data' => $giftType]; } - //拉去礼物列表 + //拉取礼物列表 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; $where['is_show'] = 1; if ($label && $label != 99) { @@ -40,7 +62,7 @@ class Gift extends Model $where['gift_price'] = ['>',$gift_price]; $where['label'] = ['<>',2]; } - $is_lock = 0; + $is_open_blind_box_turntable = 1; // if($room_id){ // $is_open_blind_box_turntable = Db::name('vs_room')->where(['id'=>$room_id])->value('is_open_blind_box_turntable'); @@ -86,13 +108,7 @@ class Gift extends Model // }); $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_gift_ids = explode(',', get_system_config_value('cp_gift_id')); $teacher_gift_ids = explode(',', get_system_config_value('master_special_gift')); @@ -122,6 +138,8 @@ class Gift extends Model if ($teacher_gift) { array_unshift($list, ...$teacher_gift); } + //设置缓存 + Cache::set($cache_key, json_encode($list), 3600); return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; } }