From 97ee12475db1ae733474e32ebcf6051c73a643c7 Mon Sep 17 00:00:00 2001 From: gengpeijie <gpj@bronet.cn> Date: Mon, 8 Jun 2020 10:56:18 +0800 Subject: [PATCH] 修改搜索商品接口 --- application/api/controller/Goods.php | 6 ++---- application/api/model/Category.php | 7 ++++++- application/api/model/Goods.php | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/api/controller/Goods.php b/application/api/controller/Goods.php index 9fb22ec..6fe7b36 100755 --- a/application/api/controller/Goods.php +++ b/application/api/controller/Goods.php @@ -321,14 +321,12 @@ class Goods extends Api if (!empty($params['level_id'])) $where['level_id'] = $params['level_id']; if (!empty($params['part_id'])) $where['part_id'] = $params['part_id']; if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id']; - $goodsWhere = $where; - $where['ch_name|en_name|ch_content|en_content'] = ['like','%'.$params['keyword'].'%']; - $goodsWhere['g.ch_name|g.en_name|g.ch_content|g.en_content'] = ['like','%'.$params['keyword'].'%']; + $where['g.ch_name|g.en_name|g.ch_content|g.en_content|cate1.name|cate2.name|cate3.name'] = ['like','%'.$params['keyword'].'%']; //获取筛选标签,国家,品牌,等级,部位,品类 $data['extend'] = $this->categoryModel->getExtend($where,$this->lang); //获取列表数据 - $data['list'] = $this->goodsModel->selectPageData($goodsWhere,$page,$limit,$this->lang); + $data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang); $this->success('请求成功', $data); } diff --git a/application/api/model/Category.php b/application/api/model/Category.php index a2fbb0a..35e6d81 100755 --- a/application/api/model/Category.php +++ b/application/api/model/Category.php @@ -30,7 +30,12 @@ class Category extends Model public function getExtend($where,$lang) { $goodsModel = new Goods(); - $ids = $goodsModel->where($where)->column('country_id,brand_id,level_id,part_id,category2_id'); + $ids = $goodsModel->alias('g') + ->join('fa_category cate1', 'g.category_one_id=cate1.id') + ->join('fa_category cate2', 'g.category_two_id=cate2.id') + ->join('fa_category cate3', 'g.category_three_id=cate3.id') + ->where($where) + ->column('country_id,brand_id,level_id,part_id,category2_id'); $countryids = []; $brandids = []; diff --git a/application/api/model/Goods.php b/application/api/model/Goods.php index f8a3a32..bd3eafb 100755 --- a/application/api/model/Goods.php +++ b/application/api/model/Goods.php @@ -142,11 +142,17 @@ class Goods extends Model $total = $this->alias('g') ->join('fa_country c', 'g.country_id=c.id') + ->join('fa_category cate1', 'g.category_one_id=cate1.id') + ->join('fa_category cate2', 'g.category_two_id=cate2.id') + ->join('fa_category cate3', 'g.category_three_id=cate3.id') ->where($where) ->count(); $list = $this->alias('g') ->join('fa_country c', 'g.country_id=c.id') + ->join('fa_category cate1', 'g.category_one_id=cate1.id') + ->join('fa_category cate2', 'g.category_two_id=cate2.id') + ->join('fa_category cate3', 'g.category_three_id=cate3.id') ->where($where) ->field($field) ->order('g.weigh desc') -- libgit2 0.24.0