|
|
@@ -92,24 +92,16 @@ class GoodsService extends BaseService
|
|
|
*/
|
|
|
public function getQuery($params)
|
|
|
{
|
|
|
- $where = ['a.is_recommend'=>1,'a.status' => 1, 'a.mark' => 1];
|
|
|
+ $where = ['a.status' => 1, 'a.mark' => 1];
|
|
|
$status = isset($params['status']) ? $params['status'] : 1;
|
|
|
- $isRecommend = isset($params['is_recommend']) ? $params['is_recommend'] : 0;
|
|
|
if ($status > 0) {
|
|
|
$where['a.status'] = $status;
|
|
|
} else {
|
|
|
unset($where['a.status']);
|
|
|
}
|
|
|
|
|
|
- if ($isRecommend == 1) {
|
|
|
- $where['a.is_recommend'] = $isRecommend;
|
|
|
- } else {
|
|
|
- unset($where['a.is_recommend']);
|
|
|
- }
|
|
|
-
|
|
|
$model = $this->model->with(['store','category'])
|
|
|
->from('goods as a')
|
|
|
- ->where($where)
|
|
|
->where(function ($query) use ($params) {
|
|
|
// 分类
|
|
|
$categoryId = isset($params['category_id'])? intval($params['category_id']) : 0;
|
|
|
@@ -131,7 +123,17 @@ class GoodsService extends BaseService
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- });
|
|
|
+ $isRecommend = isset($params['is_recommend']) ? $params['is_recommend'] : 0;
|
|
|
+ if($isRecommend){
|
|
|
+ $query->where('a.is_recommend', $isRecommend);
|
|
|
+ }
|
|
|
+
|
|
|
+ $isNew = isset($params['is_new']) ? $params['is_new'] : 0;
|
|
|
+ if($isNew){
|
|
|
+ $query->where('a.is_new', $isNew);
|
|
|
+ }
|
|
|
+
|
|
|
+ })->where($where);
|
|
|
|
|
|
return $model;
|
|
|
}
|