diff --git a/app/Service/v3/Implementations/OrderStatisticsService.php b/app/Service/v3/Implementations/OrderStatisticsService.php index ca39f5f..e235e9e 100644 --- a/app/Service/v3/Implementations/OrderStatisticsService.php +++ b/app/Service/v3/Implementations/OrderStatisticsService.php @@ -35,6 +35,7 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface $goodsTable = ApplicationContext::getContainer()->get(OrderGoods::class)->getTable(); $builder = OrderMain::query() + ->selectRaw('COUNT(DISTINCT '.$mainTable.'.id) AS count') ->join($childTable, ''.$childTable.'.order_main_id', '=', ''.$mainTable.'.global_order_id') ->where([''.$childTable.'.store_id' => $storeId, ''.$mainTable.'.type' => $type]) ->whereIn(''.$mainTable.'.state', array_merge(OrderState::FINISH, [OrderState::REFUNDED,OrderState::REFUND_REFUSE])); @@ -52,7 +53,7 @@ class OrderStatisticsService implements OrderStatisticsServiceInterface $builder = $builder->where(''.$mainTable.'.created_at', '<=', $endTime); } - return $builder->count(); + return $builder->first()->count; // $builder = Order::join('lanzu_order_main','lanzu_order_main.global_order_id','lanzu_order.order_main_id') // ->where('lanzu_order.store_id',$storeId);