feature: reset day

This commit is contained in:
Tokumeikoi 2020-08-10 21:17:01 +08:00
parent 4f60cc5311
commit 95d71ae77f
4 changed files with 24 additions and 3 deletions

View File

@ -99,6 +99,7 @@ class UserController extends Controller
}
}
$user['subscribe_url'] = config('v2board.subscribe_url', config('v2board.app_url', env('APP_URL'))) . '/api/v1/client/subscribe?token=' . $user['token'];
$user['reset_day'] = $this->getResetDay($user);
return response([
'data' => $user
]);
@ -160,4 +161,24 @@ class UserController extends Controller
'data' => true
]);
}
private function getResetDay(User $user)
{
if ($user->expired_at <= time() || $user->expired_at === NULL) 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) {
return $lastDay - $today;
}
if ((int)config('v2board.reset_traffic_method') === 1) {
if ((int)$day >= (int)$today) {
return $day - $today;
} else {
return $lastDay - $today + $day;
}
}
return null;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long