|
|
|
@ -329,13 +329,36 @@ class Goods extends BaseModel |
|
|
|
|
$query = $query->whereRaw('goods_name like ? or goods_no like ?', ["%{$val}%", "%{$val}%"]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 执行查询 |
|
|
|
|
$list = $query->with(['images.file']) |
|
|
|
|
->alias($this->name) |
|
|
|
|
->field($field) |
|
|
|
|
->where('is_delete', '=', 0) |
|
|
|
|
->order($sort) |
|
|
|
|
->paginate($listRows); |
|
|
|
|
if (isset($param['fliter_condition']) && $param['fliter_condition']) { |
|
|
|
|
$fliter_condition = json_decode($param['fliter_condition'], true); |
|
|
|
|
|
|
|
|
|
$str = ""; |
|
|
|
|
foreach ($fliter_condition as $value) { |
|
|
|
|
$strConditon = "("; |
|
|
|
|
$strConditon .= "goods_category_rel.category_id in (".implode(",", $value['category']).")"; |
|
|
|
|
$strConditon .= " and goods.profit >= ".$value['profit']; |
|
|
|
|
$strConditon .= " and goods.profit_rate >= ".$value['profit_rate'] . ") or "; |
|
|
|
|
$str .= $strConditon; |
|
|
|
|
} |
|
|
|
|
$str = trim($str, "or "); |
|
|
|
|
// 执行查询 |
|
|
|
|
$list = $query->with(['images.file']) |
|
|
|
|
->alias($this->name) |
|
|
|
|
->field($field) |
|
|
|
|
->where('is_delete', '=', 0) |
|
|
|
|
->where($str) |
|
|
|
|
->order($sort) |
|
|
|
|
->paginate($listRows); |
|
|
|
|
} else { |
|
|
|
|
// 执行查询 |
|
|
|
|
$list = $query->with(['images.file']) |
|
|
|
|
->alias($this->name) |
|
|
|
|
->field($field) |
|
|
|
|
->where('is_delete', '=', 0) |
|
|
|
|
->order($sort) |
|
|
|
|
->paginate($listRows); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 整理列表数据并返回 |
|
|
|
|
return $this->setGoodsListData($list); |
|
|
|
@ -526,6 +549,7 @@ class Goods extends BaseModel |
|
|
|
|
if (isset($param['is_has_detail']) && $param['is_has_detail'] !== '') { |
|
|
|
|
$filter[] = ['goods.is_has_detail', '=', $params['is_has_detail']]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 实例化新查询对象 |
|
|
|
|
return $query->where($filter); |
|
|
|
|
} |
|
|
|
|