Browse Source

统计修复去重

master
weigang 5 years ago
parent
commit
2186865052
  1. 3
      app/Service/v3/Implementations/OrderStatisticsService.php

3
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);

Loading…
Cancel
Save