getUserNobilityInfo($user_id); $power_list_ids = array_column($Nobility['power_list'],'id'); if(!in_array(5,$power_list_ids)){ $is_lock = 1; } } //1,先从缓存获取 if($is_lock){//根据这个判断是不是爵位礼物 创建不同的key $cache_key = 'gift_list_'.$label.'_'.$is_lock; }else{ $cache_key = 'gift_list_'.$label; } //2,缓存获取 $list = json_decode(Cache::get($cache_key), true); //获取到就返回 if($list){ return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; } //================================从这里开始写逻辑================================== //根据type的值分析拉起礼物的场合 加$label的条件 给出对应的列表 //根据类型组装查询条件 $where['is_show'] = 1; $where['delete_time'] = 0; if ($label == 99) { $gift_price = get_system_config_value('room_love_auction_cion'); $where['gift_price'] = ['>',$gift_price]; $where['label'] = ['<>',2]; } switch ($type) { case 1: $where['label'] = $label; break; case 2: $where['label'] = 5; break; case 3: $where['type'] = 1; //爆币id $bb_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); $where['gid'] = ['<>',$bb_gift_id];//拍卖位选礼物 不能是爆币这个礼物 break; case 4: $where['type'] = 1; $where['gift_price'] = ['>',128];//歌单礼物价格要大于128 老板26年1月2号提的要求 break; case 5: $where['type'] = 1; break; } $list = db::name('vs_gift') ->field('gid as gift_id,gift_name,base_image,gift_price,icon') ->where($where)->order('sort desc, gift_price asc')->select(); if($label==2){ foreach ($list as &$v) { //获取盲盒列表 $box_list = Db::name('vs_gift_bag')->where(['status'=>1])->where(['activities_id'=>["in",[4,5]]])->select(); foreach ($box_list as $key =>$box) { $ext = json_decode($box['ext'],true); if ($ext['gift_id'] == $v['gift_id']) { $v['gift_bag_name'] = $box['name']; $v['rule'] = $ext['description']; $v['rule_url'] = get_system_config_value('web_site')."/api/Page/get_gift_box_rule?box_id=".$box["id"]; $v['activities_id'] = $box['activities_id']; $v['gift_bag'] = $box['id']; break; } } //爆币 $pool_gift_id = db::name('bb_lottery_config')->where(['key' => 'pool_gift_id'])->value('value'); if($pool_gift_id == $v['gift_id']){ $v['gift_bag_name'] = "幸运币活动"; $v['rule'] = "幸运羽币"; $v['rule_url'] = get_system_config_value('web_site')."/api/Page/page_show?id=35"; $v['activities_id'] = 88; $v['gift_bag'] = 0; } } }else{ //获取配置里面的CP礼物 $cp_gift_ids = explode(',', get_system_config_value('cp_gift_id')); $teacher_gift_ids = explode(',', get_system_config_value('master_special_gift')); foreach ($list as $key =>&$v) { $v['is_lock'] = $is_lock; if (in_array($v['gift_id'], $cp_gift_ids)) { $v['is_cp'] = 1; }else{ $v['is_cp'] = 0; } if (in_array($v['gift_id'], $teacher_gift_ids)) { $v['is_teacher'] = 1; }else{ $v['is_teacher'] = 0; } } } //================================到这里结束逻辑================================== //设置缓存 Cache::set($cache_key, json_encode($list), 3600); return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; } }