作者 李宇航

合并分支 'develop' 到 'master'

Develop



查看合并请求 !386
@@ -40,7 +40,7 @@ class CategoryController extends BaseController @@ -40,7 +40,7 @@ class CategoryController extends BaseController
40 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id 40 $template_id = $this->getTemplateId(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST);//获取模版id
41 foreach ($list as $k =>$v){ 41 foreach ($list as $k =>$v){
42 $v['url'] = $this->user['domain'] . $v['route'].'/'; 42 $v['url'] = $this->user['domain'] . $v['route'].'/';
43 - $v['product_num'] = Category::getProductNum($v['id']); 43 + $v['product_num'] = $category->getProductNum($v['id']);
44 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']); 44 $v['image_link'] = getImageUrl($v['image'],$this->user['storage_type'],$this->user['project_location']);
45 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']); 45 $v['is_renovation'] = $this->getIsRenovation(BTemplate::SOURCE_PRODUCT,BTemplate::IS_LIST,$template_id,$v['id']);
46 $list[$k] = $v; 46 $list[$k] = $v;
@@ -41,7 +41,23 @@ class Category extends Base @@ -41,7 +41,23 @@ class Category extends Base
41 return $ids; 41 return $ids;
42 } 42 }
43 43
44 - 44 + /**
  45 + * @remark :获取当前id下所有子集
  46 + * @name :getAllSub
  47 + * @author :lyh
  48 + * @method :post
  49 + * @time :2023/10/18 15:10
  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){
  55 + $str[] = $v['id'];
  56 + $this->getAllSub($v['id'],$str);
  57 + }
  58 + }
  59 + return $str;
  60 + }
45 61
46 /** 62 /**
47 * 关联产品数量 63 * 关联产品数量
@@ -50,8 +66,9 @@ class Category extends Base @@ -50,8 +66,9 @@ class Category extends Base
50 * @author zbj 66 * @author zbj
51 * @date 2023/4/28 67 * @date 2023/4/28
52 */ 68 */
53 - public static function getProductNum($cate_id){  
54 - $cate_ids = self::getChildIdsArr($cate_id); 69 + public function getProductNum($cate_id){
  70 + $str = [];
  71 + $cate_ids = $this->getAllSub($cate_id,$str);
55 $count = CategoryRelated::whereIn('cate_id',$cate_ids)->count(); 72 $count = CategoryRelated::whereIn('cate_id',$cate_ids)->count();
56 // $str = 0; 73 // $str = 0;
57 return $count; 74 return $count;