setMonthIncome(); $this->setMonthRegisterTotal(); $this->setMonthServerTrafficTotal(); } private function setMonthIncome() { Redis::set( 'month_income', Order::where('created_at', '>=', strtotime(date('Y-m-1'))) ->where('created_at', '<', time()) ->where('status', '3') ->sum('total_amount') ); } private function setMonthRegisterTotal() { Redis::set( 'month_register_total', User::where('created_at', '>=', strtotime(date('Y-m-1'))) ->where('created_at', '<', time()) ->count() ); } private function setMonthServerTrafficTotal () { $servers = Server::get(); foreach ($servers as $item) { $serverLog = ServerLog::where('created_at', '>=', strtotime(date('Y-m-1'))) ->where('created_at', '<', time()) ->where('node_id', $item->id); Redis::set('month_server_traffic_total_u_' . $item->id, $serverLog->sum('u')); Redis::set('month_server_traffic_total_d_' . $item->id, $serverLog->sum('d')); } } }