diff --git a/application/api/controller/GiftNew.php b/application/api/controller/GiftNew.php new file mode 100644 index 00000000..f9845ef7 --- /dev/null +++ b/application/api/controller/GiftNew.php @@ -0,0 +1,29 @@ +uid; + redis_lock_exits($key_name); + $label = input('label', 0); + $type = input('type'); + if (empty($type)) { + return V(0, 'type参数错误'); + } + $reslut = model('GiftNew')->get_gift_list($this->uid, $type, $label); + redis_unlocks($key_name); + return V($reslut['code'], $reslut['msg'], $reslut['data']); + } +} \ No newline at end of file diff --git a/application/api/model/GiftNew.php b/application/api/model/GiftNew.php new file mode 100644 index 00000000..f07a068b --- /dev/null +++ b/application/api/model/GiftNew.php @@ -0,0 +1,79 @@ +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; + 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(); + + + //================================到这里结束逻辑================================== + + //设置缓存 + Cache::set($cache_key, json_encode($list), 3600); + return ['code' => 1, 'msg' => '获取成功', 'data' => $list]; + } + +} \ No newline at end of file