diff --git a/app/Http/Controllers/Api/AgentProductController.php b/app/Http/Controllers/Api/AgentProductController.php index d711507..1cf51b1 100644 --- a/app/Http/Controllers/Api/AgentProductController.php +++ b/app/Http/Controllers/Api/AgentProductController.php @@ -58,7 +58,7 @@ class AgentProductController extends Controller { $id = (int)request()->input('id'); - if (AgentProduct::withTrashed()->where('agent_id', $this->agent_id)->count() === 0) { //演示产品用 + if (AgentProduct::where('agent_id', $this->agent_id)->withTrashed()->count() === 0) { //演示产品用 $where = ['id' => $id, 'status' => ProductStatus::ON_SALE]; } else { $where = ['id' => $id, 'agent_id' => $this->agent_id, 'status' => ProductStatus::ON_SALE]; @@ -199,7 +199,7 @@ class AgentProductController extends Controller { //如果是新入驻代理商没有数据,且没有删除过的数据,则显示最早的几条 if ($list->isEmpty()) { - if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据 + if (AgentProduct::where('agent_id', $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(); } else { return $list; //因为只获取2页数据,不return可能会导入下面的代码出错 diff --git a/app/Http/Controllers/Api/CategoryController.php b/app/Http/Controllers/Api/CategoryController.php index 6be3816..bbfd635 100644 --- a/app/Http/Controllers/Api/CategoryController.php +++ b/app/Http/Controllers/Api/CategoryController.php @@ -15,7 +15,7 @@ class CategoryController extends Controller ->orderBy('sort') ->get(['id', 'name']); if ($list->isEmpty()) { //如果是新入驻商户,显示默认数据 - if (AgentProduct::list($this->agent_id)->withTrashed()->count() === 0 && request('page', 1) <= 2) { //只获取2页数据 + if (AgentProduct::where('agent_id', $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(); } }