浏览代码

feat: invoice type

M1Screw 1 年之前
父节点
当前提交
9b258bde74
共有 6 个文件被更改,包括 81 次插入65 次删除
  1. 4 4
      README.md
  2. 18 18
      composer.lock
  3. 12 9
      db/migrations/2023020100-init.php
  4. 38 0
      db/migrations/2024040500-add_invoice_type.php
  5. 0 34
      qodana.yaml
  6. 9 0
      src/Models/Invoice.php

+ 4 - 4
README.md

@@ -21,20 +21,20 @@
 
 ## TL;DR
 
-SSPanel UIM is a multi-purpose proxy service sales management system designed for Shadowsocks / V2Ray / Trojan / TUIC protocol.
+SSPanel UIM is a multi-purpose proxy service management system designed for Shadowsocks / V2Ray / Trojan / TUIC protocol.
 
 ## Features
 
 - Integrate multiple payment systems such as Alipay F2F, PayPal, Stripe, etc.
 - Support multiple mail services, built-in mail queue function, no third-party components are required to use
 - Built-in tabler theme based on Bootstrap 5, template engine support
-- Support Shadowsocks 2022, TUIC and other latest proxy protocols
+- Support Shadowsocks 2022, TUIC, and other latest proxy protocols
 - Universal subscription interface, one-click json/clash/sip008/sing-box format subscription distribution
 - Custom node configuration, modular subscription system, support multiple client-specific subscription formats
 - Refactored store system, support billing modes including but not limited to annual/monthly, pay-as-you-go, access type billing, etc.
 - Refactored scheduled task system, one command can automatically complete all scheduled tasks
-- Deep integration of large language models, support intelligent reply to ticket, document generation and other functions
-- One-click access to OpenAI, Google AI, Vertex AI, Hugging Face Hosted API, Cloudflare Workers AI and Anthropic and other large language model services
+- Deep integration of large language models, support intelligent replies to tickets, document generation, and other functions
+- One-click access to OpenAI, Google AI, Vertex AI, Hugging Face Hosted API, Cloudflare Workers AI, Anthropic, and other large language model services
 
 ## Installation
 

+ 18 - 18
composer.lock

