Skip to content

Commit e0a1960

Browse files
author
M1Screw
committed
refactor: remove deprecated user value
1 parent 3bd2972 commit e0a1960

File tree

8 files changed

+30
-28
lines changed

8 files changed

+30
-28
lines changed

db/migrations/2023020100-init.php

-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ public function up(): int
277277
`last_check_in_time` int(11) unsigned DEFAULT 0 COMMENT '最后签到时间',
278278
`last_login_time` int(11) unsigned DEFAULT 0 COMMENT '最后登录时间',
279279
`reg_date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '注册时间',
280-
`invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数',
281280
`money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额',
282281
`ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '邀请人ID',
283282
`method` varchar(255) NOT NULL DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式',

db/migrations/2023060300-add_user_locale_and_update_data_type.php

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public function up(): int
2323
ALTER TABLE user MODIFY COLUMN `all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数';
2424
ALTER TABLE user MODIFY COLUMN `last_check_in_time` int(11) unsigned DEFAULT 0 COMMENT '最后签到时间';
2525
ALTER TABLE user MODIFY COLUMN `reg_date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '注册时间';
26-
ALTER TABLE user MODIFY COLUMN `invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数';
2726
ALTER TABLE user MODIFY COLUMN `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额';
2827
ALTER TABLE user MODIFY COLUMN `ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '邀请人ID';
2928
ALTER TABLE user MODIFY COLUMN `method` varchar(255) NOT NULL DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use App\Interfaces\MigrationInterface;
6+
use App\Services\DB;
7+
8+
return new class() implements MigrationInterface {
9+
public function up(): int
10+
{
11+
DB::getPdo()->exec('
12+
ALTER TABLE user DROP COLUMN IF EXISTS `invite_num`;
13+
');
14+
15+
return 2024012300;
16+
}
17+
18+
public function down(): int
19+
{
20+
DB::getPdo()->exec("
21+
ALTER TABLE user ADD COLUMN IF NOT EXISTS `invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数';
22+
");
23+
24+
return 2024012000;
25+
}
26+
};

resources/views/tabler/admin/user/edit.tpl

-7
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,6 @@
169169
<div class="hr-text">
170170
<span>邀请注册</span>
171171
</div>
172-
<div class="form-group mb-3 row">
173-
<label class="form-label col-4 col-form-label">可用邀请数量</label>
174-
<div class="col">
175-
<input id="invite_num" type="text" class="form-control"
176-
value="{$edit_user->invite_num}">
177-
</div>
178-
</div>
179172
<div class="form-group mb-3 row">
180173
<label class="form-label col-4 col-form-label">邀请人</label>
181174
<div class="col">

src/Command/Tool.php

-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ public function createAdmin(): void
371371
$user->u = 0;
372372
$user->d = 0;
373373
$user->transfer_enable = 0;
374-
$user->invite_num = 0;
375374
$user->ref_by = 0;
376375
$user->is_admin = 1;
377376
$user->reg_date = date('Y-m-d H:i:s');

src/Controllers/Admin/UserController.php

-2
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ final class UserController extends BaseController
7676
'banned_reason',
7777
'is_shadow_banned',
7878
'transfer_enable',
79-
'invite_num',
8079
'ref_by',
8180
'class_expire',
8281
'node_group',
@@ -199,7 +198,6 @@ public function update(ServerRequest $request, Response $response, array $args):
199198
$user->banned_reason = $request->getParam('banned_reason');
200199
$user->is_shadow_banned = $request->getParam('is_shadow_banned') === 'true' ? 1 : 0;
201200
$user->transfer_enable = Tools::autoBytesR($request->getParam('transfer_enable'));
202-
$user->invite_num = $request->getParam('invite_num');
203201
$user->ref_by = $request->getParam('ref_by');
204202
$user->class_expire = $request->getParam('class_expire');
205203
$user->node_group = $request->getParam('node_group');

src/Controllers/AuthController.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ public function registerHelper(
245245
$user->im_type = $imtype;
246246
$user->im_value = $imvalue;
247247
$user->transfer_enable = Tools::toGB($configs['sign_up_for_free_traffic']);
248-
$user->invite_num = $configs['sign_up_for_invitation_codes'];
249248
$user->auto_reset_day = Config::obtain('free_user_reset_day');
250249
$user->auto_reset_bandwidth = Config::obtain('free_user_reset_bandwidth');
251250
$user->daily_mail_enable = $configs['sign_up_for_daily_report'];
@@ -337,15 +336,15 @@ public function registerHandle(ServerRequest $request, Response $response, array
337336
}
338337

339338
if ($invite_code !== '') {
340-
$user_invite = (new InviteCode())->where('code', $invite_code)->first();
339+
$invite = (new InviteCode())->where('code', $invite_code)->first();
341340

342-
if ($user_invite === null) {
341+
if ($invite === null) {
343342
return ResponseHelper::error($response, '邀请码无效');
344343
}
345344

346-
$gift_user = (new User())->where('id', $user_invite->user_id)->first();
345+
$ref_user = (new User())->where('id', $invite->user_id)->first();
347346

348-
if ($gift_user === null || $gift_user->invite_num === 0) {
347+
if ($ref_user === null) {
349348
return ResponseHelper::error($response, '邀请码无效');
350349
}
351350
}

src/Models/User.php

-11
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
* @property int $last_check_in_time 最后签到时间
4141
* @property int $last_login_time 最后登录时间
4242
* @property string $reg_date 注册时间
43-
* @property int $invite_num 可用邀请次数
4443
* @property float $money 账户余额
4544
* @property int $ref_by 邀请人ID
4645
* @property string $method Shadowsocks加密方式
@@ -186,16 +185,6 @@ public function addInviteCode(): string
186185
return $code->code;
187186
}
188187

189-
/**
190-
* 添加邀请次数
191-
*/
192-
public function addInviteNum(int $num): bool
193-
{
194-
$this->invite_num += $num;
195-
196-
return $this->save();
197-
}
198-
199188
/**
200189
* 生成新的 API Token
201190
*/

0 commit comments

Comments
 (0)