liyinglin 2 years ago
parent 0882f34e76
commit dc431fb57a

@ -416,29 +416,28 @@ class StatisticsController extends CommonController
$bedIds = Bed::where('area_id', $item->id)->pluck('id'); $bedIds = Bed::where('area_id', $item->id)->pluck('id');
$order = Orders::whereIn('bed_id', $bedIds)->where('status', 100)->get(); $order = Orders::whereIn('bed_id', $bedIds)->where('status', 100)->get();
$item->order_total = $order->sum('total'); $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'); $lie = array_column($data[0]->lies, 'name');
$months = $this->_getMonths(); $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 = []; $list = [];
// DB::enableQueryLog();
foreach ($productItem as $item) { foreach ($productItem as $item) {
foreach ($factor as $factor_item) { foreach ($factor as $factor_item) {
$total = OrderItems::where('product_item_id', $item->id) $total = OrderItems::where('product_item_id', $item->id)
->whereIn("bed_id", $bedIds) ->whereIn("bed_id", $bedIds)
->whereRaw("factors like '%\"factor_item_id\": $factor_item->id%'") ->whereRaw("factors like '%\"factor_item_id\": $factor_item->id%'")
->where('paid_at', 'like', '%' . $month . '%')
->sum('total'); ->sum('total');
//dd(DB::getQueryLog());
$list [] = [ $list [] = [
'name' => $item->price + $factor_item->price . '元/天', 'name' => $item->price + $factor_item->price . '元/天',
'total_price' => $item->price + $factor_item->price, 'total_price' => $item->price + $factor_item->price,

Loading…
Cancel
Save