@@ -622,16 +622,16 @@
         },
         {
             "name": "aws/aws-sdk-php",
-            "version": "3.303.2",
+            "version": "3.303.3",
             "source": {
                 "type": "git",
                 "url": "https://github.com/aws/aws-sdk-php.git",
-                "reference": "c087819351de027791d830ffc7f45195488ae988"
+                "reference": "3389ceccdc8e78d38bf60c6648d7da9768a86d9b"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/c087819351de027791d830ffc7f45195488ae988",
-                "reference": "c087819351de027791d830ffc7f45195488ae988",
+                "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3389ceccdc8e78d38bf60c6648d7da9768a86d9b",
+                "reference": "3389ceccdc8e78d38bf60c6648d7da9768a86d9b",
                 "shasum": ""
             },
             "require": {
@@ -711,9 +711,9 @@
             "support": {
                 "forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
                 "issues": "https://github.com/aws/aws-sdk-php/issues",
-                "source": "https://github.com/aws/aws-sdk-php/tree/3.303.2"
+                "source": "https://github.com/aws/aws-sdk-php/tree/3.303.3"
             },
-            "time": "2024-04-03T18:08:21+00:00"
+            "time": "2024-04-04T18:11:56+00:00"
         },
         {
             "name": "bacon/bacon-qr-code",
@@ -5034,16 +5034,16 @@
         },
         {
             "name": "stripe/stripe-php",
-            "version": "v13.16.0",
+            "version": "v13.17.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/stripe/stripe-php.git",
-                "reference": "b122efcf4ee02256e4a9ae60783cbf1c3f702503"
+                "reference": "24d3d9ed8406e10d24452af44597300173655f69"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/stripe/stripe-php/zipball/b122efcf4ee02256e4a9ae60783cbf1c3f702503",
-                "reference": "b122efcf4ee02256e4a9ae60783cbf1c3f702503",
+                "url": "https://api.github.com/repos/stripe/stripe-php/zipball/24d3d9ed8406e10d24452af44597300173655f69",
+                "reference": "24d3d9ed8406e10d24452af44597300173655f69",
                 "shasum": ""
             },
             "require": {
@@ -5087,9 +5087,9 @@
             ],
             "support": {
                 "issues": "https://github.com/stripe/stripe-php/issues",
-                "source": "https://github.com/stripe/stripe-php/tree/v13.16.0"
+                "source": "https://github.com/stripe/stripe-php/tree/v13.17.0"
             },
-            "time": "2024-03-28T19:17:08+00:00"
+            "time": "2024-04-04T22:16:10+00:00"
         },
         {
             "name": "symfony/clock",
@@ -8283,16 +8283,16 @@
         },
         {
             "name": "phpunit/phpunit",
-            "version": "10.5.16",
+            "version": "10.5.17",
             "source": {
                 "type": "git",
                 "url": "https://github.com/sebastianbergmann/phpunit.git",
-                "reference": "18f8d4a5f52b61fdd9370aaae3167daa0eeb69cd"
+                "reference": "c1f736a473d21957ead7e94fcc029f571895abf5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/18f8d4a5f52b61fdd9370aaae3167daa0eeb69cd",
-                "reference": "18f8d4a5f52b61fdd9370aaae3167daa0eeb69cd",
+                "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/c1f736a473d21957ead7e94fcc029f571895abf5",
+                "reference": "c1f736a473d21957ead7e94fcc029f571895abf5",
                 "shasum": ""
             },
             "require": {
@@ -8364,7 +8364,7 @@
             "support": {
                 "issues": "https://github.com/sebastianbergmann/phpunit/issues",
                 "security": "https://github.com/sebastianbergmann/phpunit/security/policy",
-                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.16"
+                "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.17"
             },
             "funding": [
                 {
@@ -8380,7 +8380,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-03-28T10:08:10+00:00"
+            "time": "2024-04-05T04:39:01+00:00"
         },
         {
             "name": "psr/cache",

+ 12 - 9
db/migrations/2023020100-init.php

@@ -108,16 +108,18 @@ return new class() implements MigrationInterface {
 
             CREATE TABLE `invoice` (
                 `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT '账单ID',
-                `user_id` bigint(20) unsigned DEFAULT 0 COMMENT '归属用户ID',
-                `order_id` bigint(20) unsigned DEFAULT 0 COMMENT '订单ID',
-                `content` longtext DEFAULT '{}' COMMENT '账单内容' CHECK (json_valid(`content`)),
-                `price` double unsigned DEFAULT 0 COMMENT '账单金额',
-                `status` varchar(255) DEFAULT '' COMMENT '账单状态',
-                `create_time` int(11) unsigned DEFAULT 0 COMMENT '创建时间',
-                `update_time` int(11) unsigned DEFAULT 0 COMMENT '更新时间',
-                `pay_time` int(11) unsigned DEFAULT 0 COMMENT '支付时间',
+                `type` varchar(255) NOT NULL DEFAULT 'product' COMMENT '类型',
+                `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '归属用户ID',
+                `order_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '订单ID',
+                `content` longtext NOT NULL DEFAULT '{}' COMMENT '账单内容' CHECK (json_valid(`content`)),
+                `price` double unsigned NOT NULL DEFAULT 0 COMMENT '账单金额',
+                `status` varchar(255) NOT NULL DEFAULT '' COMMENT '账单状态',
+                `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间',
+                `update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间',
+                `pay_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '支付时间',
                 PRIMARY KEY (`id`),
                 KEY `id` (`id`),
+                KEY `type` (`type`),
                 KEY `user_id` (`user_id`),
                 KEY `order_id` (`order_id`),
                 KEY `status` (`status`)
@@ -150,7 +152,7 @@ return new class() implements MigrationInterface {
                 `server` varchar(255) NOT NULL DEFAULT '' COMMENT '节点地址',
                 `custom_config` longtext NOT NULL DEFAULT '{}' COMMENT '自定义配置' CHECK (json_valid(`custom_config`)),
                 `sort` tinyint(2) unsigned NOT NULL DEFAULT 14 COMMENT '节点类型',
-                `traffic_rate` float unsigned NOT NULL DEFAULT 1 COMMENT '流量倍率',
+                `traffic_rate` double unsigned NOT NULL DEFAULT 1 COMMENT '流量倍率',
                 `is_dynamic_rate` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '是否启用动态流量倍率',
                 `dynamic_rate_type` tinyint(1) unsigned NOT NULL DEFAULT 0 COMMENT '动态流量倍率计算方式',
                 `dynamic_rate_config` longtext NOT NULL DEFAULT '{}' COMMENT '动态流量倍率配置' CHECK (json_valid(`custom_config`)),
@@ -207,6 +209,7 @@ return new class() implements MigrationInterface {
                 KEY `id` (`id`),
                 KEY `user_id` (`user_id`),
                 KEY `product_id` (`product_id`),
+                KEY `product_type` (`product_type`),
                 KEY `status` (`status`)
             ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
 

+ 38 - 0
db/migrations/2024040500-add_invoice_type.php

@@ -0,0 +1,38 @@
+<?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 invoice ADD COLUMN IF NOT EXISTS `type` varchar(255) NOT NULL DEFAULT 'product' COMMENT '类型';
+            ALTER TABLE invoice ADD KEY IF NOT EXISTS `type` (`type`);
+            ALTER TABLE invoice MODIFY COLUMN `user_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '归属用户ID';
+            ALTER TABLE invoice MODIFY COLUMN `order_id` bigint(20) unsigned NOT NULL DEFAULT 0 COMMENT '订单ID';
+            ALTER TABLE invoice MODIFY COLUMN `content` longtext NOT NULL DEFAULT '{}' COMMENT '账单内容' CHECK (json_valid(`content`));
+            ALTER TABLE invoice MODIFY COLUMN `price` double unsigned NOT NULL DEFAULT 0 COMMENT '账单金额';
+            ALTER TABLE invoice MODIFY COLUMN `status` varchar(255) NOT NULL DEFAULT '' COMMENT '账单状态';
+            ALTER TABLE invoice MODIFY COLUMN `create_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '创建时间';
+            ALTER TABLE invoice MODIFY COLUMN `update_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '更新时间';
+            ALTER TABLE invoice MODIFY COLUMN `pay_time` int(11) unsigned NOT NULL DEFAULT 0 COMMENT '支付时间';
+            ALTER TABLE `order` ADD KEY IF NOT EXISTS `product_type` (`product_type`);
+            ALTER TABLE node MODIFY COLUMN `traffic_rate` double unsigned NOT NULL DEFAULT 1 COMMENT '流量倍率';
+        ");
+
+        return 2024040500;
+    }
+
+    public function down(): int
+    {
+        DB::getPdo()->exec('
+            ALTER TABLE invoice DROP COLUMN IF EXISTS `type`;
+            ALTER TABLE invoice DROP KEY IF EXISTS `type`;
+        ');
+
+        return 2024031700;
+    }
+};

+ 0 - 34
qodana.yaml

@@ -1,34 +0,0 @@
-#-------------------------------------------------------------------------------#
-#               Qodana analysis is configured by qodana.yaml file               #
-#             https://www.jetbrains.com/help/qodana/qodana-yaml.html            #
-#-------------------------------------------------------------------------------#
-version: "1.0"
-
-#Specify inspection profile for code analysis
-profile:
-  name: qodana.starter
-
-#Enable inspections
-#include:
-#  - name: <SomeEnabledInspectionId>
-
-#Disable inspections
-#exclude:
-#  - name: <SomeDisabledInspectionId>
-#    paths:
-#      - <path/where/not/run/inspection>
-
-php:
-  version: 8.2 #(Applied in CI/CD pipeline)
-
-#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
-#bootstrap: sh ./prepare-qodana.sh
-
-#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
-#plugins:
-#  - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
-
-#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
-linter: jetbrains/qodana-php:latest
-include:
-  - name: CheckDependencyLicenses

+ 9 - 0
src/Models/Invoice.php

@@ -44,6 +44,15 @@ final class Invoice extends Model
         };
     }
 
+    public function type(): string
+    {
+        return match ($this->type) {
+            'product' => '商品',
+            'topup' => '充值',
+            default => '未知',
+        };
+    }
+
     public function refundToBalance(): void
     {
         if (in_array($this->status, ['paid_gateway', 'paid_balance', 'paid_admin'])) {