415 Commits

Author SHA1 Message Date
EUForest
7e08a07e29 fix: resolve balance payment issue with coupon and fee calculation
This commit fixes the inconsistent calculation logic between order preview
and actual order creation, which caused balance payment failures when using
coupons.

Changes:
- Standardized fee calculation order in both preCreateOrderLogic and purchaseLogic
- Moved gift amount deduction after fee calculation to ensure correct total
- Removed premature gift amount deduction before transaction in purchaseLogic
- Gift amount is now only deducted within the database transaction

The calculation order is now unified:
1. Apply coupon discount
2. Calculate handling fee based on post-coupon amount
3. Deduct gift amount from total (including fee)

This ensures the preview amount matches the actual payment amount.
2026-02-06 23:14:04 +08:00
EUForest
64023dfd1d update: redis config 2026-01-31 12:08:56 +08:00
EUForest
37200698ab update: redis config 2026-01-31 12:08:12 +08:00
EUForest
ffe589ff77 feat: Device short code lookup 2026-01-31 11:52:09 +08:00
5f1a546bbe fix: resolve trial subscription cache issue on new user registration
When new users register with trial subscription enabled, the subscription
link fails to connect in Clash clients. This is caused by missing cache
invalidation after transaction commit.

Changes:
- Add cache clearing after successful trial subscription creation
- Clear user subscription cache, subscription details cache, and server cache
- Modify activeTrial functions to return subscription object for cache clearing
- Apply fix to all registration methods: email, phone, device, and OAuth

This ensures subscription links work immediately after registration without
requiring manual subscription reset.
2026-01-22 23:57:15 +07: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
2a1ae2e1cc feat: add index on user.refer_code for faster invite code lookup
- Add idx_refer_code index to improve query performance
- Prevents full table scan when validating invite codes during registration
2026-01-10 20:37:24 +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
ed669d0620 feat: remove v prefix from service version and disable SECRET_KEY check 2026-01-07 14:40:07 +08:00
EUForest
076e5e584b fix: use underscore in build time to avoid ldflags parsing error 2026-01-07 14:27:41 +08:00
EUForest
d3e18af08e fix: correct ldflags for version and build time 2026-01-07 14:25:55 +08:00
EUForest
69ec491d0a fix bug: Restore WS connection 2026-01-07 01:23:40 +08:00
EUForest
d2e9a837cc Merge upstream changes and release v1.3.1 2026-01-06 18:53:52 +08:00
EUForest
f452838c63 Merge upstream/master into develop 2026-01-06 18:52:28 +08:00
EUForest
3eb40bd5e4 chore: simplify build workflow for v1.3 2026-01-06 17:10:41 +08:00
EUForest
8a804eec0c chore: simplify build workflow for v1.3 2026-01-06 17:02:31 +08:00
EUForest
8f783b162c feat: redemption code 2026-01-06 16:24:24 +08:00
EUForest
24c7fc8857 add: init sql 2026-01-06 16:16:42 +08:00
EUForest
23ef9dbff1 feat: bind device limit 2026-01-06 16:15:47 +08:00
EUForest
ec0a0f968e up: Redemption Code 2026-01-06 16:15:24 +08:00
EUForest
3f3b0ae6ad up: Redemption Code 2026-01-06 16:15:10 +08:00
EUForest
518595b058 feat: Redemption Code 2026-01-05 17:53:31 +08:00
EUForest
5beff61e91 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-03 23:21:41 +08:00
Tension
90e2f24d46 fix(config): conditionally set SubscribePath based on gateway mode 2026-01-03 18:05:17 +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
798fb9e245 feat(currency): add currency configuration support and integrate into payment processing 2025-12-31 11:47:24 +08:00
Tension
780e71441d fix(subscribe): refactor getSubscribeV2URL to remove token parameter and adjust URL construction 2025-12-31 10:53:50 +08:00
Tension
24f3c29fad fix(subscribe): improve short token validation by adding case-insensitive comparison 2025-12-30 16:23:07 +08:00
Tension
77a5373d44 feat(adapter): add support for additional parameters in Adapter and Client structs 2025-12-30 14:39:15 +08:00
Tension
8436c2d6ee feat(subscribe): add short token generation for user subscriptions 2025-12-30 14:06:46 +08:00
Tension
ff2fa573a0 fix(subscribe): enhance node subscription logic to handle empty tags and log node counts 2025-12-29 15:12:13 +08:00
Tension
d4c6aa0528 feat(node): add enabled field to node creation logic 2025-12-29 15:03:39 +08:00
Tension
532a5ab009 feat(config): update subscribe path in global config response 2025-12-29 15:00:19 +08:00
Tension
e8084e9d2c feat(subscribe): rename stop user subscribe handler to toggle and update logic for status change 2025-12-29 13:50:50 +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
518294a528 feat(database): add migration to drop server_group table 2025-12-28 22:55:38 +08:00
Tension
fb6adc9ae3 feat(subscribe): add inventory check and update logic for subscription plans 2025-12-28 22:44:14 +08:00
Tension
7a2000f696 feat(discount): change discount type to float64 for improved precision 2025-12-28 22:04:50 +08:00
Tension
495c4529ed fix(gorm): adjust caller skip for logging methods to improve stack trace accuracy 2025-12-28 21:52:54 +08:00
Tension
bbc3703404 feat(traffic): enhance logging for successful push traffic tasks 2025-12-28 21:52:42 +08:00
Tension
ec829452c1 feat(traffic): add debug logging for current time traffic multiplier 2025-12-28 21:52:29 +08:00
Tension
21f77e141b feat(node): update Node Multiplier configuration and initialize node 2025-12-28 21:52:16 +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
e027cbb5de refactor(server): remove server table 2025-12-23 07:52:38 -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
47c41d1d14 fix bug: telephone login 2025-12-19 22:46:48 +08:00