mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 17:49:11 +08:00
update: reset by next year
This commit is contained in:
parent
4ad44c5f45
commit
fe1ab11bbd
@ -69,6 +69,9 @@ class ResetTraffic extends Command
|
|||||||
// no action
|
// no action
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
|
// year
|
||||||
|
case 3:
|
||||||
|
$this->resetByYear($builder);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -85,10 +88,25 @@ class ResetTraffic extends Command
|
|||||||
case ($resetMethod['method'] === 2): {
|
case ($resetMethod['method'] === 2): {
|
||||||
break;
|
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
|
private function resetByMonthFirstDay($builder):void
|
||||||
{
|
{
|
||||||
if ((string)date('d') === '01') {
|
if ((string)date('d') === '01') {
|
||||||
|
@ -16,7 +16,6 @@ class PlanController extends Controller
|
|||||||
{
|
{
|
||||||
public function fetch(Request $request)
|
public function fetch(Request $request)
|
||||||
{
|
{
|
||||||
|
|
||||||
$counts = User::select(
|
$counts = User::select(
|
||||||
DB::raw("plan_id"),
|
DB::raw("plan_id"),
|
||||||
DB::raw("count(*) as count")
|
DB::raw("count(*) as count")
|
||||||
|
@ -189,18 +189,21 @@ class UserController extends Controller
|
|||||||
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 (isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 2) return null;
|
if (isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 2) return null;
|
||||||
$day = date('d', $user->expired_at);
|
|
||||||
$today = date('d');
|
|
||||||
$lastDay = date('d', strtotime('last day of +0 months'));
|
|
||||||
|
|
||||||
if ((int)config('v2board.reset_traffic_method') === 0 ||
|
if ((int)config('v2board.reset_traffic_method') === 0 ||
|
||||||
(isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 0))
|
(isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 0))
|
||||||
{
|
{
|
||||||
|
$day = date('d', $user->expired_at);
|
||||||
|
$today = date('d');
|
||||||
|
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||||
return $lastDay - $today;
|
return $lastDay - $today;
|
||||||
}
|
}
|
||||||
if ((int)config('v2board.reset_traffic_method') === 1 ||
|
if ((int)config('v2board.reset_traffic_method') === 1 ||
|
||||||
(isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 1))
|
(isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 1))
|
||||||
{
|
{
|
||||||
|
$day = date('d', $user->expired_at);
|
||||||
|
$today = date('d');
|
||||||
|
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||||
if ((int)$day >= (int)$today && (int)$day >= (int)$lastDay) {
|
if ((int)$day >= (int)$today && (int)$day >= (int)$lastDay) {
|
||||||
return $lastDay - $today;
|
return $lastDay - $today;
|
||||||
}
|
}
|
||||||
@ -210,6 +213,12 @@ class UserController extends Controller
|
|||||||
return $lastDay - $today + $day;
|
return $lastDay - $today + $day;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((int)config('v2board.reset_traffic_method') === 2 ||
|
||||||
|
(isset($user->plan->reset_traffic_method) && $user->plan->reset_traffic_method === 2))
|
||||||
|
{
|
||||||
|
$nextYear = strtotime(date("Y-01-01", strtotime('+1 year')));
|
||||||
|
return (int)(($nextYear - time()) / 86400);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ class ConfigSave extends FormRequest
|
|||||||
'register_limit_expire' => 'integer',
|
'register_limit_expire' => 'integer',
|
||||||
// subscribe
|
// subscribe
|
||||||
'plan_change_enable' => 'in:0,1',
|
'plan_change_enable' => 'in:0,1',
|
||||||
'reset_traffic_method' => 'in:0,1,2',
|
'reset_traffic_method' => 'in:0,1,2,3',
|
||||||
'surplus_enable' => 'in:0,1',
|
'surplus_enable' => 'in:0,1',
|
||||||
'new_order_event_id' => 'in:0,1',
|
'new_order_event_id' => 'in:0,1',
|
||||||
'renew_order_event_id' => 'in:0,1',
|
'renew_order_event_id' => 'in:0,1',
|
||||||
|
@ -26,7 +26,7 @@ class PlanSave extends FormRequest
|
|||||||
'three_year_price' => 'nullable|integer',
|
'three_year_price' => 'nullable|integer',
|
||||||
'onetime_price' => 'nullable|integer',
|
'onetime_price' => 'nullable|integer',
|
||||||
'reset_price' => 'nullable|integer',
|
'reset_price' => 'nullable|integer',
|
||||||
'reset_traffic_method' => 'nullable|integer|in:0,1,2'
|
'reset_traffic_method' => 'nullable|integer|in:0,1,2,3'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
public/assets/admin/umi.js
vendored
2
public/assets/admin/umi.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user