125 Commits

Author SHA1 Message Date
ea34718a0b fix: 设备变更时同步清除用户缓存,修复 user_devices 为空问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m23s
Device.GetCacheKeys() 新增 cacheUserIdPrefix+UserId,
确保 InsertDevice/UpdateDevice/DeleteDevice 时同时失效
cache:user:id:{userId},避免下次 FindOne 读到不含
UserDevices 的旧缓存。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 05:46:48 -07:00
abc9864d46 fix: 单订阅模式下避免重复创建订阅
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m31s
1. FindSingleModeAnchorSubscribe 补充 status=4(流量耗完)到查询范围,
   避免流量耗尽的订阅被忽略导致续费时新建订阅

2. activateOrderLogic NewPurchase 路径去掉套餐ID匹配检查,
   单订阅模式下无论购买何种套餐都更新现有订阅而非新建

3. singleModeHelper fallback 查询同步补充 status=4

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 05:13:00 -07:00
0f28f4995f fix: 修复在线设备列表无数据问题
user_device 表的 subscribe_id 字段从未在插入时写入(始终为 NULL),
导致 QueryDevicePageList 的 WHERE 条件 `subscribe_id = ?` 永远匹配不到记录。
移除 subscribe_id 过滤,改为只按 user_id 查询。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-28 18:23:18 -07:00
507ee16a30 x
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m20s
2026-03-28 09:06:24 -07:00
2bdda7558c fix: JSON_CONTAINS node_group_ids 参数需用引号包裹
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m25s
JSON_CONTAINS 第二参数必须是 JSON 字符串,裸数字会报 Error 3146。
修复:%d → '%d'

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-27 07:22:39 -07:00
f111b36389 fix: JSON_CONTAINS 参数类型修复 + API sync
- 修复 JSON_CONTAINS(node_group_ids, int64) 类型错误,改为传 JSON 字符串
- 添加 node_group_ids IS NOT NULL 兼容判断,防止 NULL 列报错
- 同步 apis/ 及 routes.go、compat_types.go 改动

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-23 06:58:28 -07:00
f703b5089a 分组概念
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m58s
2026-03-19 03:21:47 -07:00
e5e9f93f68 Merge remote-tracking branch 'origin/master' into internal 2026-03-19 01:55:01 -07:00
dcdbabdb13 注销
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m34s
2026-03-17 07:12:42 -07:00
1d2f2a594a feat: 增强用户搜索功能,支持通过设备ID哈希进行查找。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m42s
2026-03-15 22:02:23 -07:00
EUForest
06a2425474 feat(subscribe): add traffic limit rules and user traffic stats
- Add subscribe traffic_limit schema and migration\n- Support traffic_limit in admin create/update and list/details\n- Apply traffic_limit when building server user list speed limits\n- Add public user traffic stats API
2026-03-14 12:41:52 +08:00
9b6efe2901 DefaultFamilyMaxSize
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m32s
2026-03-12 01:41:39 -07:00
7c2eddf9c3 feat: 为订单表添加 app_account_token 字段并增强 Apple IAP 对账逻辑,支持通过交易历史记录查找。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m25s
2026-03-10 20:47:24 -07:00
26f6400e74 feat: 苹果支付uuid 及设备逻辑
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m3s
2026-03-10 19:53:19 -07:00
5f884ed737 fix: 修复 读写不一致 appleiap 的问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m39s
2026-03-09 05:17:26 -07:00
130fb702ab fix: IAP 支付流程优化与关键 bug 修复
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m42s
- getStatusLogic 类型断言修复(*user.User)
- restoreLogic 事务拆分为单条处理 + appAccountToken 解析
- attachTransactionLogic 提取 ParseProductIdDuration 共享函数
- 新增 config_helper.go 统一 Apple API 配置加载
- reconcileLogic 补充 BundleID 配置读取
- activateOrderLogic 邀请赠送天数逻辑完善

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-09 00:27:16 -07:00
dcfcd036de x
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m46s
2026-03-08 22:37:58 -07:00
79a97ec569 限制套餐具体到 档位
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m45s
2026-03-08 21:25:07 -07:00
EUForest
fae8787ff4 Merge branch 'master' of https://github.com/OmnTeam/ppanel-server 2026-03-08 23:24:05 +08:00
EUForest
39310d5b9a Features:
- Node group CRUD operations with traffic-based filtering
  - Three grouping modes: average distribution, subscription-based, and traffic-based
  - Automatic and manual group recalculation with history tracking
  - Group assignment preview before applying changes
  - User subscription group locking to prevent automatic reassignment
  - Subscribe-to-group mapping configuration
  - Group calculation history and detailed reports
  - System configuration for group management (enabled/mode/auto_create)

  Database:
  - Add node_group table for group definitions
  - Add group_history and group_history_detail tables for tracking
  - Add node_group_ids (JSON) to nodes and subscribe tables
  - Add node_group_id and group_locked fields to user_subscribe table
  - Add migration files for schema changes
