1234567891011121314151617181920212223242526272829303132333435363738 |
- <?php
- namespace app\youzan\logic;
- use app\youzan\model\YzCat;
- use think\facade\Cache;
- //有赞 分类处理层
- class Cat
- {
- private static $cache_key = 'yz_cat_list_pid_';
- //获取分类列表
- public static function getYzCatList(int $parent_cid = 0)
- {
- $key = self::$cache_key . (string)$parent_cid;
- $rs = Cache::get($key);
- if (empty($rs) || $rs==false) {
- $rs = YzCat::field('id,rule_id yz_cat_id,name yz_cat_name,parent_id parent_cid,level,has_children')//id,yz_cat_id,yz_cat_name,parent_cid
- ->where('status', YzCat::$status_normal)
- ->where('parent_id', $parent_cid)
- ->order('id')
- ->select()
- ->toArray();
- Cache::set($key, $rs, 3600);
- }
- return $rs;
- }
- }
|