mirror of
				https://github.com/v2board/v2board.git
				synced 2025-10-31 17:31:49 +08:00 
			
		
		
		
	update: fix reset traffic
This commit is contained in:
		| @@ -44,18 +44,27 @@ class ResetTraffic extends Command | |||||||
|     public function handle() |     public function handle() | ||||||
|     { |     { | ||||||
|         ini_set('memory_limit', -1); |         ini_set('memory_limit', -1); | ||||||
|         foreach (Plan::get() as $plan) { |         $resetMethods = Plan::select( | ||||||
|             switch ($plan->reset_traffic_method) { |             DB::raw("GROUP_CONCAT(`id`) as plan_ids"), | ||||||
|  |             DB::raw("reset_traffic_method as method") | ||||||
|  |         ) | ||||||
|  |             ->groupBy('reset_traffic_method') | ||||||
|  |             ->get() | ||||||
|  |             ->toArray(); | ||||||
|  |         foreach ($resetMethods as $resetMethod) { | ||||||
|  |             $planIds = explode(',', $resetMethod['plan_ids']); | ||||||
|  |             switch ($resetMethod['method']) { | ||||||
|                 case null: { |                 case null: { | ||||||
|                     $resetTrafficMethod = config('v2board.reset_traffic_method', 0); |                     $resetTrafficMethod = config('v2board.reset_traffic_method', 0); | ||||||
|  |                     $builder = with(clone($this->builder))->whereIn('plan_id', $planIds); | ||||||
|                     switch ((int)$resetTrafficMethod) { |                     switch ((int)$resetTrafficMethod) { | ||||||
|                         // month first day |                         // month first day | ||||||
|                         case 0: |                         case 0: | ||||||
|                             $this->resetByMonthFirstDay($this->builder); |                             $this->resetByMonthFirstDay($builder); | ||||||
|                             break; |                             break; | ||||||
|                         // expire day |                         // expire day | ||||||
|                         case 1: |                         case 1: | ||||||
|                             $this->resetByExpireDay($this->builder); |                             $this->resetByExpireDay($builder); | ||||||
|                             break; |                             break; | ||||||
|                         // no action |                         // no action | ||||||
|                         case 2: |                         case 2: | ||||||
| @@ -64,12 +73,12 @@ class ResetTraffic extends Command | |||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case 0: { |                 case 0: { | ||||||
|                     $builder = with(clone($this->builder))->where('plan_id', $plan->id); |                     $builder = with(clone($this->builder))->whereIn('plan_id', $planIds); | ||||||
|                     $this->resetByMonthFirstDay($builder); |                     $this->resetByMonthFirstDay($builder); | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|                 case 1: { |                 case 1: { | ||||||
|                     $builder = with(clone($this->builder))->where('plan_id', $plan->id); |                     $builder = with(clone($this->builder))->whereIn('plan_id', $planIds); | ||||||
|                     $this->resetByExpireDay($builder); |                     $this->resetByExpireDay($builder); | ||||||
|                     break; |                     break; | ||||||
|                 } |                 } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user