mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 09:21:46 +08:00 
			
		
		
		
	opt: mail & reset traffic
This commit is contained in:
		| @@ -7,6 +7,7 @@ use App\Models\User; | ||||
|  | ||||
| class ResetTraffic extends Command | ||||
| { | ||||
|     protected $user; | ||||
|     /** | ||||
|      * The name and signature of the console command. | ||||
|      * | ||||
| @@ -29,6 +30,8 @@ class ResetTraffic extends Command | ||||
|     public function __construct() | ||||
|     { | ||||
|         parent::__construct(); | ||||
|         $this->user = User::where('expired_at', '!=', NULL) | ||||
|             ->where('expired_at', '>', time()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -38,23 +41,22 @@ class ResetTraffic extends Command | ||||
|      */ | ||||
|     public function handle() | ||||
|     { | ||||
|         $user = User::where('expired_at', '!=', NULL) | ||||
|             ->where('expired_at', '>', time()); | ||||
|         $resetTrafficMethod = config('v2board.reset_traffic_method', 0); | ||||
|         switch ((int)$resetTrafficMethod) { | ||||
|             // 1 a month | ||||
|             case 0: | ||||
|                 $this->resetByMonthFirstDay($user); | ||||
|                 $this->resetByMonthFirstDay(); | ||||
|                 break; | ||||
|             // expire day | ||||
|             case 1: | ||||
|                 $this->resetByExpireDay($user); | ||||
|                 $this->resetByExpireDay(); | ||||
|                 break; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function resetByMonthFirstDay($user):void | ||||
|     { | ||||
|         $user = $this->user; | ||||
|         if ((string)date('d') === '01') { | ||||
|             $user->update([ | ||||
|                 'u' => 0, | ||||
| @@ -63,8 +65,9 @@ class ResetTraffic extends Command | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private function resetByExpireDay($user):void | ||||
|     private function resetByExpireDay():void | ||||
|     { | ||||
|         $user = $this->user; | ||||
|         $lastDay = date('d', strtotime('last day of +0 months')); | ||||
|         $users = []; | ||||
|         foreach ($user->get() as $item) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user