Browse Source

refactor: user table data type

M1Screw 2 years ago
parent
commit
9b199489b0

+ 47 - 44
db/migrations/2023020100-init.php

@@ -269,59 +269,62 @@ return new class() implements MigrationInterface {
 
             CREATE TABLE `user` (
                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '用户ID',
-                `user_name` varchar(255) DEFAULT NULL COMMENT '用户名',
-                `email` varchar(255) DEFAULT NULL COMMENT 'E-Mail',
-                `pass` varchar(255) DEFAULT NULL COMMENT '登录密码',
-                `passwd` varchar(255) DEFAULT NULL COMMENT '节点密码',
+                `user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名',
+                `email` varchar(255) NOT NULL COMMENT 'E-Mail',
+                `pass` varchar(255) NOT NULL COMMENT '登录密码',
+                `passwd` varchar(255) NOT NULL COMMENT '节点密码',
                 `uuid` char(36) NOT NULL COMMENT 'UUID',
-                `t` bigint(20) unsigned DEFAULT 0 COMMENT '最后使用时间',
-                `u` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前上传流量',
-                `d` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前下载流量',
-                `transfer_today` bigint(20) unsigned DEFAULT 0 COMMENT '账户今日所用流量',
-                `transfer_total` bigint(20) unsigned DEFAULT 0 COMMENT '账户累计使用流量',
-                `transfer_enable` bigint(20) unsigned DEFAULT 0 COMMENT '账户当前可用流量',
+                `t` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '最后使用时间',
+                `u` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前上传流量',
+                `d` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前下载流量',
+                `transfer_today` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户今日所用流量',
+                `transfer_total` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户累计使用流量',
+                `transfer_enable` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前可用流量',
                 `port` smallint(6) unsigned NOT NULL COMMENT '端口',
-                `last_detect_ban_time` datetime DEFAULT '1989-06-04 00:05:00' COMMENT '最后一次被封禁的时间',
-                `all_detect_number` int(11) DEFAULT 0 COMMENT '累计违规次数',
-                `last_check_in_time` bigint(20) unsigned DEFAULT 0 COMMENT '最后签到时间',
-                `reg_date` datetime DEFAULT NULL COMMENT '注册时间',
-                `invite_num` int(11) DEFAULT 0 COMMENT '可用邀请次数',
-                `money` decimal(10,2) NOT NULL DEFAULT 0.00,
-                `ref_by` bigint(20) unsigned DEFAULT 0 COMMENT '邀请人ID',
-                `method` varchar(255) DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式',
-                `reg_ip` varchar(255) DEFAULT '127.0.0.1' COMMENT '注册IP',
+                `last_detect_ban_time` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '最后一次被封禁的时间',
+                `all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数',
+                `last_check_in_time` int(11) unsigned DEFAULT 0 COMMENT '最后签到时间',
+                `reg_date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '注册时间',
+                `invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数',
+                `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额',
+                `ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '邀请人ID',
+                `method` varchar(255) NOT NULL DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式',
+                `reg_ip` varchar(255) NOT NULL DEFAULT '127.0.0.1' COMMENT '注册IP',
                 `node_speedlimit` double NOT NULL DEFAULT 0 COMMENT '用户限速',
                 `node_iplimit` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '同时可连接IP数',
-                `node_connector` int(11) DEFAULT 0 COMMENT '同时可使用连接数',
-                `is_admin` tinyint(1) DEFAULT 0 COMMENT '是否管理员',
-                `im_type` int(11) DEFAULT 1 COMMENT '联系方式类型',
-                `im_value` varchar(255) DEFAULT '' COMMENT '联系方式',
-                `sendDailyMail` tinyint(1) DEFAULT 0 COMMENT '每日报告开关',
-                `class` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '等级',
-                `class_expire` datetime DEFAULT '1989-06-04 00:05:00' COMMENT '等级过期时间',
-                `expire_in` datetime DEFAULT '2199-01-01 00:00:00',
-                `theme` varchar(255) DEFAULT NULL COMMENT '网站主题',
-                `ga_token` varchar(255) DEFAULT NULL,
-                `ga_enable` int(11) DEFAULT 0,
-                `remark` text DEFAULT '' COMMENT '备注',
-                `node_group` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '节点分组',
-                `is_banned` int(11) DEFAULT 0 COMMENT '是否封禁',
-                `banned_reason` varchar(255) DEFAULT '' COMMENT '封禁理由',
-                `telegram_id` bigint(20) DEFAULT 0,
-                `expire_notified` tinyint(1) DEFAULT 0,
-                `traffic_notified` tinyint(1) DEFAULT 0,
-                `forbidden_ip` varchar(255) DEFAULT '',
-                `forbidden_port` varchar(255) DEFAULT '',
-                `auto_reset_day` int(11) DEFAULT 0,
-                `auto_reset_bandwidth` decimal(12,2) DEFAULT 0.00,
+                `node_connector` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '同时可使用连接数',
+                `is_admin` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否管理员',
+                `im_type` smallint(6) unsigned NOT NULL DEFAULT 1 COMMENT '联系方式类型',
+                `im_value` varchar(255) NOT NULL DEFAULT '' COMMENT '联系方式',
+                `daily_mail_enable` tinyint(1) NOT NULL DEFAULT 0 COMMENT '每日报告开关',
+                `class` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '等级',
+                `class_expire` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '等级过期时间',
+                `expire_in` datetime NOT NULL DEFAULT '2199-01-01 00:00:00' COMMENT '账户过期时间',
+                `theme` varchar(255) NOT NULL DEFAULT 'tabler' COMMENT '网站主题',
+                `ga_token` varchar(255) NOT NULL DEFAULT '' COMMENT 'GA密钥',
+                `ga_enable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'GA开关',
+                `remark` text NOT NULL DEFAULT '' COMMENT '备注',
+                `node_group` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '节点分组',
+                `is_banned` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否封禁',
+                `banned_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '封禁理由',
+                `telegram_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT 'Telegram ID',
+                `expire_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '过期提醒',
+                `traffic_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '流量提醒',
+                `forbidden_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问IP',
+                `forbidden_port` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问端口',
+                `auto_reset_day` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '自动重置流量日',
+                `auto_reset_bandwidth` decimal(12,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '自动重置流量',
                 `api_token` char(36) NOT NULL DEFAULT '' COMMENT 'API 密钥',
-                `use_new_shop` smallint(6) NOT NULL DEFAULT 0 COMMENT '是否启用新商店',
-                `is_dark_mode` int(11) DEFAULT 0,
+                `use_new_shop` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否启用新商店',
+                `is_dark_mode` tinyint(1) NOT NULL DEFAULT 0,
+                `locale` varchar(16) NOT NULL DEFAULT 'zh-TW' COMMENT '显示语言',
                 PRIMARY KEY (`id`),
                 UNIQUE KEY `uuid` (`uuid`),
                 UNIQUE KEY `email` (`email`),
                 UNIQUE KEY `ga_token` (`ga_token`),
-                KEY `user_name` (`user_name`)
+                UNIQUE KEY `api_token` (`api_token`),
+                KEY `is_admin` (`is_admin`),
+                KEY `is_banned` (`is_banned`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `user_coupon` (

+ 73 - 0
db/migrations/2023060300-add_user_locale_and_update_data_type.php

@@ -0,0 +1,73 @@
+<?php
+
+declare(strict_types=1);
+
+use App\Interfaces\MigrationInterface;
+use App\Services\DB;
+
+return new class() implements MigrationInterface {
+    public function up(): int
+    {
+        DB::getPdo()->exec("
+        ALTER TABLE user ADD COLUMN IF NOT EXISTS `locale` varchar(16) NOT NULL DEFAULT 'zh-TW' COMMENT '显示语言';
+        ALTER TABLE user MODIFY COLUMN `user_name` varchar(255) NOT NULL DEFAULT '' COMMENT '用户名';
+        ALTER TABLE user MODIFY COLUMN `email` varchar(255) NOT NULL COMMENT 'Email';
+        ALTER TABLE user MODIFY COLUMN `pass` varchar(255) NOT NULL COMMENT '登录密码';
+        ALTER TABLE user MODIFY COLUMN `passwd` varchar(255) NOT NULL COMMENT '节点密码';
+        ALTER TABLE user MODIFY COLUMN `t` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '最后使用时间';
+        ALTER TABLE user MODIFY COLUMN `u` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前上传流量';
+        ALTER TABLE user MODIFY COLUMN `d` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前下载流量';
+        ALTER TABLE user MODIFY COLUMN `transfer_today` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户今日所用流量';
+        ALTER TABLE user MODIFY COLUMN `transfer_total` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户累计使用流量';
+        ALTER TABLE user MODIFY COLUMN `transfer_enable` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '账户当前可用流量';
+        ALTER TABLE user MODIFY COLUMN `last_detect_ban_time` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '最后一次被封禁的时间';
+        ALTER TABLE user MODIFY COLUMN `all_detect_number` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '累计违规次数';
+        ALTER TABLE user MODIFY COLUMN `last_check_in_time` int(11) unsigned DEFAULT 0 COMMENT '最后签到时间';
+        ALTER TABLE user MODIFY COLUMN `reg_date` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '注册时间';
+        ALTER TABLE user MODIFY COLUMN `invite_num` int(11) NOT NULL DEFAULT 0 COMMENT '可用邀请次数';
+        ALTER TABLE user MODIFY COLUMN `money` decimal(10,2) NOT NULL DEFAULT 0.00 COMMENT '账户余额';
+        ALTER TABLE user MODIFY COLUMN `ref_by` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '邀请人ID';
+        ALTER TABLE user MODIFY COLUMN `method` varchar(255) NOT NULL DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式';
+        ALTER TABLE user MODIFY COLUMN `reg_ip` varchar(255) NOT NULL DEFAULT '127.0.0.1' COMMENT '注册IP';
+        ALTER TABLE user MODIFY COLUMN `node_connector` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '同时可使用连接数';
+        ALTER TABLE user MODIFY COLUMN `is_admin` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否管理员';
+        ALTER TABLE user MODIFY COLUMN `im_type` smallint(6) unsigned NOT NULL DEFAULT 1 COMMENT '联系方式类型';
+        UPDATE user SET im_value = '' WHERE im_value IS NULL;
+        ALTER TABLE user MODIFY COLUMN `im_value` varchar(255) NOT NULL DEFAULT '' COMMENT '联系方式';
+        ALTER TABLE user MODIFY COLUMN `class` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '等级';
+        ALTER TABLE user MODIFY COLUMN `class_expire` datetime NOT NULL DEFAULT '1989-06-04 00:05:00' COMMENT '等级过期时间';
+        ALTER TABLE user MODIFY COLUMN `expire_in` datetime NOT NULL DEFAULT '2199-01-01 00:00:00' COMMENT '账户过期时间';
+        ALTER TABLE user MODIFY COLUMN `theme` varchar(255) NOT NULL DEFAULT 'tabler' COMMENT '网站主题';
+        ALTER TABLE user MODIFY COLUMN `ga_token` varchar(255) NOT NULL DEFAULT '' COMMENT 'GA密钥';
+        ALTER TABLE user MODIFY COLUMN `ga_enable` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT 'GA开关';
+        ALTER TABLE user MODIFY COLUMN `remark` text NOT NULL DEFAULT '' COMMENT '备注';
+        ALTER TABLE user MODIFY COLUMN `node_group` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '节点分组';
+        ALTER TABLE user MODIFY COLUMN `is_banned` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否封禁';
+        ALTER TABLE user MODIFY COLUMN `banned_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '封禁理由';
+        UPDATE user SET telegram_id = 0 WHERE telegram_id IS NULL;
+        ALTER TABLE user MODIFY COLUMN `telegram_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT 'Telegram ID';
+        ALTER TABLE user MODIFY COLUMN `expire_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '过期提醒';
+        ALTER TABLE user MODIFY COLUMN `traffic_notified` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '流量提醒';
+        ALTER TABLE user MODIFY COLUMN `forbidden_ip` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问IP';
+        ALTER TABLE user MODIFY COLUMN `forbidden_port` varchar(255) NOT NULL DEFAULT '' COMMENT '禁止访问端口';
+        ALTER TABLE user MODIFY COLUMN `auto_reset_day` smallint(6) unsigned NOT NULL DEFAULT 0 COMMENT '自动重置流量日';
+        ALTER TABLE user MODIFY COLUMN `auto_reset_bandwidth` decimal(12,2) unsigned NOT NULL DEFAULT 0.00 COMMENT '自动重置流量';
+        ALTER TABLE user MODIFY COLUMN `use_new_shop` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否启用新商店';
+        ALTER TABLE user MODIFY COLUMN `is_dark_mode` tinyint(1) NOT NULL DEFAULT 0;
+        ALTER TABLE user DROP KEY IF EXISTS `user_name`;
+        ALTER TABLE user ADD UNIQUE KEY `api_token` (`api_token`);
+        ALTER TABLE user ADD KEY IF NOT EXISTS `is_admin` (`is_admin`);
+        ALTER TABLE user ADD KEY IF NOT EXISTS `is_banned` (`is_banned`);
+        ALTER TABLE user CHANGE COLUMN IF EXISTS `sendDailyMail` `daily_mail_enable` tinyint(1) NOT NULL DEFAULT 0 COMMENT '每日报告开关';
+        ");
+
+        return 2023060300;
+    }
+
+    public function down(): int
+    {
+        DB::getPdo()->exec('ALTER TABLE user DROP COLUMN IF EXISTS `locale`;');
+
+        return 2023053000;
+    }
+};

+ 3 - 3
resources/views/tabler/user/edit.tpl

@@ -347,13 +347,13 @@
                                                     <h3 class="card-title">每日用量推送</h3>
                                                     <div class="mb-3">
                                                         <select id="daily-report" class="form-select">
-                                                            <option value="0" {if $user->sendDailyMail === 0}selected{/if}>
+                                                            <option value="0" {if $user->daily_mail_enable === 0}selected{/if}>
                                                                 不发送
                                                             </option>
-                                                            <option value="1" {if $user->sendDailyMail === 1}selected{/if}>
+                                                            <option value="1" {if $user->daily_mail_enable === 1}selected{/if}>
                                                                 邮件接收
                                                             </option>
-                                                            <option value="2" {if $user->sendDailyMail === 2}selected{/if}>
+                                                            <option value="2" {if $user->daily_mail_enable === 2}selected{/if}>
                                                                 Telegram Bot 接收
                                                             </option>
                                                         </select>

+ 5 - 6
src/Command/Tool.php

@@ -198,7 +198,7 @@ EOL;
     public function resetTraffic(): void
     {
         try {
-            ModelsUser::where('enable', 1)->update([
+            ModelsUser::where('is_banned', 0)->update([
                 'd' => 0,
                 'u' => 0,
                 'transfer_today' => 0,
@@ -285,8 +285,6 @@ EOL;
         }
 
         if (strtolower($y) === 'y') {
-            // create admin user
-            $configs = Setting::getClass('register');
             // do reg user
             $user = new ModelsUser();
             $user->user_name = 'Admin';
@@ -300,16 +298,17 @@ EOL;
             $user->t = 0;
             $user->u = 0;
             $user->d = 0;
-            $user->transfer_enable = Tools::toGB($configs['sign_up_for_free_traffic']);
-            $user->invite_num = $configs['sign_up_for_invitation_codes'];
+            $user->transfer_enable = 0;
+            $user->invite_num = 0;
             $user->ref_by = 0;
             $user->is_admin = 1;
-            $user->expire_in = date('Y-m-d H:i:s', time() + $configs['sign_up_for_free_time'] * 86400);
+            $user->expire_in = date('Y-m-d H:i:s');
             $user->reg_date = date('Y-m-d H:i:s');
             $user->money = 0;
             $user->im_type = 1;
             $user->im_value = '';
             $user->class = 0;
+            $user->node_iplimit = 0;
             $user->node_speedlimit = 0;
             $user->theme = $_ENV['theme'];
 

+ 1 - 1
src/Controllers/AuthController.php

@@ -267,7 +267,7 @@ final class AuthController extends BaseController
         $user->invite_num = $configs['sign_up_for_invitation_codes'];
         $user->auto_reset_day = Setting::obtain('free_user_reset_day');
         $user->auto_reset_bandwidth = Setting::obtain('free_user_reset_bandwidth');
-        $user->sendDailyMail = $configs['sign_up_for_daily_report'];
+        $user->daily_mail_enable = $configs['sign_up_for_daily_report'];
 
         if ($money > 0) {
             $user->money = $money;

+ 2 - 2
src/Controllers/LinkController.php

@@ -206,8 +206,8 @@ final class LinkController extends BaseController
                 $network = $node_custom_config['network'] ?? '';
                 $header = $node_custom_config['header'] ?? ['type' => 'none'];
                 $header_type = $header['type'] ?? '';
-                $host = $node_custom_config['host'] ?? '';
-                $path = $node_custom_config['path'] ?? '/';
+                $host = $node_custom_config['header']['request']['headers']['Host'][0] ?? $node_custom_config['host'] ?? '';
+                $path = $node_custom_config['header']['request']['path'][0] ?? $node_custom_config['path'] ?? '/';
 
                 $v2rayn_array = [
                     'v' => '2',

+ 4 - 4
src/Controllers/SubController.php

@@ -115,9 +115,9 @@ final class SubController extends BaseController
                     $network = $node_custom_config['network'] ?? '';
                     $header = $node_custom_config['header'] ?? ['type' => 'none'];
                     $header_type = $header['type'] ?? '';
-                    $host = $node_custom_config['host'] ?? '';
+                    $host = $node_custom_config['header']['request']['headers']['Host'][0] ?? $node_custom_config['host'] ?? '';
                     $servicename = $node_custom_config['servicename'] ?? '';
-                    $path = $node_custom_config['path'] ?? '/';
+                    $path = $node_custom_config['header']['request']['path'][0] ?? $node_custom_config['path'] ?? '/';
                     $tls = in_array($security, ['tls', 'xtls']) ? '1' : '0';
                     $enable_vless = $node_custom_config['enable_vless'] ?? '0';
                     $node = [
@@ -257,8 +257,8 @@ final class SubController extends BaseController
                     $alter_id = $node_custom_config['alter_id'] ?? '0';
                     $security = $node_custom_config['security'] ?? 'none';
                     $encryption = $node_custom_config['encryption'] ?? 'auto';
-                    $network = $node_custom_config['network'] ?? '';
-                    $host = $node_custom_config['host'] ?? '';
+                    $network = $node_custom_config['header']['type'] ?? $node_custom_config['network'] ?? '';
+                    $host = $node_custom_config['header']['request']['headers']['Host'][0] ?? $node_custom_config['host'] ?? '';
                     $allow_insecure = $node_custom_config['allow_insecure'] ?? false;
                     $tls = in_array($security, ['tls', 'xtls']);
                     // Clash 特定配置

+ 1 - 1
src/Controllers/UserController.php

@@ -393,7 +393,7 @@ final class UserController extends BaseController
             );
         }
 
-        $user->sendDailyMail = $value;
+        $user->daily_mail_enable = $value;
 
         if (! $user->save()) {
             return ResponseHelper::error($response, '修改失败');

+ 2 - 2
src/Models/User.php

@@ -48,7 +48,7 @@ final class User extends Model
         'port' => 'int',
         'is_admin' => 'boolean',
         'node_speedlimit' => 'float',
-        'sendDailyMail' => 'int',
+        'daily_mail_enable' => 'int',
         'ref_by' => 'int',
     ];
 
@@ -579,7 +579,7 @@ final class User extends Model
         $enable_traffic = $this->enableTraffic();
         $used_traffic = $this->usedTraffic();
         $unused_traffic = $this->unusedTraffic();
-        switch ($this->sendDailyMail) {
+        switch ($this->daily_mail_enable) {
             case 1:
                 echo 'Send daily mail to user: ' . $this->id;
                 $this->sendMail(

+ 1 - 1
src/Services/CronJob.php

@@ -572,7 +572,7 @@ final class CronJob
 
     public static function sendDailyTrafficReport(): void
     {
-        $users = User::where('sendDailyMail', 1)->get();
+        $users = User::where('daily_mail_enable', 1)->get();
 
         $ann_latest_raw = Ann::orderBy('date', 'desc')->first();
 

+ 3 - 3
src/Utils/Telegram/Callback.php

@@ -698,12 +698,12 @@ final class Callback
                 $OpEnd = end($Operate);
 
                 if ($OpEnd === 'update') {
-                    $this->User->sendDailyMail = ($this->User->sendDailyMail === 0 ? 1 : 0);
+                    $this->User->daily_mail_enable = ($this->User->daily_mail_enable === 0 ? 1 : 0);
 
                     if ($this->User->save()) {
                         $text = '设置更改成功,每日邮件接收当前设置为:';
                         $text .= '<strong>';
-                        $text .= ($this->User->sendDailyMail === 0 ? '不发送' : '发送');
+                        $text .= ($this->User->daily_mail_enable === 0 ? '不发送' : '发送');
                         $text .= '</strong>';
                     } else {
                         $text = '发生错误。';
@@ -711,7 +711,7 @@ final class Callback
                 } else {
                     $text = '每日邮件接收当前设置为:';
                     $text .= '<strong>';
-                    $text .= ($this->User->sendDailyMail === 0 ? '不发送' : '发送');
+                    $text .= ($this->User->daily_mail_enable === 0 ? '不发送' : '发送');
                     $text .= '</strong>';
                 }
 

+ 1 - 1
src/Utils/Telegram/TelegramTools.php

@@ -126,7 +126,7 @@ final class TelegramTools
         $useOptionMethodName = self::getUserActionOption()[$useOptionMethod][0];
         switch ($useOptionMethod) {
             // ##############
-            case 'enable':
+            case 'is_banned':
             case 'is_admin':
                 $strArray = [
                     '// 支持的写法',