正在显示
3 个修改的文件
包含
12 行增加
和
4 行删除
@@ -338,11 +338,16 @@ class Goods extends Api | @@ -338,11 +338,16 @@ class Goods extends Api | ||
338 | if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id']; | 338 | if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id']; |
339 | 339 | ||
340 | // $where['g.ch_name|g.en_name|g.ch_content|g.en_content|cate1.name|cate2.name|cate3.name'] = ['like','%'.$params['keyword'].'%']; | 340 | // $where['g.ch_name|g.en_name|g.ch_content|g.en_content|cate1.name|cate2.name|cate3.name'] = ['like','%'.$params['keyword'].'%']; |
341 | + $cateWhere['name'] = $params['keyword']; | ||
342 | + $cateWhere['en_name'] = $params['keyword']; | ||
343 | + $cateIds = $this->categoryModel->whereOr($cateWhere)->column('id'); | ||
344 | + $cateIds = implode(',',$cateIds); | ||
345 | + $whereOr['g.category_one_id|g.category_two_id|g.category_three_id'] = ['like','%,'.$cateIds.',%']; | ||
341 | $where['g.ch_name|g.en_name'] = ['like','%'.$params['keyword'].'%']; | 346 | $where['g.ch_name|g.en_name'] = ['like','%'.$params['keyword'].'%']; |
342 | //获取筛选标签,国家,品牌,等级,部位,品类 | 347 | //获取筛选标签,国家,品牌,等级,部位,品类 |
343 | - $data['extend'] = $this->categoryModel->getExtend($where,$this->lang); | 348 | + $data['extend'] = $this->categoryModel->getExtend($where,$this->lang,$whereOr); |
344 | //获取列表数据 | 349 | //获取列表数据 |
345 | - $data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang); | 350 | + $data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang,$whereOr); |
346 | foreach ($data['list']['list'] as $k => $v){ | 351 | foreach ($data['list']['list'] as $k => $v){ |
347 | $v['user_type'] = $this->user['type']; | 352 | $v['user_type'] = $this->user['type']; |
348 | $data['list']['list'][$k]['price'] = get_price_not_group($v); | 353 | $data['list']['list'][$k]['price'] = get_price_not_group($v); |
@@ -27,7 +27,7 @@ class Category extends Model | @@ -27,7 +27,7 @@ class Category extends Model | ||
27 | return $data; | 27 | return $data; |
28 | } | 28 | } |
29 | 29 | ||
30 | - public function getExtend($where,$lang) | 30 | + public function getExtend($where,$lang,$whereOr) |
31 | { | 31 | { |
32 | $goodsModel = new Goods(); | 32 | $goodsModel = new Goods(); |
33 | $ids = $goodsModel->alias('g') | 33 | $ids = $goodsModel->alias('g') |
@@ -35,6 +35,7 @@ class Category extends Model | @@ -35,6 +35,7 @@ class Category extends Model | ||
35 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') | 35 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') |
36 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') | 36 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') |
37 | ->where($where) | 37 | ->where($where) |
38 | + ->whereOr($whereOr) | ||
38 | ->column('country_id,brand_id,level_id,part_id,category2_id'); | 39 | ->column('country_id,brand_id,level_id,part_id,category2_id'); |
39 | 40 | ||
40 | $countryids = []; | 41 | $countryids = []; |
@@ -148,7 +148,7 @@ class Goods extends Model | @@ -148,7 +148,7 @@ class Goods extends Model | ||
148 | return $data; | 148 | return $data; |
149 | } | 149 | } |
150 | 150 | ||
151 | - public function selectPageData($where, $page, $limit, $lang) | 151 | + public function selectPageData($where, $page, $limit, $lang,$whereOr) |
152 | { | 152 | { |
153 | $where['g.status'] = 1; | 153 | $where['g.status'] = 1; |
154 | 154 | ||
@@ -161,6 +161,7 @@ class Goods extends Model | @@ -161,6 +161,7 @@ class Goods extends Model | ||
161 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') | 161 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') |
162 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') | 162 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') |
163 | ->where($where) | 163 | ->where($where) |
164 | + ->whereOr($whereOr) | ||
164 | ->count(); | 165 | ->count(); |
165 | 166 | ||
166 | $list = $this->alias('g') | 167 | $list = $this->alias('g') |
@@ -169,6 +170,7 @@ class Goods extends Model | @@ -169,6 +170,7 @@ class Goods extends Model | ||
169 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') | 170 | // ->join('fa_category cate2', 'g.category_two_id=cate2.id') |
170 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') | 171 | // ->join('fa_category cate3', 'g.category_three_id=cate3.id') |
171 | ->where($where) | 172 | ->where($where) |
173 | + ->whereOr($whereOr) | ||
172 | ->field($field) | 174 | ->field($field) |
173 | ->order('g.weigh desc') | 175 | ->order('g.weigh desc') |
174 | ->page($page, $limit) | 176 | ->page($page, $limit) |
-
请 注册 或 登录 后发表评论