2026-03-08 23:22:38 +08:00
69028898a4 搜索
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m52s
2026-03-08 08:05:26 -07:00
7a3a53f1a9 ipa
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m47s
2026-03-08 05:12:28 -07:00
4d913c1728 修复缓存
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m26s
2026-03-06 21:58:29 -08:00
7308aa9191 无订阅 支付后出现两个订阅
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 7m37s
2026-03-05 21:53:36 -08:00
EUForest
e215ffcae9 fix(subscribe): invalidate user subscription cache when plan is updated
When administrators update subscription plan configurations (traffic limits,
nodes, speed limits, etc.), existing subscribers were not seeing the updated
settings immediately. This was caused by stale cache entries that were not
being invalidated.

The issue occurred because:
- User subscription queries cache the entire result including preloaded plan details
- Plan update/delete operations only cleared the plan's own cache keys
- User subscription cache keys (cache:user:subscribe:user:{userId}) remained stale

This fix ensures that when a subscription plan is updated or deleted, all
associated user subscription caches are properly invalidated by:
- Querying all active users subscribed to the plan
- Building cache keys for each affected user
- Clearing both plan and user subscription caches atomically

Users will now immediately see updated plan configurations without waiting
for cache expiration.
2026-03-06 13:26:31 +08:00
70c0483ca9 修复订阅
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 8m2s
2026-03-04 23:08:46 -08:00
4752f844ef 各种配置项修复,优化到后台管理端配置
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
2026-03-04 17:58:40 -08:00
a01570b59d fix gitea workflow path and runner label
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 8m21s
2026-03-04 06:33:14 -08:00
b0eb6595ac add: 新增ci diamanté 2026-03-03 17:29:45 -08:00
4d8516b2e1 同步历史版本代码 2026-03-03 09:32:22 -08:00
EUForest
34372fe0b3 fix(redemption): enhance redemption code flow with transaction safety and idempotency
This commit addresses critical issues in the redemption code activation flow
to ensure data consistency, prevent duplicate redemptions, and improve user
experience.

Key improvements:

1. Transaction Safety (P0)
   - Wrap subscription creation, used count update, and record insertion in
     a single database transaction
   - Ensure atomicity: all operations succeed or all rollback
   - Prevent orphaned records and data inconsistencies

2. Idempotency Protection (P0)
   - Add redemption record check before processing to prevent duplicate
     operations on queue task retries
   - Maintain idempotency at multiple layers: interface, order, and record

3. Distributed Lock (P1)
   - Implement Redis-based distributed lock (10s timeout) to prevent
     concurrent duplicate redemptions
   - Lock key format: redemption_lock:{user_id}:{code}

4. IsNew Field Correction (P2)
   - Fix IsNew field to correctly determine first-time purchases using
     IsUserEligibleForNewOrder method
   - Ensure accurate statistics and future commission calculations

