function index() { $day = getWeekDate(); $cardAr = []; $orderAr = []; $rechargeAr = []; foreach ($day as $day) { $cardAr[] = UserCa::whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->count(); /* 订单金额 */ $orders = Order::whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get(); $orderPrice = 0; foreach ($orders as $order) { $orderPrice += $order->price; } $orderAr[] = $orderPrice; /* 混合订单金额 */ $mixOrders = MixOrder::whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get(); $mixOrderPrice = 0; foreach ($mixOrders as $order) { $mixOrderPrice += $order->price; } $mixOrderAr[] = $mixOrderPrice; /* 充值金额 */ $recharges = Recharge::whereBetween('created_at', [$day . ' 00:00:00', $day . ' 23:59:59'])->get(); $rechargePrice = 0; foreach ($recharges as $d) { $rechargePrice += $d->price; } $rechargeAr[] = $rechargePrice; } $data['cards'] = $cardAr; $data['orderPrice'] = $orderAr; $data['mixOrderPrice'] = $mixOrderAr; $data['rechargePrice'] = $rechargeAr; $markets = Market::all(); $data['markets'] = $markets; return view('card.data_day.index', $data); }
/** * 后台首页 === 后台控制台概要页面 * * @return Response */ public function index() { $startTime = date('Y-m-d', time()) . ' 00:00:00'; $endTime = date('Y-m-d', time()) . ' 23:59:59'; $data['cards'] = UserCa::whereBetween('created_at', [$startTime, $endTime])->get()->count(); $data['orders'] = Order::whereBetween('created_at', [$startTime, $endTime])->get()->count(); $recharges = Recharge::whereBetween('created_at', [$startTime, $endTime])->get(); $consumes = CountOrder::whereBetween('created_at', [$startTime, $endTime])->get(); $rechargesPrice = 0; $consumesPrice = 0; if (count($recharges) > 0) { foreach ($recharges as $key => $li) { $rechargesPrice += $li->price; } } if (count($consumes) > 0) { foreach ($consumes as $key => $li) { $consumesPrice += $li->product_price * $li->product_weight; } } $data['rechargesPrice'] = $rechargesPrice; $data['consumesPrice'] = $consumesPrice; return view('card.home.index', $data); }