model = new LevelSettingModel(); } /** * 静态化入口 * @return static|null */ public static function make() { if(!self::$instance){ self::$instance = new static(); } return self::$instance; } /** * 按类型获取列表 * @param $display * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getListData($display=0) { $cacheKey = "caches:levels:list_{$display}"; $data = RedisCache::get($cacheKey); if($data){ return $data; } $where = []; if($display){ $where['display'] = $display; } $data = $this->model->where($where)->select(); $data = $data? $data->toArray():[]; if($data){ RedisCache::set($cacheKey, $data, rand(5,10)); } return $data; } /** * 按类型获取列表 * @param $level 等级 * @param $type 升级方式:1-自动,2-手动 * @return array|mixed * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException */ public function getConfigData($level=0, $type=0) { $cacheKey = "caches:temp:levels:config_{$level}_{$type}"; $data = RedisCache::get($cacheKey); if($data){ return $data; } $where = []; if($level){ $where['level'] = $level; } if($type){ $where['type'] = $type; } $data = $this->model->where($where)->column('level,total_money,dynamic_scale,zt_money,zt_num,team_num,zt_level','level'); if($data){ RedisCache::set($cacheKey, $data, 3600); } return $data; } }