update: reset day

This commit is contained in:
tokumeikoi 2022-08-07 02:32:57 +08:00
parent bd1ec0fe89
commit ef366d8d8b
3 changed files with 6 additions and 4 deletions

View File

@ -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']))

View File

@ -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']))

View File

@ -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;