mirror of
https://github.com/v2board/v2board.git
synced 2024-11-10 09:39:10 +08:00
update: add plan reset method
This commit is contained in:
parent
25b3b11efd
commit
7a4bd468a2
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Plan;
|
||||
use Illuminate\Console\Command;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -43,27 +44,44 @@ class ResetTraffic extends Command
|
||||
public function handle()
|
||||
{
|
||||
ini_set('memory_limit', -1);
|
||||
DB::beginTransaction();
|
||||
$resetTrafficMethod = config('v2board.reset_traffic_method', 0);
|
||||
switch ((int)$resetTrafficMethod) {
|
||||
// 1 a month
|
||||
case 0:
|
||||
$this->resetByMonthFirstDay();
|
||||
break;
|
||||
// expire day
|
||||
case 1:
|
||||
$this->resetByExpireDay();
|
||||
break;
|
||||
// no action
|
||||
case 2:
|
||||
break;
|
||||
foreach (Plan::get() as $plan) {
|
||||
switch ($plan->reset_traffic_method) {
|
||||
case null: {
|
||||
$resetTrafficMethod = config('v2board.reset_traffic_method', 0);
|
||||
switch ((int)$resetTrafficMethod) {
|
||||
// month first day
|
||||
case 0:
|
||||
$this->resetByMonthFirstDay($this->builder);
|
||||
break;
|
||||
// expire day
|
||||
case 1:
|
||||
$this->resetByExpireDay($this->builder);
|
||||
break;
|
||||
// no action
|
||||
case 2:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 0: {
|
||||
$builder = $this->builder->where('plan_id', $plan->id);
|
||||
$this->resetByMonthFirstDay($builder);
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
$builder = $this->builder->where('plan_id', $plan->id);
|
||||
$this->resetByExpireDay($builder);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
DB::commit();
|
||||
}
|
||||
|
||||
private function resetByMonthFirstDay():void
|
||||
private function resetByMonthFirstDay($builder):void
|
||||
{
|
||||
$builder = $this->builder;
|
||||
if ((string)date('d') === '01') {
|
||||
$builder->update([
|
||||
'u' => 0,
|
||||
@ -72,9 +90,8 @@ class ResetTraffic extends Command
|
||||
}
|
||||
}
|
||||
|
||||
private function resetByExpireDay():void
|
||||
private function resetByExpireDay($builder):void
|
||||
{
|
||||
$builder = $this->builder;
|
||||
$lastDay = date('d', strtotime('last day of +0 months'));
|
||||
$users = [];
|
||||
foreach ($builder->get() as $item) {
|
||||
|
@ -25,7 +25,8 @@ class PlanSave extends FormRequest
|
||||
'two_year_price' => 'nullable|integer',
|
||||
'three_year_price' => 'nullable|integer',
|
||||
'onetime_price' => 'nullable|integer',
|
||||
'reset_price' => 'nullable|integer'
|
||||
'reset_price' => 'nullable|integer',
|
||||
'reset_traffic_method' => 'nullable|integer|in:0,1,2'
|
||||
];
|
||||
}
|
||||
|
||||
@ -44,7 +45,9 @@ class PlanSave extends FormRequest
|
||||
'two_year_price.integer' => '两年付金额格式有误',
|
||||
'three_year_price.integer' => '三年付金额格式有误',
|
||||
'onetime_price.integer' => '一次性金额有误',
|
||||
'reset_price.integer' => '流量重置包金额有误'
|
||||
'reset_price.integer' => '流量重置包金额有误',
|
||||
'reset_traffic_method.integer' => '流量重置方式格式有误',
|
||||
'reset_traffic_method.in' => '流量重置方式格式有误'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -165,6 +165,7 @@ CREATE TABLE `v2_plan` (
|
||||
`three_year_price` int(11) DEFAULT NULL,
|
||||
`onetime_price` int(11) DEFAULT NULL,
|
||||
`reset_price` int(11) DEFAULT NULL,
|
||||
`reset_traffic_method` tinyint(1) DEFAULT NULL,
|
||||
`created_at` int(11) NOT NULL,
|
||||
`updated_at` int(11) NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
@ -367,4 +368,4 @@ CREATE TABLE `v2_user` (
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
-- 2021-09-18 12:00:43
|
||||
-- 2021-09-20 15:35:06
|
||||
|
@ -452,3 +452,6 @@ CREATE TABLE `v2_commission_log` (
|
||||
`created_at` int(11) NOT NULL,
|
||||
`updated_at` int(11) NOT NULL
|
||||
) COLLATE 'utf8mb4_general_ci';
|
||||
|
||||
ALTER TABLE `v2_plan`
|
||||
ADD `reset_traffic_method` tinyint(1) NULL AFTER `reset_price`;
|
||||
|
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
2
public/theme/v2board/assets/umi.js
vendored
2
public/theme/v2board/assets/umi.js
vendored
File diff suppressed because one or more lines are too long
@ -20,6 +20,11 @@
|
||||
## Sponsors
|
||||
Thanks to the open source project license provided by [Jetbrains](https://www.jetbrains.com/)
|
||||
|
||||
## Other
|
||||
## Community
|
||||
Telegram Channel: [@v2board](https://t.me/v2board)
|
||||
We have closed issue. If you want to find us, please contact us through the telegram group.
|
||||
|
||||
## Rules
|
||||
1.We have closed issue. If you want to find us, please contact us through the telegram group.
|
||||
2.Forward, Please indicate the original repo.
|
||||
3.This repo is v2board api interface open source.
|
||||
4.Due to the copyright problem, we have no plan to open source the front-end, but the front-end code is still readable.
|
||||
|
Loading…
Reference in New Issue
Block a user