From 2360fc51ee31b888f6c45ce9a769e085adbb9733 Mon Sep 17 00:00:00 2001 From: gongfuxiang <2499232802@qq.com> Date: Mon, 17 Dec 2018 03:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=B1=BBids=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/service/BrandService.php | 2 +- application/service/GoodsService.php | 13 +++++++++---- application/service/SearchService.php | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/application/service/BrandService.php b/application/service/BrandService.php index 243ace959..2c7ef8350 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 7e702703a..98c8a31dd 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 29a724129..00c3bb3f9 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]; } -- GitLab