shanshanzhong147 7236ca4cf2
Build docker and publish / build (20.15.1) (push) Has been cancelled
Build docker and publish / build (20.15.1) (pull_request) Has been cancelled
修复(#128): 按规则类型决定促销资格,让 InactiveUser/Campaign 对老用户生效
此前 calculatePurchasePrice 把 allowPromo 绑死在 orderType == 1,导致只要用户
有任何过往付费订阅(含已过期),就会被 paidSubscriptionQuery 路由为续费
(orderType=2),跳过所有促销评估。后果:

  - InactiveUser 召回促销永远无法触发(其目标人群恰好就是有过期订阅的用户)
  - Campaign 全员活动对老用户 / 升级加购场景完全失效
  - 套餐列表(loadSubscribePromoMap)直接调 EvaluatePromo 不感知 orderType,
    可能显示促销价但下单时却拿到原价

修复方式:把 isFirstPurchase 下放给 EvaluatePromo,由规则类型决定 gating:

  - NewUser    要求 isFirstPurchase=true(保留首购语义)
  - InactiveUser 由规则自身的"上次订阅过期 N 月以上"条件判定
  - Campaign   时间窗内对任意用户生效

新增 common.HasPaidSubscription 助手,套餐列表与下单走同一份 isFirstPurchase
判定,确保展示价与实际下单价口径一致。

测试:补充 EvaluatePromo / calculatePurchasePrice 的 NewUser 屏蔽 + Campaign
放开用例;更新 loadSubscribePromoMap 测试覆盖新增 HasPaidSubscription 查询。

注:renewalLogic.go 仍未接入促销(属于方向 B 的彻底统一,本次未涵盖)。
2026-05-31 19:00:30 -07:00
x
2026-05-16 23:58:53 -07:00
x
2026-05-26 09:14:59 -07:00
2026-03-06 21:58:29 -08:00
x
2026-05-08 06:19:59 -07:00
2026-04-29 12:49:45 -07:00
x
2026-05-14 05:50:44 -07:00
x
2026-05-06 02:34:43 -07:00
x
2026-05-06 02:34:43 -07:00
x
2026-05-08 06:19:59 -07:00
x
2026-05-26 09:14:59 -07:00
2026-04-28 17:44:28 -07:00
2025-04-25 12:08:29 +09:00
2025-04-25 12:08:29 +09:00
2025-04-25 12:08:29 +09:00
x
2026-05-03 18:34:14 -07:00
2025-04-25 12:08:29 +09:00
2025-04-25 12:08:29 +09:00
2025-04-25 12:08:29 +09:00
2025-04-25 16:40:57 +09:00
2026-03-08 07:31:11 -07:00
2026-03-03 17:29:45 -08:00
2026-03-03 17:29:45 -08:00
x
2026-05-15 09:53:15 -07:00

PPanel Server

License Go Version Go Report Card Docker CI/CD

PPanel is a pure, professional, and perfect open-source proxy panel tool, designed for learning and practical use.

English | 中文 | Report Bug | Request Feature

Article 1.
All human beings are born free and equal in dignity and rights.
They are endowed with reason and conscience and should act towards one another in a spirit of brotherhood.

Article 12.
No one shall be subjected to arbitrary interference with his privacy, family, home or correspondence, nor to attacks upon his honour and reputation.
Everyone has the right to the protection of the law against such interference or attacks.

Article 19.
Everyone has the right to freedom of opinion and expression; this right includes freedom to hold opinions without interference and to seek, receive and impart information and ideas through any media and regardless of frontiers.

Source: United Nations Universal Declaration of Human Rights (UN.org)

📋 Overview

PPanel Server is the backend component of the PPanel project, providing robust APIs and core functionality for managing proxy services. Built with Go, it emphasizes performance, security, and scalability.

Key Features

  • Multi-Protocol Support: Supports Shadowsocks, V2Ray, Trojan, and more.
  • Privacy First: No user logs are collected, ensuring privacy and security.
  • Minimalist Design: Simple yet powerful, with complete business logic.
  • User Management: Full authentication and authorization system.
  • Subscription System: Manage user subscriptions and service provisioning.
  • Payment Integration: Supports multiple payment gateways.
  • Order Management: Track and process user orders.
  • Ticket System: Built-in customer support and issue tracking.
  • Node Management: Monitor and control server nodes.
  • API Framework: Comprehensive RESTful APIs for frontend integration.

Subscription Mode Behavior

The subscription behavior can be switched by the backend config Subscribe.SingleModel:

  • false (multi-subscription mode): each successful purchase creates a new user_subscribe record.
  • true (single-subscription mode): purchase is auto-routed to renewal semantics when the user already has a paid subscription:
    • a new order is still created,
    • but the existing subscription is extended (instead of creating another user_subscribe).

🚀 Quick Start

Prerequisites

  • Go: 1.21 or higher
  • Docker: Optional, for containerized deployment
  • Git: For cloning the repository

Installation from Source

  1. Clone the repository:

    git clone https://github.com/perfect-panel/ppanel-server.git
    cd ppanel-server
    
  2. Install dependencies:

    go mod download
    
  3. Generate code:

    chmod +x script/generate.sh
    ./script/generate.sh
    
  4. Build the project:

    make linux-amd64
    
  5. Run the server:

    ./ppanel-server-linux-amd64 run --config etc/ppanel.yaml
    

🐳 Docker Deployment

  1. Build the Docker image:

    docker buildx build --platform linux/amd64 -t ppanel-server:latest .
    
  2. Run the container:

    docker run --rm -p 8080:8080 -v $(pwd)/etc:/app/etc ppanel-server:latest
    
  3. Use Docker Compose (create docker-compose.yml):

    version: '3.8'
    services:
      ppanel-server:
        image: ppanel-server:latest
        ports:
          - "8080:8080"
        volumes:
          - ./etc:/app/etc
        environment:
          - TZ=Asia/Shanghai
    

    Run:

    docker-compose up -d
    
  4. Pull from Docker Hub (after CI/CD publishes):

    docker pull ppanel/ppanel-server:latest
    docker run --rm -p 8080:8080 ppanel/ppanel-server:latest
    

📖 API Documentation

Explore the full API documentation:

The documentation covers all endpoints, request/response formats, and authentication details.

Project Description Link
PPanel Web Frontend for PPanel GitHub
PPanel User Web User interface for PPanel Preview
PPanel Admin Web Admin interface for PPanel Preview

🌐 Official Website

Visit ppanel.dev for more details.

🏛 Architecture

Architecture Diagram

📁 Directory Structure

.
├── apis/             # API definition files
├── cmd/              # Application entry point
├── doc/              # Documentation
├── etc/              # Configuration files (e.g., ppanel.yaml)
├── generate/         # Code generation tools
├── initialize/       # System initialization
├── internal/         # Internal modules
│   ├── config/       # Configuration parsing
│   ├── handler/      # HTTP handlers
│   ├── middleware/   # HTTP middleware
│   ├── logic/        # Business logic
│   ├── model/        # Data models
│   ├── svc/          # Service layer
│   └── types/        # Type definitions
├── pkg/              # Utility code
├── queue/            # Queue services
├── scheduler/        # Scheduled tasks
├── script/           # Build scripts
├── go.mod            # Go module definition
├── Makefile          # Build automation
└── Dockerfile        # Docker configuration

💻 Development

Format API Files

goctl api format --dir apis/user.api

Add a New API

  1. Create a new API file in apis/.
  2. Import it in apis/ppanel.api.
  3. Regenerate code:
    ./script/generate.sh
    

Build for Multiple Platforms

Use the Makefile to build for various platforms (e.g., Linux, Windows, macOS):

make all  # Builds linux-amd64, darwin-amd64, windows-amd64
make linux-arm64  # Build for specific platform

Supported platforms include:

  • Linux: 386, amd64, arm64, armv5-v7, mips, riscv64, loong64, etc.
  • Windows: 386, amd64, arm64, armv7
  • macOS: amd64, arm64
  • FreeBSD: amd64, arm64

🤝 Contributing

Contributions are welcome! Please follow the Contribution Guidelines for bug fixes, features, or documentation improvements.

Special Thanks

A huge thank you to the following outstanding open-source projects that have provided invaluable support for this project's development! 🚀

Project Description Project Description
Gin
Gin
Gin Stars
High-performance Go Web framework
Gorm
Gorm
Gorm Stars
Powerful Go ORM framework
Asynq
Asynq
Asynq Stars
Asynchronous task queue for Go
Go-Swagger
Go-Swagger
Go-Swagger Stars
Comprehensive Go Swagger toolkit
Go-Zero
Go-Zero
Go-Zero Stars
Go microservices framework (this project's API generator is built on Go-Zero)

🎉 Salute to Open Source: Thank you to the open-source community for making development simpler and more efficient! Please give these projects a to support the open-source movement!

📄 License

This project is licensed under the GPL-3.0 License.

S
Description
No description provided
Readme GPL-3.0 291 MiB
Languages
Go 95.5%
PLpgSQL 2.8%
HTML 1.5%