From ef366d8d8b7ea026d129e7219891dcec388a0e09 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Sun, 7 Aug 2022 02:32:57 +0800 Subject: [PATCH] update: reset day --- app/Http/Controllers/Client/Protocols/Clash.php | 1 - app/Http/Controllers/Client/Protocols/Stash.php | 1 - app/Services/UserService.php | 8 ++++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Client/Protocols/Clash.php b/app/Http/Controllers/Client/Protocols/Clash.php index 06f40537..4a806e3e 100644 --- a/app/Http/Controllers/Client/Protocols/Clash.php +++ b/app/Http/Controllers/Client/Protocols/Clash.php @@ -121,7 +121,6 @@ class Clash $array['ws-opts']['path'] = $wsSettings['path']; if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; - // TODO: 2022.06.01 remove it if (isset($wsSettings['path']) && !empty($wsSettings['path'])) $array['ws-path'] = $wsSettings['path']; if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) diff --git a/app/Http/Controllers/Client/Protocols/Stash.php b/app/Http/Controllers/Client/Protocols/Stash.php index 1821e46b..4d9e42bb 100644 --- a/app/Http/Controllers/Client/Protocols/Stash.php +++ b/app/Http/Controllers/Client/Protocols/Stash.php @@ -122,7 +122,6 @@ class Stash $array['ws-opts']['path'] = $wsSettings['path']; if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; - // TODO: 2022.06.01 remove it if (isset($wsSettings['path']) && !empty($wsSettings['path'])) $array['ws-path'] = $wsSettings['path']; if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) diff --git a/app/Services/UserService.php b/app/Services/UserService.php index b15c1c57..a7f9f1ae 100644 --- a/app/Services/UserService.php +++ b/app/Services/UserService.php @@ -8,6 +8,7 @@ use App\Jobs\StatUserJob; use App\Jobs\TrafficFetchJob; use App\Models\InviteCode; use App\Models\Order; +use App\Models\Plan; use App\Models\ServerV2ray; use App\Models\Ticket; use App\Models\User; @@ -37,13 +38,13 @@ class UserService } } - private function calcResetDayByYearFirstDay() + private function calcResetDayByYearFirstDay(): int { $nextYear = strtotime(date("Y-01-01", strtotime('+1 year'))); return (int)(($nextYear - time()) / 86400); } - private function calcResetDayByYearExpiredAt(int $expiredAt) + private function calcResetDayByYearExpiredAt(int $expiredAt): int { $md = date('m-d', $expiredAt); $nowYear = strtotime(date("Y-{$md}")); @@ -53,6 +54,9 @@ class UserService public function getResetDay(User $user) { + if (!isset($user->plan)) { + $user->plan = Plan::find($user->plan_id); + } if ($user->expired_at <= time() || $user->expired_at === NULL) return null; // if reset method is not reset if ($user->plan->reset_traffic_method === 2) return null;