作者 lyh

gx

@@ -41,24 +41,7 @@ class Category extends Base @@ -41,24 +41,7 @@ class Category extends Base
41 return $ids; 41 return $ids;
42 } 42 }
43 43
44 - /**  
45 - * @remark :获取当前id下所有子集  
46 - * @name :getAllSub  
47 - * @author :lyh  
48 - * @method :post  
49 - * @time :2023/10/18 15:10  
50 - */  
51 - public static function getAllSub($id,&$str = []){  
52 - $cateModel = new Category();  
53 - $list = $cateModel->list(['pid'=>$id,'status'=>1],['id','pid']);  
54 - if(!empty($list)){  
55 - foreach ($list as $v){  
56 - $str[] = $v['id'];  
57 - self::getAllSub($v['id'],$str);  
58 - }  
59 - }  
60 - return $str;  
61 - } 44 +
62 45
63 /** 46 /**
64 * 关联产品数量 47 * 关联产品数量
@@ -68,8 +51,9 @@ class Category extends Base @@ -68,8 +51,9 @@ class Category extends Base
68 * @date 2023/4/28 51 * @date 2023/4/28
69 */ 52 */
70 public static function getProductNum($cate_id){ 53 public static function getProductNum($cate_id){
71 - $cate_ids = self::getAllSub($cate_id,$str); 54 + $cate_ids = self::getChildIdsArr($cate_id);
72 $count = CategoryRelated::whereIn('cate_id',$cate_ids)->count(); 55 $count = CategoryRelated::whereIn('cate_id',$cate_ids)->count();
  56 +// $str = 0;
73 return $count; 57 return $count;
74 } 58 }
75 } 59 }