From 6437db94b380e7942ec5429d7044c465edf9d347 Mon Sep 17 00:00:00 2001 From: liapples Date: Tue, 28 Sep 2021 21:33:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Api/TestController.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Api/TestController.php b/app/Http/Controllers/Api/TestController.php index 24d3055..32adc26 100644 --- a/app/Http/Controllers/Api/TestController.php +++ b/app/Http/Controllers/Api/TestController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Api; +use App\Common\ProductStatus; use App\Models\AgentProduct; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\DB; @@ -16,7 +17,14 @@ class TestController { public function index() { - dd(AgentProduct::list(10)->withTrashed()->count()); + dd(AgentProduct::withoutGlobalScope('orderById') + ->whereDoesntHave('agentProductItem', function ($query) { + return $query->whereHas('product', function ($query) { + return $query->where('stock', '<=', 0)->orWhere('status', '<>', ProductStatus::ON_SALE); + }); + }) + ->where('stock', '>', 0)->where(['agent_id' => 10, 'status' => ProductStatus::ON_SALE]) + ->select('id', 'sale', 'product_id', 'price', 'original_price', 'title', 'pictures')->withTrashed()->count()); } /**