作者 耿培杰

添加分类搜索范围

... ... @@ -338,11 +338,16 @@ class Goods extends Api
if (!empty($params['category2_id'])) $where['category2_id'] = $params['category2_id'];
// $where['g.ch_name|g.en_name|g.ch_content|g.en_content|cate1.name|cate2.name|cate3.name'] = ['like','%'.$params['keyword'].'%'];
$cateWhere['name'] = $params['keyword'];
$cateWhere['en_name'] = $params['keyword'];
$cateIds = $this->categoryModel->whereOr($cateWhere)->column('id');
$cateIds = implode(',',$cateIds);
$whereOr['g.category_one_id|g.category_two_id|g.category_three_id'] = ['like','%,'.$cateIds.',%'];
$where['g.ch_name|g.en_name'] = ['like','%'.$params['keyword'].'%'];
//获取筛选标签,国家,品牌,等级,部位,品类
$data['extend'] = $this->categoryModel->getExtend($where,$this->lang);
$data['extend'] = $this->categoryModel->getExtend($where,$this->lang,$whereOr);
//获取列表数据
$data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang);
$data['list'] = $this->goodsModel->selectPageData($where,$page,$limit,$this->lang,$whereOr);
foreach ($data['list']['list'] as $k => $v){
$v['user_type'] = $this->user['type'];
$data['list']['list'][$k]['price'] = get_price_not_group($v);
... ...
... ... @@ -27,7 +27,7 @@ class Category extends Model
return $data;
}
public function getExtend($where,$lang)
public function getExtend($where,$lang,$whereOr)
{
$goodsModel = new Goods();
$ids = $goodsModel->alias('g')
... ... @@ -35,6 +35,7 @@ class Category extends Model
// ->join('fa_category cate2', 'g.category_two_id=cate2.id')
// ->join('fa_category cate3', 'g.category_three_id=cate3.id')
->where($where)
->whereOr($whereOr)
->column('country_id,brand_id,level_id,part_id,category2_id');
$countryids = [];
... ...
... ... @@ -148,7 +148,7 @@ class Goods extends Model
return $data;
}
public function selectPageData($where, $page, $limit, $lang)
public function selectPageData($where, $page, $limit, $lang,$whereOr)
{
$where['g.status'] = 1;
... ... @@ -161,6 +161,7 @@ class Goods extends Model
// ->join('fa_category cate2', 'g.category_two_id=cate2.id')
// ->join('fa_category cate3', 'g.category_three_id=cate3.id')
->where($where)
->whereOr($whereOr)
->count();
$list = $this->alias('g')
... ... @@ -169,6 +170,7 @@ class Goods extends Model
// ->join('fa_category cate2', 'g.category_two_id=cate2.id')
// ->join('fa_category cate3', 'g.category_three_id=cate3.id')
->where($where)
->whereOr($whereOr)
->field($field)
->order('g.weigh desc')
->page($page, $limit)
... ...