|
|
|
|
@ -404,19 +404,24 @@ class StatisticsController extends CommonController
|
|
|
|
|
$product = Product::where('project_id', $project_id)->first();
|
|
|
|
|
$productItem = ProductItems::where('product_id', $product->id)->get();
|
|
|
|
|
$factor = FactorItems::where('factor_id', $product->statistic_factor_id)->get();
|
|
|
|
|
|
|
|
|
|
$sumOrderTotal = 0;
|
|
|
|
|
foreach ($data as $item) {
|
|
|
|
|
// 获取所有床位id
|
|
|
|
|
$bedIds = Bed::where('area_id', $item->id)->pluck('id');
|
|
|
|
|
$order = Orders::whereIn('bed_id', $bedIds)->where('status', 100)->get();
|
|
|
|
|
$item->order_total = $order->sum('total');
|
|
|
|
|
// 总和
|
|
|
|
|
$item->order_total = OrderItems::whereIn('product_item_id', $productItem->pluck('id'))
|
|
|
|
|
->whereIn("bed_id", $bedIds)
|
|
|
|
|
->where('paid_at', 'like', '%' . $month . '%')
|
|
|
|
|
->sum('total');
|
|
|
|
|
$sumOrderTotal += $item->order_total;
|
|
|
|
|
// 子项
|
|
|
|
|
$item->lies = $this->getLies($bedIds, $productItem, $factor, $month);
|
|
|
|
|
}
|
|
|
|
|
// 获取所有列
|
|
|
|
|
$lie = array_column($data[0]->lies, 'name');
|
|
|
|
|
$months = $this->_getMonths();
|
|
|
|
|
|
|
|
|
|
return view($this->bladePath . ".huli", compact("data", "month", "lie", "projects", "project_id"));
|
|
|
|
|
return view($this->bladePath . ".huli", compact("sumOrderTotal","data", "month", "lie", "projects", "project_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|