where('user_id', $request->user['id']) ->where('record_at', '>=', strtotime(date('Y-m-1'))) ->orderBy('record_at', 'DESC') ->get(); // 追加当天流量 $recordAt = strtotime(date('Y-m-d')); $statService = new StatisticalService(); $statService->setStartAt($recordAt); $statService->setUserStats(); $todayTraffics = $statService->getStatUserByUserID($request->user['id']); if (count($todayTraffics) > 0) { foreach ($todayTraffics as $todayTraffic){ $todayTraffic['server_rate'] = number_format($todayTraffic['server_rate'], 2); $records->prepend($todayTraffic); } }; return $this->success($records); } }