From 4f28be262d47325f0affb6325d90597acfd66428 Mon Sep 17 00:00:00 2001 From: liyinglin Date: Tue, 19 Mar 2024 14:12:39 +0800 Subject: [PATCH] 1 --- app/Http/Controllers/Admin/StatisticsController.php | 11 ++++++++--- resources/views/admin/statistics/bed.blade.php | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Admin/StatisticsController.php b/app/Http/Controllers/Admin/StatisticsController.php index ec0ec8c..46dc30c 100755 --- a/app/Http/Controllers/Admin/StatisticsController.php +++ b/app/Http/Controllers/Admin/StatisticsController.php @@ -460,6 +460,11 @@ class StatisticsController extends CommonController $area = Area::withCount('beds')->where('project_id', $project_id)->get(); $beds = Bed::whereIn('area_id', $area->pluck('id'))->where('project_id', $project_id)->get(); $totalBed = $beds->count(); + // 订单总数 + $orderTotal = Orders::where('project_id', $project_id) + ->where('created_at', 'like', '%' . $month . '%') + ->whereIn('bed_id', $beds->pluck('id')) + ->count(); foreach ($area as $item) { // 床位占比 $item->bed_rate = 0; @@ -473,12 +478,12 @@ class StatisticsController extends CommonController ->whereIn('bed_id', $bedsIdTemp) ->count(); $item->rate = 0; - if ($totalBed) { + if ($bedsIdTemp->count()) { // 配比 - $item->rate = round($item->order_total / $totalBed, 4) * 100; + $item->rate = round($item->order_total / $bedsIdTemp->count(), 4) * 100; } } - return view($this->bladePath . ".bed", compact("area", "totalBed", "project", "project_id", "month", "projects")); + return view($this->bladePath . ".bed", compact("area", "orderTotal", "totalBed", "project", "project_id", "month", "projects")); } } diff --git a/resources/views/admin/statistics/bed.blade.php b/resources/views/admin/statistics/bed.blade.php index a9acf72..e06fc4a 100755 --- a/resources/views/admin/statistics/bed.blade.php +++ b/resources/views/admin/statistics/bed.blade.php @@ -31,7 +31,7 @@ 病区 床位数量(总数:{{$totalBed}}) 床位占比 - 订单数量 + 订单数量(总数:{{$orderTotal}}) 护工配比