diff --git a/application/service/BrandService.php b/application/service/BrandService.php index 243ace959fa6557be6c7a0c3b028cf7e7f015cde..2c7ef83503ea19d3c9e615c0ea983a88e17ea4bb 100755 --- a/application/service/BrandService.php +++ b/application/service/BrandService.php @@ -106,7 +106,7 @@ class BrandService if(!empty($params['category_id'])) { // 根据分类获取品牌id - $category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']]); + $category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']], 1); $where = ['g.is_delete_time'=>0, 'g.is_shelves'=>1, 'gci.id'=>$category_ids]; $brand_where['id'] = db('Goods')->alias('g')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'g.id=gci.goods_id')->field('g.brand_id')->where($where)->group('g.brand_id')->column('brand_id'); } diff --git a/application/service/GoodsService.php b/application/service/GoodsService.php index 7e702703ae23fade77d07ac364ecbdf289f704b1..98c8a31dda23c679d6f69cfdc2789c259a2b7054 100755 --- a/application/service/GoodsService.php +++ b/application/service/GoodsService.php @@ -144,7 +144,7 @@ class GoodsService { foreach($goods_category as &$v) { - $category_ids = self::GoodsCategoryItemsIds([$v['id']]); + $category_ids = self::GoodsCategoryItemsIds([$v['id']], 1); $v['goods'] = self::CategoryGoodsList(['where'=>['gci.category_id'=>$category_ids, 'is_home_recommended'=>1], 'm'=>0, 'n'=>6, 'field'=>'g.id,g.title,g.title_color,g.images,g.home_recommended_images,g.original_price,g.price,g.inventory,g.buy_min_number,g.buy_max_number']); } } @@ -159,11 +159,16 @@ class GoodsService * @date 2018-08-29 * @desc description * @param [array] $ids [分类id数组] - * @param [int] $is_enable [是否启用 0否, 1是] + * @param [int] $is_enable [是否启用 null, 0否, 1是] */ - public static function GoodsCategoryItemsIds($ids = [], $is_enable = 1) + public static function GoodsCategoryItemsIds($ids = [], $is_enable = null) { - $data = db('GoodsCategory')->where(['pid'=>$ids, 'is_enable'=>$is_enable])->column('id'); + $where = ['pid'=>$ids]; + if($is_enable !== null) + { + $where['is_enable'] = $is_enable; + } + $data = db('GoodsCategory')->where($where)->column('id'); if(!empty($data)) { $temp = self::GoodsCategoryItemsIds($data, $is_enable); diff --git a/application/service/SearchService.php b/application/service/SearchService.php index 29a724129410c596100860b7253b8da2a9a8fdb0..00c3bb3f9c159ddee4f11ad39ff397513e1eab93 100755 --- a/application/service/SearchService.php +++ b/application/service/SearchService.php @@ -78,7 +78,7 @@ class SearchService // 分类id if(!empty($params['category_id'])) { - $category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']]); + $category_ids = GoodsService::GoodsCategoryItemsIds([$params['category_id']], 1); $category_ids[] = $params['category_id']; $where[] = ['gci.category_id', 'in', $category_ids]; }