作者 耿培杰

修改搜索商品接口

... ... @@ -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);
}
... ...
... ... @@ -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 = [];
... ...
... ... @@ -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')
... ...