From c691072200bc760f97767f07ab96d094efa10faa Mon Sep 17 00:00:00 2001 From: devil_gong Date: Tue, 22 Jan 2019 13:38:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E5=AD=97=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E7=AD=9B=E9=80=89=E5=93=81=E7=89=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/index/controller/Search.php | 2 +- application/service/AdminService.php | 2 +- application/service/BrandService.php | 11 +++++++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/application/index/controller/Search.php b/application/index/controller/Search.php index ad4cab1cf..6bce25186 100755 --- a/application/index/controller/Search.php +++ b/application/index/controller/Search.php @@ -71,7 +71,7 @@ class Search extends Common return redirect(MyUrl('index/search/index', $p)); } else { // 品牌列表 - $this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id']])); + $this->assign('brand_list', BrandService::CategoryBrandList(['category_id'=>$this->params['category_id'], 'keywords'=>$this->params['keywords']])); // 商品分类 $this->assign('category_list', SearchService::GoodsCategoryList(['category_id'=>$this->params['category_id']])); diff --git a/application/service/AdminService.php b/application/service/AdminService.php index 5a1569066..f8b1ae019 100755 --- a/application/service/AdminService.php +++ b/application/service/AdminService.php @@ -63,7 +63,7 @@ class AdminService $where = []; if(!empty($params['username'])) { - $where[] =['username', 'like', '%'.$params['username'].'%']; + $where[] = ['username', 'like', '%'.$params['username'].'%']; } if(isset($params['role_id']) && $params['role_id'] > -1) { diff --git a/application/service/BrandService.php b/application/service/BrandService.php index c8034c0f2..7e4fa4a58 100755 --- a/application/service/BrandService.php +++ b/application/service/BrandService.php @@ -172,6 +172,8 @@ class BrandService public static function CategoryBrandList($params = []) { $brand_where = ['is_enable'=>1]; + + // 分类id if(!empty($params['category_id'])) { // 根据分类获取品牌id @@ -181,6 +183,15 @@ class BrandService $brand_where['id'] = Db::name('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'); } + // 关键字 + if(!empty($params['keywords'])) + { + $where = [ + ['title', 'like', '%'.$params['keywords'].'%'] + ]; + $brand_where['id'] = Db::name('Goods')->where($where)->group('brand_id')->column('brand_id'); + } + // 获取品牌列表 $brand = Db::name('Brand')->where($brand_where)->field('id,name,logo,website_url')->select(); if(!empty($brand)) -- GitLab