fix: resolve known issues and improve code standards

- Fix known bugs in user, plan, and server modules
- Standardize code formatting and structure
- Optimize database queries and model relationships
- Improve request validation and error handling
- Update admin controllers for better consistency
This commit is contained in:
xboard
2025-06-22 17:38:17 +08:00
parent 733cc7e9a5
commit 44d92ac1c6
20 changed files with 56 additions and 51 deletions
-7
View File
@@ -87,13 +87,6 @@ class ServerService
public static function getRoutes(array $routeIds)
{
$routes = ServerRoute::select(['id', 'match', 'action', 'action_value'])->whereIn('id', $routeIds)->get();
// TODO: remove on 1.8.0
foreach ($routes as $k => $route) {
$array = json_decode($route->match, true);
if (is_array($array))
$routes[$k]['match'] = $array;
}
// TODO: remove on 1.8.0
return $routes;
}
+1 -1
View File
@@ -109,7 +109,6 @@ class TrafficResetService
Plan::RESET_TRAFFIC_MONTHLY => $this->getNextMonthlyReset($user, $now),
Plan::RESET_TRAFFIC_FIRST_DAY_YEAR => $this->getNextYearFirstDay($now),
Plan::RESET_TRAFFIC_YEARLY => $this->getNextYearlyReset($user, $now),
Plan::RESET_TRAFFIC_NEVER => null,
default => null,
};
}
@@ -251,6 +250,7 @@ class TrafficResetService
Plan::RESET_TRAFFIC_MONTHLY => TrafficResetLog::TYPE_MONTHLY,
Plan::RESET_TRAFFIC_FIRST_DAY_YEAR => TrafficResetLog::TYPE_FIRST_DAY_YEAR,
Plan::RESET_TRAFFIC_YEARLY => TrafficResetLog::TYPE_YEARLY,
Plan::RESET_TRAFFIC_NEVER => TrafficResetLog::TYPE_MANUAL,
default => TrafficResetLog::TYPE_MANUAL,
};
}
+2 -2
View File
@@ -145,8 +145,8 @@ class UserService
'total_available' => $user->transfer_enable ?? 0,
'remaining' => $user->getRemainingTraffic(),
'usage_percentage' => $user->getTrafficUsagePercentage(),
'next_reset_at' => $user->next_reset_at?->timestamp,
'last_reset_at' => $user->last_reset_at?->timestamp,
'next_reset_at' => $user->next_reset_at,
'last_reset_at' => $user->last_reset_at,
'reset_count' => $user->reset_count,
];
}