47 Commits

Author SHA1 Message Date
e51dbea7c7 fix: getDiscount 新人取折扣最大档,非新人取折扣最小档
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 7m31s
- 新人:所有匹配 quantity 的条目中取 discount 值最小的(折扣力度最大)
- 非新人:所有匹配 quantity 的条目中取 discount 值最大的(折扣力度最小,接近原价)
- 不再按 new_user_only 过滤,由 isNewUserOnlyForQuantity 在上层控制准入

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 07:22:12 -07:00
c8f172dc0e fix: getDiscount 新人取折扣最大档,非新人取最贵档
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
- 新人:遍历所有匹配 quantity 的条目,取 discount 值最小的(折扣力度最大)
- 非新人:仅看 new_user_only=false 的条目,取 discount 值最大的(最接近原价)

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 07:18:04 -07:00
52aaaf4de5 fix: getDiscount 新人价取值错误 — 始终优先取 new_user_only=false 的实际折扣档
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
同一 quantity 有两条记录时:
- new_user_only=true (discount=99.64) 是新人限制标记,非实际折扣
- new_user_only=false (discount=35.36) 是实际折扣价格

原逻辑遍历到第一条即返回,导致新人拿到 99.64 而非 35.36。
修复后优先取 new_user_only=false 的条目,仅在无 false 条目时才降级到 new_user_only=true。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 07:14:37 -07:00
5733ebe40d fix: renewal logic 尝鲜价未生效 — 改为走 newUser 资格判断
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m17s
renewalLogic 在计算折扣时硬编码 isNewUser=false,
导致新用户在 24h 窗口内通过 renewal 接口购买时无法享受尝鲜价。
改为调用 resolveNewUserDiscountEligibility,与 purchaseLogic 保持一致。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 06:35:14 -07:00
3167465865 fix: 单订阅模式成员购买时用家庭主 ID 查锚点订阅
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
ResolvePurchaseRoute 传入 entitlement.EffectiveUserID
(家庭主 ID)而非 u.Id(成员 ID),确保成员购买时
能找到家庭主已有订阅并续费,而不是新建一条订阅。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-31 06:08:28 -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
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
df7303738a bug: 无订阅情况 出现下多笔订单 支付状态乱
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m18s
2026-03-30 00:32:41 -07:00
8398865bd3 fix: SingleModel 下首购 isNew 判断错误导致佣金不发
SingleModel 模式下,用户首次购买会被路由成 orderType=2(续费),
导致 isNew 判断逻辑跳过,始终为 false,激活时 shouldProcessCommission
误判为非首购,佣金不发给邀请人。

