diff --git a/app/Http/Controllers/Admin/StatisticsController.php b/app/Http/Controllers/Admin/StatisticsController.php index ecd3bdb..1e77596 100755 --- a/app/Http/Controllers/Admin/StatisticsController.php +++ b/app/Http/Controllers/Admin/StatisticsController.php @@ -553,14 +553,18 @@ class StatisticsController extends CommonController foreach ($areaList as $item) { $beds = Bed::where('area_id', $item->id)->where('project_id', $project_id)->get(); // 订单总数 - $orders = Orders::where('project_id', $project_id) - // ->where('created_at', 'like', '%' . $month . '%') +// $orders = Orders::where('project_id', $project_id) +// ->whereIn('bed_id', $beds->pluck('id')) +// ->get(); +// $orderTotal = Balance::where('created_at', 'like', '%' . $month . '%') +// ->where('belongs_type', 'App\Models\Recharge') +// ->whereIn('order_id', $orders->pluck('id')) +// ->sum("money"); + + $orderTotal = OrderItems::where('paid_at', 'like', '%' . $month . '%') ->whereIn('bed_id', $beds->pluck('id')) - ->get(); - $orderTotal = Balance::where('created_at', 'like', '%' . $month . '%') - ->where('belongs_type', 'App\Models\Recharge') - ->whereIn('order_id', $orders->pluck('id')) ->sum("money"); + $item->order_total = $orderTotal; $item->shouxufei = round($orderTotal * 0.006, 2); $item->zengshishui = round($orderTotal * 0.06, 2); @@ -576,14 +580,6 @@ class StatisticsController extends CommonController $total['shijishouru'] += $item->shijishouru; $total['guanlifei'] += $item->guanlifei; } - - // 获取所有订单数据 -// $beds = Bed::whereIn('area_id', $areaList->pluck('id'))->where('project_id', $project_id)->get(); -// // 订单总数 -// $allOrderTotal = Orders::where('project_id', $project_id) -// ->where('created_at', 'like', '%' . $month . '%') -// ->whereIn('bed_id', $beds->pluck('id')) -// ->get(); $refund['order_total'] = abs(Balance::where('created_at', 'like', '%' . $month . '%') ->where('belongs_type', 'App\Models\Refund') ->whereHas("order", function ($query) use ($project_id) {