mirror of
https://github.com/v2board/v2board.git
synced 2025-02-11 16:00:27 +08:00
fix reset traffic
This commit is contained in:
parent
e4cb6458c0
commit
35917ad199
@ -38,7 +38,8 @@ class ResetTraffic extends Command
|
|||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
$user = User::where('expired_at', '!=', NULL);
|
$user = User::where('expired_at', '!=', NULL)
|
||||||
|
->where('expired_at', '>', time());
|
||||||
$resetTrafficMethod = config('v2board.reset_traffic_method', 0);
|
$resetTrafficMethod = config('v2board.reset_traffic_method', 0);
|
||||||
switch ((int)$resetTrafficMethod) {
|
switch ((int)$resetTrafficMethod) {
|
||||||
// 1 a month
|
// 1 a month
|
||||||
@ -64,21 +65,14 @@ class ResetTraffic extends Command
|
|||||||
|
|
||||||
private function resetByExpireDay($user):void
|
private function resetByExpireDay($user):void
|
||||||
{
|
{
|
||||||
$date = date('Y-m-d', time());
|
|
||||||
$startAt = strtotime((string)$date);
|
|
||||||
$endAt = (int)$startAt + 24 * 3600;
|
|
||||||
$lastDay = date('d', strtotime('last day of +0 months'));
|
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||||
if ((string)$lastDay === '29') {
|
foreach ($user->get() as $item) {
|
||||||
$endAt = (int)$startAt + 72 * 3600;
|
$expireDay = date('d', $item->expired_at);
|
||||||
|
if ($expireDay === date('d') || (string)$lastDay === '29' || (string)$lastDay === '30') {
|
||||||
|
$item->u = 0;
|
||||||
|
$item->d = 0;
|
||||||
|
$item->save();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((string)$lastDay === '30') {
|
|
||||||
$endAt = (int)$startAt + 48 * 3600;
|
|
||||||
}
|
|
||||||
$user->where('expired_at', '>=', (int)$startAt)
|
|
||||||
->where('expired_at', '<', (int)$endAt)
|
|
||||||
->update([
|
|
||||||
'u' => 0,
|
|
||||||
'd' => 0
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user