|
...
|
...
|
@@ -48,12 +48,11 @@ class Category extends Base |
|
|
|
* @method :post
|
|
|
|
* @time :2023/10/18 15:10
|
|
|
|
*/
|
|
|
|
public function getAllSub($id,&$str = []){
|
|
|
|
$list = $this->list(['pid'=>$id,'status'=>1],['id','pid']);
|
|
|
|
if(!empty($list)){
|
|
|
|
foreach ($list as $v){
|
|
|
|
public function getAllSub($list,$id,&$str = []){
|
|
|
|
foreach ($list as $k =>$v){
|
|
|
|
if($v['pid'] == $id){
|
|
|
|
$str[] = $v['id'];
|
|
|
|
$this->getAllSub($v['id'],$str);
|
|
|
|
$this->getAllSub($list,$v['id'],$str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $str;
|
|
...
|
...
|
@@ -66,9 +65,9 @@ class Category extends Base |
|
|
|
* @author zbj
|
|
|
|
* @date 2023/4/28
|
|
|
|
*/
|
|
|
|
public function getProductNum($cate_id){
|
|
|
|
public function getProductNum($list,$cate_id){
|
|
|
|
$str[] = $cate_id;
|
|
|
|
$cate_ids = $this->getAllSub($cate_id,$str);
|
|
|
|
$cate_ids = $this->getAllSub($list,$cate_id,$str);
|
|
|
|
$productArr = CategoryRelated::whereIn('cate_id',$cate_ids)->pluck('product_id')->unique()->toArray();
|
|
|
|
$count = count($productArr);
|
|
|
|
return $count;
|
...
|
...
|
|