修复:去除 isNew 查询对 orderType==1 的依赖,始终通过
IsUserEligibleForNewOrder 判断用户是否有历史完成订单。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-28 11:28:02 -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
bb80df5786 权限问题
Some checks failed
Build docker and publish / build (20.15.1) (push) Has been cancelled
2026-03-11 08:06:13 -07:00
fafb229295 feat: 为折扣计算函数 getDiscount 引入新用户判断逻辑以支持新用户专属折扣。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m37s
2026-03-11 03:56:48 -07:00
48383fa0a9 更新支付方式相关业务逻辑。
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m31s
2026-03-10 21:42:02 -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
662ef6edb3 15分钟修改成5分钟
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m38s
2026-03-09 22:29:30 -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
94f5d0c07d map对齐
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 7m29s
2026-03-07 07:42:09 -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
4349a7ea2f 家庭组 权益修改
All checks were successful
Build docker and publish / build (20.15.1) (push) Successful in 8m16s
2026-03-04 22:02:42 -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
0c544268e5 refactor payment platform canonicalization and order method consistency
Some checks failed
Build docker and publish / build (20.15.1) (push) Failing after 8m1s
2026-03-04 02:15:32 -08:00
b0eb6595ac add: 新增ci diamanté 2026-03-03 17:29:45 -08:00
4d8516b2e1 同步历史版本代码 2026-03-03 09:32:22 -08:00
EUForest
31e75efacb Merge upstream/master into master 2026-02-13 23:06:43 +08:00
Chang lue Tsen
701d47ed21 feat(order): add validation for quantity and amount limits in order requests 2026-02-08 06:41:23 -05:00
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
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
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
EUForest
95ddba2332 update: Added support for floating-point calculations for discounts 2025-11-21 17:40:03 +08:00
Chang lue Tsen
900096ed12 fix(coupon): add check for zero count in coupon usage validation 2025-09-16 10:17:18 -04:00
Chang lue Tsen
82fd674ae4 feat(api): standardize timestamp field across log structures 2025-08-26 14:39:54 -04:00
Chang lue Tsen
87c771bbd4 refactor(log): consolidate logging models and update related logic for improved clarity and functionality 2025-08-20 13:36:06 -04:00
Leif Draven
41d660bb9e
Develop (#64)
* fix(database): correct name entry for SingBox in initialization script

* fix(purchase): update gift amount deduction logic and handle zero-amount order status

* feat: add type and default fields to rule group requests and update related logic

* feat(rule): implement logic to set a default rule group during creation and update

* fix(rule): add type and default fields to rule group model and update related logic

* feat(proxy): enhance proxy group handling and sorting logic

* refactor(proxy): replace hardcoded group names with constants for better maintainability

* fix(proxy): update group selection logic to skip empty and default names

* feat(proxy): enhance proxy and group handling with new configuration options

* feat(surge): add Surge adapter support and enhance subscription URL handling

* feat(traffic): implement traffic reset logic for subscription cycles

* feat(auth): improve email and mobile config unmarshalling with default values

* fix(auth) upbind email not update

* fix(order) discount set default 1

* fix(order) discount set default 1

* fix: refactor surfboard proxy handling and enhance configuration template

* fix(renewal) discount set default 1

* feat(loon): add Loon configuration template and enhance proxy handling

* feat(subscription): update user subscription status based on expiration time

* fix(renewal): update subscription retrieval method to use token instead of order ID

* feat(order): enhance order processing logic with improved error handling and user subscription management

* fix(order): improve code quality and fix critical bugs in order processing logic

- Fix inconsistent logging calls across all order logic files
- Fix critical gift amount deduction logic bug in renewal process
- Fix variable shadowing errors in database transactions
- Add comprehensive Go-standard documentation comments
- Improve log prefix consistency for better debugging
- Remove redundant discount validation code

* fix(docker): add build argument for version in Docker image build process

* feat(version): add endpoint to retrieve application version information

* fix(auth): improve user authentication method logic and update user cache

* feat(user): add ordering functionality to user list retrieval

* fix(RevenueStatistics) fill list

* fix(UserStatistics) fill list

* fix(user): implement user cache clearing after auth method operations

* fix(auth): enhance OAuth login logic with improved request handling and user registration flow

* fix(user): implement sorting for authentication methods based on priority

* fix(user): correct ordering clause for user retrieval based on filter

* refactor(user): streamline cache management and enhance cache clearing logic

* feat(logs) set logs volume in develop

* fix(handler): implement browser interception to deny access for specific user agents

* fix(resetTraffic) reset daily server

* refactor(trojan): remove unused parameter and clean up logging in slice

* fix(middleware): add domain length check and improve user-agent handling

* fix(middleware): reorder domain processing and enhance user-agent handling

* fix(resetTraffic): update subscription reset logic to use expire_time for monthly and yearly checks

* fix(scheduler): update reset traffic task schedule to run daily at 00:30

* fix(traffic): enhance traffic reset logic for subscriptions and adjust status checks

* fix(activateOrder): update traffic reset logic to include reset day check

* feat(marketing): add batch email task management API and logic

* feat(application): implement CRUD operations for subscribe applications

* feat(types): add user agent limit and list to subscription configuration

* feat(application): update subscription application requests to include structured download links

* feat(application): add scheme field and download link handling to subscribe application

* feat(application): add endpoint to retrieve client information

* feat(application): move DownloadLink and SubscribeApplication types to types.api

* feat(application): add DownloadLink and SubscribeClient types, update client response structure

* feat(application): remove ProxyTemplate field from application API

* feat(application): implement adapter for client configuration and add preview template functionality

* feat(application): move DownloadLink type to types.api and remove from common.api

* feat(application): update PreviewSubscribeTemplate to return structured response

* feat(application): remove ProxyTemplate field from application API

* feat(application): enhance cache key generation for user list and server data

* feat(subscribe): add ClearCache method to manage subscription cache invalidation

* feat(payment): add Description field to PaymentMethodDetail response

* feat(subscribe): update next reset time calculation to use ExpireTime

* feat(purchase): include handling fee in total amount calculation

* feat(subscribe): add V2SubscribeHandler and logic for enhanced subscription management

* feat(subscribe): add output format configuration to subscription adapter

* feat(application): default data

---------

Co-authored-by: Chang lue Tsen <tension@ppanel.dev>
Co-authored-by: NoWay <Bob455668@hotmail.com>
2025-08-15 12:30:21 -04:00
Chang lue Tsen
c8de30f78c fix(order): improve code quality and fix critical bugs in order processing logic
- Fix inconsistent logging calls across all order logic files
- Fix critical gift amount deduction logic bug in renewal process
- Fix variable shadowing errors in database transactions
- Add comprehensive Go-standard documentation comments
- Improve log prefix consistency for better debugging
- Remove redundant discount validation code
2025-07-24 03:06:44 +09:00
Chang lue Tsen
8976724c1e fix(renewal): update subscription retrieval method to use token instead of order ID 2025-07-24 03:06:44 +09:00
NoWay
f4cd567492 fix(renewal) discount set default 1 2025-07-24 03:06:44 +09:00
NoWay
a155a4f8cd fix(order) discount set default 1 2025-07-24 03:06:44 +09:00
NoWay
1b78e04113 fix(order) discount set default 1 2025-07-24 03:06:44 +09:00
Chang lue Tsen
40c24fbc85 fix(purchase): update gift amount deduction logic and handle zero-amount order status 2025-07-24 03:06:44 +09:00
Chang lue Tsen
9691257bad fix(purchase): correct gift amount deduction logic and enhance payment processing comments 2025-07-07 14:26:53 -04:00
missish
565eb8cbbf "fix(order): 修复优惠券使用限制检查逻辑,增加数量有效性验证" 2025-06-02 01:47:16 +09:00
Chang lue Tsen
34c09c4618 refactor: update import paths from ppanel-server to server 2025-04-25 15:09:31 +09:00
Chang lue Tsen
8addcc584b init: 1.0.0 2025-04-25 12:08:29 +09:00