mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	update: reset day
This commit is contained in:
		| @@ -121,7 +121,6 @@ class Clash | |||||||
|                     $array['ws-opts']['path'] = $wsSettings['path']; |                     $array['ws-opts']['path'] = $wsSettings['path']; | ||||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) |                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||||
|                     $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; |                     $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; | ||||||
|                 // TODO: 2022.06.01 remove it |  | ||||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) |                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||||
|                     $array['ws-path'] = $wsSettings['path']; |                     $array['ws-path'] = $wsSettings['path']; | ||||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) |                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||||
|   | |||||||
| @@ -122,7 +122,6 @@ class Stash | |||||||
|                     $array['ws-opts']['path'] = $wsSettings['path']; |                     $array['ws-opts']['path'] = $wsSettings['path']; | ||||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) |                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||||
|                     $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; |                     $array['ws-opts']['headers'] = ['Host' => $wsSettings['headers']['Host']]; | ||||||
|                 // TODO: 2022.06.01 remove it |  | ||||||
|                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) |                 if (isset($wsSettings['path']) && !empty($wsSettings['path'])) | ||||||
|                     $array['ws-path'] = $wsSettings['path']; |                     $array['ws-path'] = $wsSettings['path']; | ||||||
|                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) |                 if (isset($wsSettings['headers']['Host']) && !empty($wsSettings['headers']['Host'])) | ||||||
|   | |||||||
| @@ -8,6 +8,7 @@ use App\Jobs\StatUserJob; | |||||||
| use App\Jobs\TrafficFetchJob; | use App\Jobs\TrafficFetchJob; | ||||||
| use App\Models\InviteCode; | use App\Models\InviteCode; | ||||||
| use App\Models\Order; | use App\Models\Order; | ||||||
|  | use App\Models\Plan; | ||||||
| use App\Models\ServerV2ray; | use App\Models\ServerV2ray; | ||||||
| use App\Models\Ticket; | use App\Models\Ticket; | ||||||
| use App\Models\User; | 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'))); |         $nextYear = strtotime(date("Y-01-01", strtotime('+1 year'))); | ||||||
|         return (int)(($nextYear - time()) / 86400); |         return (int)(($nextYear - time()) / 86400); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private function calcResetDayByYearExpiredAt(int $expiredAt) |     private function calcResetDayByYearExpiredAt(int $expiredAt): int | ||||||
|     { |     { | ||||||
|         $md = date('m-d', $expiredAt); |         $md = date('m-d', $expiredAt); | ||||||
|         $nowYear = strtotime(date("Y-{$md}")); |         $nowYear = strtotime(date("Y-{$md}")); | ||||||
| @@ -53,6 +54,9 @@ class UserService | |||||||
|  |  | ||||||
|     public function getResetDay(User $user) |     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 ($user->expired_at <= time() || $user->expired_at === NULL) return null; | ||||||
|         // if reset method is not reset |         // if reset method is not reset | ||||||
|         if ($user->plan->reset_traffic_method === 2) return null; |         if ($user->plan->reset_traffic_method === 2) return null; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user