正在显示
3 个修改的文件
包含
14 行增加
和
5 行删除
@@ -321,14 +321,12 @@ class Goods extends Api | @@ -321,14 +321,12 @@ class Goods extends Api | ||
321 | if (!empty($params['level_id'])) $where['level_id'] = $params['level_id']; | 321 | if (!empty($params['level_id'])) $where['level_id'] = $params['level_id']; |
322 | if (!empty($params['part_id'])) $where['part_id'] = $params['part_id']; | 322 | if (!empty($params['part_id'])) $where['part_id'] = $params['part_id']; |
323 | if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id']; | 323 | if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id']; |
324 | - $goodsWhere = $where; | ||
325 | - $where['ch_name|en_name|ch_content|en_content'] = ['like','%'.$params['keyword'].'%']; | ||
326 | - $goodsWhere['g.ch_name|g.en_name|g.ch_content|g.en_content'] = ['like','%'.$params['keyword'].'%']; | ||
327 | 324 | ||
325 | + $where['g.ch_name|g.en_name|g.ch_content|g.en_content|cate1.name|cate2.name|cate3.name'] = ['like','%'.$params['keyword'].'%']; | ||
328 | //获取筛选标签,国家,品牌,等级,部位,品类 | 326 | //获取筛选标签,国家,品牌,等级,部位,品类 |
329 | $data['extend'] = $this->categoryModel->getExtend($where,$this->lang); | 327 | $data['extend'] = $this->categoryModel->getExtend($where,$this->lang); |
330 | //获取列表数据 | 328 | //获取列表数据 |
331 | - $data['list'] = $this->goodsModel->selectPageData($goodsWhere,$page,$limit,$this->lang); | 329 | + $data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang); |
332 | 330 | ||
333 | $this->success('请求成功', $data); | 331 | $this->success('请求成功', $data); |
334 | } | 332 | } |
@@ -30,7 +30,12 @@ class Category extends Model | @@ -30,7 +30,12 @@ class Category extends Model | ||
30 | public function getExtend($where,$lang) | 30 | public function getExtend($where,$lang) |
31 | { | 31 | { |
32 | $goodsModel = new Goods(); | 32 | $goodsModel = new Goods(); |
33 | - $ids = $goodsModel->where($where)->column('country_id,brand_id,level_id,part_id,category2_id'); | 33 | + $ids = $goodsModel->alias('g') |
34 | + ->join('fa_category cate1', 'g.category_one_id=cate1.id') | ||
35 | + ->join('fa_category cate2', 'g.category_two_id=cate2.id') | ||
36 | + ->join('fa_category cate3', 'g.category_three_id=cate3.id') | ||
37 | + ->where($where) | ||
38 | + ->column('country_id,brand_id,level_id,part_id,category2_id'); | ||
34 | 39 | ||
35 | $countryids = []; | 40 | $countryids = []; |
36 | $brandids = []; | 41 | $brandids = []; |
@@ -142,11 +142,17 @@ class Goods extends Model | @@ -142,11 +142,17 @@ class Goods extends Model | ||
142 | 142 | ||
143 | $total = $this->alias('g') | 143 | $total = $this->alias('g') |
144 | ->join('fa_country c', 'g.country_id=c.id') | 144 | ->join('fa_country c', 'g.country_id=c.id') |
145 | + ->join('fa_category cate1', 'g.category_one_id=cate1.id') | ||
146 | + ->join('fa_category cate2', 'g.category_two_id=cate2.id') | ||
147 | + ->join('fa_category cate3', 'g.category_three_id=cate3.id') | ||
145 | ->where($where) | 148 | ->where($where) |
146 | ->count(); | 149 | ->count(); |
147 | 150 | ||
148 | $list = $this->alias('g') | 151 | $list = $this->alias('g') |
149 | ->join('fa_country c', 'g.country_id=c.id') | 152 | ->join('fa_country c', 'g.country_id=c.id') |
153 | + ->join('fa_category cate1', 'g.category_one_id=cate1.id') | ||
154 | + ->join('fa_category cate2', 'g.category_two_id=cate2.id') | ||
155 | + ->join('fa_category cate3', 'g.category_three_id=cate3.id') | ||
150 | ->where($where) | 156 | ->where($where) |
151 | ->field($field) | 157 | ->field($field) |
152 | ->order('g.weigh desc') | 158 | ->order('g.weigh desc') |
-
请 注册 或 登录 后发表评论