mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: fix reset traffic
This commit is contained in:
parent
13327d004d
commit
21a9074b3f
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user