79 Commits

Author SHA1 Message Date
0b1e6ce3c3 fix: 单订阅模式激活时赠送订阅也用受益者 ID 查找
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m21s
findGiftSubscription 同步改用 singleModeUserId
(家庭组场景为家庭主 ID),与锚点订阅查找保持一致。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 06:10:58 -07:00
8838fc51f8 fix: 单订阅模式家庭组购买时用 SubscriptionUserId 查锚点
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m28s
NewPurchase 中查 FindSingleModeAnchorSubscribe 时,家庭组
场景下应使用实际受益者 SubscriptionUserId(成员/主),
而非付款人 UserId,否则找不到已有订阅,会为成员创建新订阅。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 05:56:09 -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
202c1c18d7 fix: 修复同 quantity 存在新用户和普通折扣档时老用户无法下单的问题
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m34s
isNewUserOnlyForQuantity 原逻辑取第一条匹配记录即返回,
当同一 quantity 同时配置了 new_user_only=true 和 false 两档时,
结果依赖数组顺序,导致老用户/超24h用户触发 SubscribeNewUserOnly 错误。

修复:扫描所有同 quantity 档位,仅当存在 true 且无 false 兜底时才返回 true;
有 false 兜底则返回 false,老用户可正常购买并命中普通折扣档。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-30 22:30:12 -07:00
e0b2be2058 x
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m36s
2026-03-30 21:05:21 -07:00
d072217e85 x 2026-03-30 07:40:42 -07:00
2a9c01ff8b x
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m28s
2026-03-30 04:49:55 -07:00
1a08949c80 fix: 流量触发限速后主动清除节点用户缓存
节点用户列表缓存(server:user:{id})永不过期,用户流量超限触发按量限速后
缓存中仍是旧的速度值,节点不会感知限速状态。

修复:每次写入 traffic_log 后,检查该订阅是否触发按量限速规则,
若 IsThrottled=true 则立即删除对应节点的用户列表缓存,
节点下次拉取时重新计算并应用降速后的 speed_limit。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-28 18:36:13 -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
4a2501a3d1 fix: 折扣匹配改为精确匹配 quantity,不再取全局最小值
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m55s
将 getDiscount 和 isNewUserOnlyForQuantity 的匹配逻辑从
inputMonths >= discount.Quantity 改为 inputMonths == discount.Quantity,
买多少天就用多少天对应的折扣,避免错误配置导致折扣泄漏。
同时增加 discount 值合法性校验(>0 且 <100)。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-26 01:28:50 -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
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
d78ec194af feat: IAP 对账逻辑在激活订单前显式更新订单状态为已支付。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m16s
2026-03-10 21:53:14 -07:00
4095552252 feat: 为订单表添加 IAP 相关字段并调整 IAP 对账逻辑参数。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m34s
2026-03-10 21:12: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
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
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
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
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
1e14e2dbd9 map对齐
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m7s
2026-03-07 07:16:01 -08:00
03573d2e65 双倍时间bug
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m33s
2026-03-07 02:05:48 -08: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
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
5f55b1242e fix: resolve order queue loss issue with retry mechanism and idempotency
- Fix task error handling: return actual errors instead of nil to enable retry
- Add idempotency check: skip processing for already finished orders
- Extend temp order cache: increase from 15 minutes to 24 hours
- Configure retry policy: add MaxRetry(5) for all payment callbacks (Epay, Alipay, Stripe)

This fixes the critical issue where paid orders were being lost due to:
1. Failed tasks being marked as successful and deleted from queue
2. Temporary order info expiring before queue processing
3. No retry mechanism for transient failures

Changes:
- queue/logic/order/activateOrderLogic.go: Fix error returns and add idempotency
- internal/logic/public/portal/purchaseLogic.go: Extend cache to 24 hours
- internal/logic/notify/*NotifyLogic.go: Add retry configuration
2026-01-12 18:30:42 +08:00
EUForest
7d4a19c9a3 fix: add quota limit check to prevent subscription bypass
- Add quota check in preCreateOrderLogic for order preview
- Move quota check inside transaction in purchaseLogic to prevent race condition
- Add quota check in activateOrderLogic as final safeguard when creating subscription
- Add quota check in redeemCodeLogic when redeeming codes for new subscriptions
2026-01-10 21:18:26 +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
Chang lue Tsen
81748abce4 fix(traffic_log): update deletion condition to use timestamp instead of created_at 2025-10-20 10:18:07 -04:00
Chang lue Tsen
adbe9a06d8 feat(exchange): add exchange rate handling and scheduled updates 2025-10-15 10:05:19 -04:00
Chang lue Tsen
8562734fde feat(user): add encryption algorithm and salt fields to User model for migrate 2025-10-09 13:33:03 -04:00
Chang lue Tsen
b97e2d650e refactor(cache): streamline subscription cache clearing logic 2025-10-03 15:20:11 -04:00
Chang lue Tsen
bf24e1756a fix(checkSubscriptionLogic): update status filter to include inactive subscriptions 2025-10-02 17:41:42 +09:00
Chang lue Tsen
d6fcff1fee fix(node): NodeId filter to FilterNodeParams and update cache clearing logic 2025-09-29 10:22:11 +09:00
Chang lue Tsen
d74d636735 feat(traffic): add protocol handling and update traffic statistics calculation 2025-09-28 11:31:21 -04:00
Chang lue Tsen
c1c324878b fix(traffic): skip logs with zero upload and download values 2025-09-27 10:16:28 -04:00
Chang lue Tsen
9ce6141b5a fix(log): correct model reference in SystemLog creation 2025-09-27 10:11:58 -04:00
Chang lue Tsen
537dab1c3b fix(quota): simplify gift amount calculation 2025-09-16 09:53:03 -04:00
Chang lue Tsen
cf4792cdc8 fix(quota): update time handling in quota logic and correct subscriber ID query 2025-09-13 14:02:49 -04:00
Chang lue Tsen
9b0e1b1e0f doc(log): rename function for clarity and add cache cleanup comment 2025-09-11 11:42:20 -04:00
Chang lue Tsen
6bc0fb4d90 fix(quota): update taskInfo to include current subscription count in quota logic 2025-09-11 06:29:12 -04:00
Chang lue Tsen
3f5aac239b feat(quota): enhance quota task management with new request structures and processing logic 2025-09-10 14:53:48 -04:00
Chang lue Tsen
83c1c14b01 fix(order): improve error logging for database transaction and user cache updates 2025-09-10 10:41:29 -04:00
Chang lue Tsen
d1be5febc3 feat(quota): add quota task creation and querying endpoints with updated data structures 2025-09-09 13:39:05 -04:00
Chang lue Tsen
47446ef410 fix(order): update commission calculation to actual payment amount minus gateway handling fee 2025-09-06 11:41:17 -04:00
Chang lue Tsen
0872099e98 fix(order): simplify commission handling and improve payload parsing logic 2025-09-06 11:28:32 -04:00
Chang lue Tsen
d5ed82955e fix(purchase): streamline error handling and improve JSON marshaling for temporary orders 2025-09-06 11:03:14 -04:00