Cat.php 827 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\youzan\logic;
  3. use app\youzan\model\YzCat;
  4. use think\facade\Cache;
  5. //有赞 分类处理层
  6. class Cat
  7. {
  8. private static $cache_key = 'yz_cat_list_pid_';
  9. //获取分类列表
  10. public static function getYzCatList(int $parent_cid = 0)
  11. {
  12. $key = self::$cache_key . (string)$parent_cid;
  13. $rs = Cache::get($key);
  14. if (empty($rs) || $rs==false) {
  15. $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
  16. ->where('status', YzCat::$status_normal)
  17. ->where('parent_id', $parent_cid)
  18. ->order('id')
  19. ->select()
  20. ->toArray();
  21. Cache::set($key, $rs, 3600);
  22. }
  23. return $rs;
  24. }
  25. }