From b041fd0c7158dbd678471fbe8da689747a1f4757 Mon Sep 17 00:00:00 2001 From: weigang Date: Mon, 28 Sep 2020 14:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=AE=A2=E5=8D=95=E6=95=B0?= =?UTF-8?q?=E7=AE=97=E4=B8=8A=E7=94=A8=E4=BC=98=E6=83=A0=E5=88=B8=E7=9A=84?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=EF=BC=88=E5=9B=A0=E4=BC=98=E6=83=A0=E5=88=B8?= =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=97=B6=E6=98=AF=E6=8C=89=E6=AF=94=E4=BE=8B?= =?UTF-8?q?=E9=80=80=E7=9A=84=EF=BC=8C=E5=95=86=E6=88=B7=E4=BC=9A=E6=9C=89?= =?UTF-8?q?=E5=89=A9=E4=BD=99=E4=BC=98=E6=83=A0=E5=88=B8=E7=9A=84=E9=87=91?= =?UTF-8?q?=E9=A2=9D=E5=9C=A8=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/Implementations/OrderStatisticsService.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Service/v3/Implementations/OrderStatisticsService.php b/app/Service/v3/Implementations/OrderStatisticsService.php index 3c7e88b..8f7eff1 100644 --- a/app/Service/v3/Implementations/OrderStatisticsService.php +++ b/app/Service/v3/Implementations/OrderStatisticsService.php @@ -37,13 +37,17 @@ 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]) - ->whereIn(''.$mainTable.'.state', array_merge(OrderState::FINISH, [OrderState::REFUNDED_DIRECT,OrderState::REFUND_REFUSE])); + ->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])); + if ($type == OrderType::ONLINE) { + $q->whereIn(''.$goodsTable.'.status', [1,2]); + } - if ($type == OrderType::ONLINE) { - $builder = $builder->join($goodsTable, ''.$goodsTable.'.order_id', '=', ''.$childTable.'.id') - ->whereIn(''.$goodsTable.'.status', [1,2]); - } + })->orWhere(''.$mainTable.'.coupon_money', '>', 0); + }); if ($startTime) { $builder = $builder->where(''.$mainTable.'.created_at', '>=', $startTime);