|
@@ -152,11 +152,11 @@ class Goods extends Base
|
|
if (!$validate->scene('lists')->check($param)) {
|
|
if (!$validate->scene('lists')->check($param)) {
|
|
$this->error($validate->getError());
|
|
$this->error($validate->getError());
|
|
}
|
|
}
|
|
- $pageSize = (int)$this->request->param('pageSize', 10);
|
|
|
|
- $orderby = $this->request->param('orderby', 'weigh');
|
|
|
|
- $orderway = $this->request->param('orderway', 'desc');
|
|
|
|
|
|
+ $pageSize = $param['pageSize'] ?? 10;
|
|
|
|
+ $orderby = $param['orderby'] ?? 'weigh';
|
|
|
|
+ $orderway = $param['orderway'] ?? 'desc';
|
|
|
|
|
|
- $list = GoodsModel::where(function ($query) use ($param) {
|
|
|
|
|
|
+ $query = GoodsModel::where(function ($query) use ($param) {
|
|
$query->where('status',GoodsEnum::STATUS_ON_SALE);
|
|
$query->where('status',GoodsEnum::STATUS_ON_SALE);
|
|
//关键词
|
|
//关键词
|
|
if (isset($param['keywords']) && !empty($param['keywords'])) {
|
|
if (isset($param['keywords']) && !empty($param['keywords'])) {
|
|
@@ -203,7 +203,11 @@ class Goods extends Base
|
|
$query->where('price', 'BETWEEN', $priceArr);
|
|
$query->where('price', 'BETWEEN', $priceArr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- })->order("{$orderby} {$orderway}")->paginate($pageSize);
|
|
|
|
|
|
+ });
|
|
|
|
+ if (!empty($orderby) && !empty($orderway)) {
|
|
|
|
+ $query = $query->order("{$orderby} {$orderway}");
|
|
|
|
+ }
|
|
|
|
+ $list = $query->paginate($pageSize);
|
|
|
|
|
|
foreach ($list as $item) {
|
|
foreach ($list as $item) {
|
|
$item->visible(explode(',', 'id,title,image,price,sales,views,description,marketprice,createtime'));
|
|
$item->visible(explode(',', 'id,title,image,price,sales,views,description,marketprice,createtime'));
|