5. Quota Pre-check (P2)
   - Add quota validation at interface layer for immediate user feedback
   - Prevent "processing" status followed by eventual failure

6. Extended Cache TTL (P2)
   - Increase Redis cache expiration from 30 minutes to 2 hours
   - Ensure queue tasks can retrieve redemption data even with delays

7. Error Handling (P2)
   - Clean up Order records when Redis cache or queue enqueue fails
   - Prevent orphaned Order records in the database

8. Cache Clearing Optimization
   - Add user subscription cache clearing after activation
   - Ensure both node-side and user-side display latest subscription info

Technical details:
- Modified: internal/logic/public/redemption/redeemCodeLogic.go
- Modified: queue/logic/order/activateOrderLogic.go
- Modified: internal/model/redemption/default.go (transaction support)

Testing:
- All changes compiled successfully
- Comprehensive flow verification completed
- Ready for production deployment

BREAKING CHANGE: None
2026-02-09 01:07:39 +08:00
EUForest
ffe589ff77 feat: Device short code lookup 2026-01-31 11:52:09 +08:00
EUForest
3359704a45 feat: add short_code field to device login API
- Add optional short_code parameter to DeviceLoginRequest
- Add ShortCode field to Device model
- Save short_code to database during device registration
- Add database migration for user_device.short_code column
- Fix duplicate variable declaration in routes.go
2026-01-10 18:11:24 +08:00
EUForest
f452838c63 Merge upstream/master into develop 2026-01-06 18:52:28 +08:00
EUForest
ec0a0f968e up: Redemption Code 2026-01-06 16:15:24 +08:00
EUForest
518595b058 feat: Redemption Code 2026-01-05 17:53:31 +08:00
EUForest
80ee9a6acf Merge upstream/master into develop
Sync upstream changes from perfect-panel/server

  Includes updates from v1.0.1 to v1.2.5:
  - Currency configuration support
  - Subscribe improvements (short token, inventory check, etc.)
  - Node management enhancements
  - Database migrations
  - Bug fixes and optimizations
2026-01-02 12:51:55 +08:00
Tension
577490749c feat(subscribe): update inventory logic in subscribe table and add migration scripts 2025-12-29 13:29:12 +08:00
Tension
d332e760f8 feat(subscribe): add ShowOriginalPrice field and related database changes 2025-12-28 17:08:26 +08:00
Tension
31e634ba66 feat(user): add handlers and logic for resetting user subscribe token and traffic 2025-12-28 16:49:28 +08:00
Chang lue Tsen
67f16ead82 feat(user): add unscoped filter to include soft-deleted records in user queries 2025-12-27 10:57:34 -05:00
Chang lue Tsen
a9c832cb7c feat(user): implement soft deletion for user accounts and update related logic 2025-12-27 10:45:28 -05:00
Chang lue Tsen
ec510b66fb refactor(server): remove deprecated server types and related methods for cleaner codebase 2025-12-23 07:48:03 -05:00
EUForest
76ff9a658d Merge branch perfect-panel/master/server into develop 2025-12-11 23:53:32 +08:00
Tension
143445a2fc feat(commission): implement commission withdrawal logic and logging 2025-11-29 14:33:05 +08:00
Chang lue Tsen
7277438b07 feat(user): add commission withdrawal and query withdrawal log functionality 2025-11-26 12:13:33 -05:00
Chang lue Tsen
429e535dd4 feat(user): add endpoint and logic for updating user rules 2025-11-24 09:05:49 -05:00
EUForest
b9d3446407 Bug fix: Clear server user node cache 2025-11-09 17:18:25 +08:00
EUForest
b7eafd0892 Update: Account display priority: phone number > email > device ID 2025-11-08 17:05:05 +08:00
EUForest
52ce054b35 Add: Server location latitude and longitude 2025-11-04 14:53:43 +08:00