|
@@ -48,12 +48,11 @@ class Category extends Base |
|
@@ -48,12 +48,11 @@ class Category extends Base |
|
48
|
* @method :post
|
48
|
* @method :post
|
|
49
|
* @time :2023/10/18 15:10
|
49
|
* @time :2023/10/18 15:10
|
|
50
|
*/
|
50
|
*/
|
|
51
|
- public function getAllSub($id,&$str = []){
|
|
|
|
52
|
- $list = $this->list(['pid'=>$id,'status'=>1],['id','pid']);
|
|
|
|
53
|
- if(!empty($list)){
|
|
|
|
54
|
- foreach ($list as $v){
|
51
|
+ public function getAllSub($list,$id,&$str = []){
|
|
|
|
52
|
+ foreach ($list as $k =>$v){
|
|
|
|
53
|
+ if($v['pid'] == $id){
|
|
55
|
$str[] = $v['id'];
|
54
|
$str[] = $v['id'];
|
|
56
|
- $this->getAllSub($v['id'],$str);
|
55
|
+ $this->getAllSub($list,$v['id'],$str);
|
|
57
|
}
|
56
|
}
|
|
58
|
}
|
57
|
}
|
|
59
|
return $str;
|
58
|
return $str;
|
|
@@ -66,9 +65,9 @@ class Category extends Base |
|
@@ -66,9 +65,9 @@ class Category extends Base |
|
66
|
* @author zbj
|
65
|
* @author zbj
|
|
67
|
* @date 2023/4/28
|
66
|
* @date 2023/4/28
|
|
68
|
*/
|
67
|
*/
|
|
69
|
- public function getProductNum($cate_id){
|
68
|
+ public function getProductNum($list,$cate_id){
|
|
70
|
$str[] = $cate_id;
|
69
|
$str[] = $cate_id;
|
|
71
|
- $cate_ids = $this->getAllSub($cate_id,$str);
|
70
|
+ $cate_ids = $this->getAllSub($list,$cate_id,$str);
|
|
72
|
$productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->unique()->toArray();
|
71
|
$productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->unique()->toArray();
|
|
73
|
$count = count($productArr);
|
72
|
$count = count($productArr);
|
|
74
|
return $count;
|
73
|
return $count;
|