|
@@ -27,7 +27,6 @@ use App\Models\UserCreditLog;
|
|
use App\Models\UserGroup;
|
|
use App\Models\UserGroup;
|
|
use App\Models\UserLoginLog;
|
|
use App\Models\UserLoginLog;
|
|
use App\Models\UserSubscribe;
|
|
use App\Models\UserSubscribe;
|
|
-use App\Models\UserTrafficDaily;
|
|
|
|
use App\Models\UserTrafficHourly;
|
|
use App\Models\UserTrafficHourly;
|
|
use App\Models\UserTrafficLog;
|
|
use App\Models\UserTrafficLog;
|
|
use App\Models\UserTrafficModifyLog;
|
|
use App\Models\UserTrafficModifyLog;
|
|
@@ -88,12 +87,11 @@ class AdminController extends Controller {
|
|
$view['flowAbnormalUserCount'] = count($this->trafficAbnormal());// 1小时内流量异常用户
|
|
$view['flowAbnormalUserCount'] = count($this->trafficAbnormal());// 1小时内流量异常用户
|
|
$view['nodeCount'] = SsNode::query()->count();
|
|
$view['nodeCount'] = SsNode::query()->count();
|
|
$view['unnormalNodeCount'] = SsNode::query()->whereStatus(0)->count();
|
|
$view['unnormalNodeCount'] = SsNode::query()->whereStatus(0)->count();
|
|
- $flowCount = SsNodeTrafficDaily::query()
|
|
|
|
- ->where('created_at', '>=', date('Y-m-d 00:00:00', strtotime("-30 days")))
|
|
|
|
- ->sum('total');
|
|
|
|
- $view['flowCount'] = flowAutoShow($flowCount);
|
|
|
|
- $totalFlowCount = SsNodeTrafficDaily::query()->sum('total');
|
|
|
|
- $view['totalFlowCount'] = flowAutoShow($totalFlowCount);
|
|
|
|
|
|
+ $view['flowCount'] = flowAutoShow(SsNodeTrafficDaily::query()
|
|
|
|
+ ->where('created_at', '>=',
|
|
|
|
+ date('Y-m-d 00:00:00', strtotime("-30 days")))
|
|
|
|
+ ->sum('total'));
|
|
|
|
+ $view['totalFlowCount'] = flowAutoShow(SsNodeTrafficDaily::query()->sum('total'));
|
|
$view['totalCredit'] = User::query()->sum('credit') / 100;
|
|
$view['totalCredit'] = User::query()->sum('credit') / 100;
|
|
$view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
|
|
$view['totalWaitRefAmount'] = ReferralLog::query()->whereIn('status', [0, 1])->sum('ref_amount') / 100;
|
|
$view['totalRefAmount'] = ReferralApply::query()->whereStatus(2)->sum('amount') / 100;
|
|
$view['totalRefAmount'] = ReferralApply::query()->whereStatus(2)->sum('amount') / 100;
|
|
@@ -105,6 +103,8 @@ class AdminController extends Controller {
|
|
->where('created_at', '>=', date('Y-m-d 00:00:00'))
|
|
->where('created_at', '>=', date('Y-m-d 00:00:00'))
|
|
->where('created_at', '<=', date('Y-m-d 23:59:59'))
|
|
->where('created_at', '<=', date('Y-m-d 23:59:59'))
|
|
->count();
|
|
->count();
|
|
|
|
+ // 今日
|
|
|
|
+ $view['todayRegister'] = User::query()->whereDate('created_at', date('Y-m-d'))->count();
|
|
|
|
|
|
return Response::view('admin.index', $view);
|
|
return Response::view('admin.index', $view);
|
|
}
|
|
}
|
|
@@ -218,8 +218,7 @@ class AdminController extends Controller {
|
|
// 流量异常警告
|
|
// 流量异常警告
|
|
$time = date('Y-m-d H:i:s', time() - 3900);
|
|
$time = date('Y-m-d H:i:s', time() - 3900);
|
|
$totalTraffic = UserTrafficHourly::query()
|
|
$totalTraffic = UserTrafficHourly::query()
|
|
- ->whereUserId($user->id)
|
|
|
|
- ->whereNodeId(0)
|
|
|
|
|
|
+ ->userHourly($user->id)
|
|
->where('created_at', '>=', $time)
|
|
->where('created_at', '>=', $time)
|
|
->sum('total');
|
|
->sum('total');
|
|
$user->trafficWarning = $totalTraffic > (self::$systemConfig['traffic_ban_value'] * GB)? 1 : 0;
|
|
$user->trafficWarning = $totalTraffic > (self::$systemConfig['traffic_ban_value'] * GB)? 1 : 0;
|
|
@@ -743,60 +742,8 @@ class AdminController extends Controller {
|
|
return Redirect::to('admin/userList');
|
|
return Redirect::to('admin/userList');
|
|
}
|
|
}
|
|
|
|
|
|
- // 30天内的流量
|
|
|
|
- $dailyData = [];
|
|
|
|
- $hourlyData = [];
|
|
|
|
- // 节点一个月内的流量
|
|
|
|
- $userTrafficDaily = UserTrafficDaily::query()
|
|
|
|
- ->whereUserId($user->id)
|
|
|
|
- ->whereNodeId(0)
|
|
|
|
- ->where('created_at', '>=', date('Y-m'))
|
|
|
|
- ->orderBy('created_at')
|
|
|
|
- ->pluck('total')
|
|
|
|
- ->toArray();
|
|
|
|
-
|
|
|
|
- $dailyTotal = date('d') - 1; // 今天不算,减一
|
|
|
|
- $dailyCount = count($userTrafficDaily);
|
|
|
|
- for($x = 0; $x < $dailyTotal - $dailyCount; $x++){
|
|
|
|
- $dailyData[$x] = 0;
|
|
|
|
- }
|
|
|
|
- for($x = $dailyTotal - $dailyCount; $x < $dailyTotal; $x++){
|
|
|
|
- $dailyData[$x] = round($userTrafficDaily[$x - ($dailyTotal - $dailyCount)] / GB, 3);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 节点一天内的流量
|
|
|
|
- $userTrafficHourly = UserTrafficHourly::query()
|
|
|
|
- ->whereUserId($user->id)
|
|
|
|
- ->whereNodeId(0)
|
|
|
|
- ->where('created_at', '>=', date('Y-m-d'))
|
|
|
|
- ->orderBy('created_at')
|
|
|
|
- ->pluck('total')
|
|
|
|
- ->toArray();
|
|
|
|
- $hourlyTotal = date('H');
|
|
|
|
- $hourlyCount = count($userTrafficHourly);
|
|
|
|
- for($x = 0; $x < $hourlyTotal - $hourlyCount; $x++){
|
|
|
|
- $hourlyData[$x] = 0;
|
|
|
|
- }
|
|
|
|
- for($x = ($hourlyTotal - $hourlyCount); $x < $hourlyTotal; $x++){
|
|
|
|
- $hourlyData[$x] = round($userTrafficHourly[$x - ($hourlyTotal - $hourlyCount)] / GB, 3);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- // 本月天数数据
|
|
|
|
- $monthDays = [];
|
|
|
|
- for($i = 1; $i <= date("d"); $i++){
|
|
|
|
- $monthDays[] = $i;
|
|
|
|
- }
|
|
|
|
- // 本日小时数据
|
|
|
|
- $dayHours = [];
|
|
|
|
- for($i = 1; $i <= date("H"); $i++){
|
|
|
|
- $dayHours[] = $i;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- $view['trafficDaily'] = json_encode($dailyData);
|
|
|
|
- $view['trafficHourly'] = json_encode($hourlyData);
|
|
|
|
- $view['monthDays'] = json_encode($monthDays);
|
|
|
|
- $view['dayHours'] = json_encode($dayHours);
|
|
|
|
$view['email'] = $user->email;
|
|
$view['email'] = $user->email;
|
|
|
|
+ $view = array_merge($view, $this->dataFlowChart($user->id));
|
|
|
|
|
|
return Response::view('admin.logs.userMonitor', $view);
|
|
return Response::view('admin.logs.userMonitor', $view);
|
|
}
|
|
}
|