update: reset by next year

This commit is contained in:
tokumeikoi
2022-05-30 14:28:15 +08:00
parent 4ad44c5f45
commit fe1ab11bbd
6 changed files with 33 additions and 7 deletions

View File

@ -69,6 +69,9 @@ class ResetTraffic extends Command
// no action
case 2:
break;
// year
case 3:
$this->resetByYear($builder);
}
break;
}
@ -85,10 +88,25 @@ class ResetTraffic extends Command
case ($resetMethod['method'] === 2): {
break;
}
case ($resetMethod['method'] === 3): {
$builder = with(clone($this->builder))->whereIn('plan_id', $planIds);
$this->resetByYear($builder);
break;
}
}
}
}
private function resetByYear($builder):void
{
if ((string)date('d') === '01' && (string)date('m') === '01') {
$builder->update([
'u' => 0,
'd' => 0
]);
}
}
private function resetByMonthFirstDay($builder):void
{
if ((string)date('d') === '01') {