|
|
|
|
@ -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"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|