diff --git a/app/Http/Controllers/Admin/ConfigController.php b/app/Http/Controllers/Admin/ConfigController.php index 3d854ea0..9e5d0af4 100755 --- a/app/Http/Controllers/Admin/ConfigController.php +++ b/app/Http/Controllers/Admin/ConfigController.php @@ -31,7 +31,7 @@ class ConfigController extends Controller 'app_url' => config('v2board.app_url'), 'subscribe_url' => config('v2board.subscribe_url'), 'plan_update_fee' => config('v2board.plan_update_fee', 0.5), - 'plan_is_update' => config('v2board.plan_is_update', 1) + 'plan_is_update' => (int)config('v2board.plan_is_update', 1) ], 'pay' => [ // alipay diff --git a/app/Http/Controllers/Admin/UserController.php b/app/Http/Controllers/Admin/UserController.php index 590e5cbc..b26ee7a1 100644 --- a/app/Http/Controllers/Admin/UserController.php +++ b/app/Http/Controllers/Admin/UserController.php @@ -41,7 +41,9 @@ class UserController extends Controller 'password', 'transfer_enable', 'expired_at', - 'banned', + 'banned', + 'plan_id', + 'commission_rate', 'is_admin' ]); $user = User::find($request->input('id')); @@ -57,6 +59,13 @@ class UserController extends Controller unset($updateData['password']); } $updateData['transfer_enable'] = $updateData['transfer_enable'] * 1073741824; + if ($updateData['plan_id']) { + $plan = Plan::find($updateData['plan_id']); + if (!$plan) { + abort(500, '订阅计划不存在'); + } + $updateData['group_id'] = $plan->group_id; + } if (!$user->update($updateData)) { abort(500, '保存失败'); } diff --git a/install.sql b/install.sql index 25e5f195..caa9f6d7 100644 --- a/install.sql +++ b/install.sql @@ -23,6 +23,7 @@ CREATE TABLE `v2_order` ( `invite_user_id` int(11) DEFAULT NULL, `user_id` int(11) NOT NULL, `plan_id` int(11) NOT NULL, + `type` int(11) NOT NULL COMMENT '1新购2续费3升级', `cycle` varchar(255) NOT NULL, `trade_no` varchar(36) NOT NULL, `callback_no` varchar(255) DEFAULT NULL, @@ -55,13 +56,11 @@ CREATE TABLE `v2_plan` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -SET NAMES utf8mb4; - DROP TABLE IF EXISTS `v2_server`; CREATE TABLE `v2_server` ( `id` int(11) NOT NULL AUTO_INCREMENT, `group_id` varchar(255) NOT NULL, - `name` varchar(255) CHARACTER SET utf8mb4 NOT NULL, + `name` varchar(255) NOT NULL, `host` varchar(255) NOT NULL, `port` int(11) NOT NULL, `server_port` int(11) NOT NULL, @@ -106,6 +105,7 @@ CREATE TABLE `v2_user` ( `invite_user_id` int(11) DEFAULT NULL, `email` varchar(64) NOT NULL, `password` varchar(64) NOT NULL, + `commission_rate` int(11) DEFAULT NULL, `commission_balance` int(11) NOT NULL DEFAULT '0', `t` int(11) NOT NULL DEFAULT '0', `u` bigint(20) NOT NULL DEFAULT '0', @@ -132,4 +132,4 @@ CREATE TABLE `v2_user` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; --- 2019-11-23 14:25:15 \ No newline at end of file +-- 2019-11-27 11:46:36 \ No newline at end of file diff --git a/update.sql b/update.sql index e820d338..9fbef6fb 100644 --- a/update.sql +++ b/update.sql @@ -12,4 +12,7 @@ ALTER TABLE `v2_user` CHANGE `enable` `enable` tinyint(1) NOT NULL DEFAULT '1' AFTER `transfer_enable`; /* 2019-11-25 */ ALTER TABLE `v2_order` -ADD `type` int(11) NOT NULL COMMENT '1新购2续费3升级' AFTER `plan_id`; \ No newline at end of file +ADD `type` int(11) NOT NULL COMMENT '1新购2续费3升级' AFTER `plan_id`; +/* 2019-11-27 */ +ALTER TABLE `v2_user` +ADD `commission_rate` int(11) NULL AFTER `password`; \ No newline at end of file