diff --git a/application/index/controller/Search.php b/application/index/controller/Search.php index ad4cab1cff51fe861e95a5ed37271529dafc5ad0..6bce25186980f80e0b9e8faa53b2ead31c85b77e 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 5a1569066fe217a35dd8a3a7c644706f5b28edee..f8b1ae0196434cdfa78a4272b2f1083e89960a58 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 c8034c0f28ec13155df138a1b67063f012c3670b..7e4fa4a589b3715e9a8ef11d70e7867007711339 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))