|
|
|
|
@ -416,29 +416,28 @@ class StatisticsController extends CommonController
|
|
|
|
|
$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->lies = $this->getLies($bedIds, $productItem, $factor);
|
|
|
|
|
$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("data", "month", "lie", "projects", "project_id"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取动态列
|
|
|
|
|
*/
|
|
|
|
|
public function getLies($bedIds, $productItem, $factor)
|
|
|
|
|
public function getLies($bedIds, $productItem, $factor, $month)
|
|
|
|
|
{
|
|
|
|
|
$list = [];
|
|
|
|
|
// DB::enableQueryLog();
|
|
|
|
|
foreach ($productItem as $item) {
|
|
|
|
|
foreach ($factor as $factor_item) {
|
|
|
|
|
$total = OrderItems::where('product_item_id', $item->id)
|
|
|
|
|
->whereIn("bed_id", $bedIds)
|
|
|
|
|
->whereRaw("factors like '%\"factor_item_id\": $factor_item->id%'")
|
|
|
|
|
->where('paid_at', 'like', '%' . $month . '%')
|
|
|
|
|
->sum('total');
|
|
|
|
|
//dd(DB::getQueryLog());
|
|
|
|
|
$list [] = [
|
|
|
|
|
'name' => $item->price + $factor_item->price . '元/天',
|
|
|
|
|
'total_price' => $item->price + $factor_item->price,
|
|
|
|
|
|