From 5f383a93fea91ee1bb34a747208de00eb975bf3b Mon Sep 17 00:00:00 2001 From: liapples Date: Fri, 17 Sep 2021 15:03:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BC=94=E7=A4=BA=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/CategoryController.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Http/Controllers/Api/CategoryController.php b/app/Http/Controllers/Api/CategoryController.php index b278c4a..6be3816 100644 --- a/app/Http/Controllers/Api/CategoryController.php +++ b/app/Http/Controllers/Api/CategoryController.php @@ -1,7 +1,9 @@ where('agent_id', $this->agent_id) ->orderBy('sort') ->get(['id', 'name']); + if ($list->isEmpty()) { //如果是新入驻商户,显示默认数据 + if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据 + $list = AgentProduct::list($this->agent_id)->orWhere([['status', '=', ProductStatus::ON_SALE], ['price', '>', 500]])->orderBy('id')->simplePaginate(); + } + } return $this->success($list); } }