فهرست منبع

feat: user money log

M1Screw 2 سال پیش
والد
کامیت
4df9e440c7

+ 15 - 3
db/migrations/2023020100-init.php

@@ -327,7 +327,7 @@ return new class() implements MigrationInterface {
                 `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 'rc4-md5' COMMENT 'Shadowsocks加密方式',
+                `method` varchar(255) DEFAULT 'aes-128-gcm' COMMENT 'Shadowsocks加密方式',
                 `reg_ip` varchar(255) 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数',
@@ -339,7 +339,7 @@ return new class() implements MigrationInterface {
                 `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 '2099-06-04 00:05:00',
+                `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,
@@ -392,11 +392,23 @@ return new class() implements MigrationInterface {
                 `code` varchar(255) DEFAULT NULL,
                 `user_id` bigint(20) unsigned DEFAULT NULL,
                 `created_at` timestamp NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
-                `updated_at` timestamp NULL DEFAULT '2016-05-31 15:00:00',
+                `updated_at` timestamp NULL DEFAULT '1989-06-04 00:05:00',
                 PRIMARY KEY (`id`),
                 UNIQUE KEY `code` (`code`),
                 UNIQUE KEY `user_id` (`user_id`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
+            
+            CREATE TABLE `user_money_log` (
+                `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+                `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
+                `before` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动前账户余额',
+                `after` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动后账户余额',
+                `amount` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变动总额',
+                `remark` text NOT NULL DEFAULT '' COMMENT '备注',
+                `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
+                PRIMARY KEY (`id`),
+                KEY `user_id` (`user_id`)
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 
             CREATE TABLE `user_password_reset` (
                 `id` int(11) NOT NULL AUTO_INCREMENT,

+ 32 - 0
db/migrations/2023031700-add_user_money_log.php

@@ -0,0 +1,32 @@
+<?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("CREATE TABLE IF NOT EXISTS `user_money_log` (
+                `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+                `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '用户ID',
+                `before` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动前账户余额',
+                `after` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '用户变动后账户余额',
+                `amount` decimal(10,2) NOT NULL DEFAULT 0 COMMENT '变动总额',
+                `remark` text NOT NULL DEFAULT '' COMMENT '备注',
+                `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
+                PRIMARY KEY (`id`),
+                KEY `user_id` (`user_id`)
+            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;");
+
+        return 2023031700;
+    }
+
+    public function down(): int
+    {
+        DB::getPdo()->exec('DROP TABLE IF EXISTS `user_money_log`;');
+
+        return 2023030500;
+    }
+};

+ 0 - 2
src/Controllers/SubController.php

@@ -105,7 +105,6 @@ final class SubController extends BaseController
 
         foreach ($nodes_raw as $node_raw) {
             $node_custom_config = json_decode($node_raw->custom_config, true);
-            $node = [];
             //檢查是否配置“前端/订阅中下发的服务器地址”
             if (! array_key_exists('server_user', $node_custom_config)) {
                 $server = $node_raw->server;
@@ -239,7 +238,6 @@ final class SubController extends BaseController
 
         foreach ($nodes_raw as $node_raw) {
             $node_custom_config = json_decode($node_raw->custom_config, true);
-            $node = [];
             //檢查是否配置“前端/订阅中下发的服务器地址”
             if (! array_key_exists('server_user', $node_custom_config)) {
                 $server = $node_raw->server;

+ 11 - 0
src/Models/UserMoneyLog.php

@@ -0,0 +1,11 @@
+<?php
+
+declare(strict_types=1);
+
+namespace App\Models;
+
+final class UserMoneyLog extends Model
+{
+    protected $connection = 'default';
+    protected $table = 'user_money_log';
+}

+ 0 - 1
src/Services/Gateway/Epay.php

@@ -103,7 +103,6 @@ final class Epay extends AbstractPayment
             $out_trade_no = $_GET['out_trade_no'];
             $type = $_GET['type'];
             $type = match ($type) {
-                'alipay' => 'Alipay',
                 'qqpay' => 'QQ',
                 'wxpay' => 'WeChat',
                 'epusdt' => 'USDT',

+ 19 - 93
src/Utils/Telegram/Callbacks/Callback.php

@@ -883,99 +883,25 @@ final class Callback
 
             $UniversalSub_Url = SubController::getUniversalSub($this->User);
             $TraditionalSub_Url = LinkController::getTraditionalSub($this->User);
-            switch ($CallbackDataExplode[1]) {
-                case 'clash':
-                    $text = 'Clash 通用订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $UniversalSub_Url . '/clash</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                case 'json':
-                    $text = 'Json 通用订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $UniversalSub_Url . '/json</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                case 'ss':
-                    $text = 'Shadowsocks 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?ss=1</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                case 'sip002':
-                    $text = 'Shadowsocks SIP002 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?sip002=1</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                case 'v2':
-                    $text = 'V2Ray 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?v2ray=1</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                case 'trojan':
-                    $text = 'Trojan 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?trojan=1</code>' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-                default:
-                    $text = '未知参数' . PHP_EOL . PHP_EOL;
-                    $sendMessage = [
-                        'text' => $text,
-                        'disable_web_page_preview' => true,
-                        'reply_to_message_id' => null,
-                        'reply_markup' => json_encode(
-                            [
-                                'inline_keyboard' => $temp['keyboard'],
-                            ]
-                        ),
-                    ];
-                    break;
-            }
+            $text = match ($CallbackDataExplode[1]) {
+                'clash' => 'Clash 通用订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $UniversalSub_Url . '/clash</code>' . PHP_EOL . PHP_EOL,
+                'json' => 'Json 通用订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $UniversalSub_Url . '/json</code>' . PHP_EOL . PHP_EOL,
+                'ss' => 'Shadowsocks 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?ss=1</code>' . PHP_EOL . PHP_EOL,
+                'sip002' => 'Shadowsocks SIP002 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?sip002=1</code>' . PHP_EOL . PHP_EOL,
+                'v2' => 'V2Ray 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?v2ray=1</code>' . PHP_EOL . PHP_EOL,
+                'trojan' => 'Trojan 传统订阅地址:' . PHP_EOL . PHP_EOL . '<code>' . $TraditionalSub_Url . '?trojan=1</code>' . PHP_EOL . PHP_EOL,
+                default => '未知参数' . PHP_EOL . PHP_EOL,
+            };
+            $sendMessage = [
+                'text' => $text,
+                'disable_web_page_preview' => true,
+                'reply_to_message_id' => null,
+                'reply_markup' => json_encode(
+                    [
+                        'inline_keyboard' => $temp['keyboard'],
+                    ]
+                ),
+            ];
         } else {
             $temp = $this->getUserSubscribeKeyboard();
             $sendMessage = [

+ 1 - 1
src/Utils/Tools.php

@@ -390,7 +390,7 @@ final class Tools
         $number = match ($req) {
             'today' => Paylist::where('status', 1)->whereBetween('datetime', [$today, time()])->sum('total'),
             'yesterday' => Paylist::where('status', 1)->whereBetween('datetime', [strtotime('-1 day', $today), $today])->sum('total'),
-            'this month' => Paylist::where('status', 1)->whereBetween('datetime', [strtotime('first day of this month'), $today])->sum('total'),
+            'this month' => Paylist::where('status', 1)->whereBetween('datetime', [strtotime('first day of this month 00:00:00'), $today])->sum('total'),
             default => Paylist::where('status', 1)->sum('total'),
         };
         return is_null($number) ? 0.00 : round(floatval($number), 2);