From c60d5b095d557a093be45800889f4ef8fcc4c7a5 Mon Sep 17 00:00:00 2001 From: weigang Date: Mon, 28 Sep 2020 15:28:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E9=9D=A2=E4=BB=98=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/OrderStatisticsService.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/Service/v3/Implementations/OrderStatisticsService.php b/app/Service/v3/Implementations/OrderStatisticsService.php index 8f7eff1..567c86c 100644 --- a/app/Service/v3/Implementations/OrderStatisticsService.php +++ b/app/Service/v3/Implementations/OrderStatisticsService.php @@ -36,9 +36,13 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface $builder = OrderMain::query() ->selectRaw('COUNT(DISTINCT '.$mainTable.'.id) AS count') - ->join($childTable, ''.$childTable.'.order_main_id', '=', ''.$mainTable.'.global_order_id') - ->join($goodsTable, ''.$goodsTable.'.order_id', '=', ''.$childTable.'.id') - ->where([''.$childTable.'.store_id' => $storeId, ''.$mainTable.'.type' => $type]) + ->join($childTable, ''.$childTable.'.order_main_id', '=', ''.$mainTable.'.global_order_id'); + + if ($type == OrderType::ONLINE) { + $builder = $builder->join($goodsTable, ''.$goodsTable.'.order_id', '=', ''.$childTable.'.id'); + } + + $builder = $builder->where([''.$childTable.'.store_id' => $storeId, ''.$mainTable.'.type' => $type]) ->where(function ($query) use ($mainTable, $goodsTable, $type) { $query->where(function ($q) use ($mainTable, $goodsTable, $type) { $q->whereIn(''.$mainTable.'.state', array_merge(OrderState::FINISH, [OrderState::REFUNDED_DIRECT,OrderState::REFUND_REFUSE]));