Commit Graph

139 Commits

Author SHA1 Message Date
shanshanzhong147 f9fa4756e9 新功能(#41): 提现优化 — 收款方式选择 + 取消提现 + 收款码上传
Build docker and publish / build (20.15.1) (push) Failing after 8m37s
Co-authored-by: multica-agent <github@multica.ai>
2026-05-26 08:36:25 -07:00
shanshanzhong147 8b4e7561f4 修复: scripts 编译冲突 + order 统计 is_new 字段修正
- scripts/ 下两个独立脚本移到各自子目录,消除 package main 冲突
- model/order/model.go 统计查询 type→is_new 字段修正(7处)

Co-authored-by: multica-agent <github@multica.ai>
2026-05-26 08:06:50 -07:00
shanshanzhong147 b6b5bccde6 fix: use withdrawals table consistently
Build docker and publish / build (20.15.1) (push) Failing after 8m20s
Co-authored-by: multica-agent <github@multica.ai>
2026-05-25 10:43:24 -07:00
shanshanzhong147 eba256bdc9 merge: sync internal with main
Build docker and publish / build (20.15.1) (push) Failing after 8m22s
Co-authored-by: multica-agent <github@multica.ai>
2026-05-25 10:32:06 -07:00
shanshanzhong147 0bd7560b64 fix: P1 activation path hardening - Bug 4-9
Bug 4: resolveRenewalActivationSubscription - add fallback by user_id+subscribe_id
  with SELECT FOR UPDATE when token lookup fails

Bug 5: appleIAPNotifyLogic - return error on product ID mapping failure instead of
  silently dropping the notification

Bug 6: NewPurchase fallback query - wrap in transaction with SELECT FOR UPDATE to
  prevent concurrent duplicate subscription creation

Bug 7: appleIAPNotifyLogic - fix UserId=0 by reverse-lookup from original purchase
  order; create renewal audit order record for DID_RENEW/SUBSCRIBED notifications

Bug 8: UpdateOrderStatus - pre-delete cache before DB write (double-delete) to
  close TOCTOU window between DB update and cache invalidation

Bug 9: validateNewUserOnlyEligibilityAtActivation - add Redis distributed lock on
  user_id to serialise concurrent new-user-only order activations

Co-authored-by: multica-agent <github@multica.ai>
2026-05-25 02:18:19 -07:00
shanshanzhong147 a0f2d8a7b8 fix: persist guest/redemption activation context to DB to survive Redis TTL expiry (Bug 1 + Bug 10)
- Add `activation_context` TEXT column to `order` table (migration 02150)
- purchaseLogic: write TemporaryOrderInfo JSON to order.ActivationContext in the same
  insert transaction; Redis write is now best-effort (non-fatal)
- redeemCodeLogic: write redemption {type, redemption_code_id, unit_time, quantity} JSON
  to order.ActivationContext at order creation; Redis write is now best-effort (non-fatal)
- getTempOrderInfo: on Redis miss, fall back to order.ActivationContext from DB;
  logs CRITICAL and returns error if both are missing (old orders with no DB record)
- RedemptionActivate: on Redis miss, fall back to order.ActivationContext from DB;
  same CRITICAL log path for legacy orders

Co-authored-by: multica-agent <github@multica.ai>
2026-05-25 02:18:19 -07:00
shanshanzhong147 3bbce5ce84 fix: 修复退款与仪表盘订单统计口径
Build docker and publish / build (20.15.1) (push) Failing after 8m16s
Co-authored-by: multica-agent <github@multica.ai>
2026-05-24 17:50:29 -07:00
shanshanzhong147 1726a584fa feat: add admin order refund flow
Co-authored-by: multica-agent <github@multica.ai>
2026-05-24 17:50:23 -07:00
shanshanzhong147 fd522b6c71 path
Build docker and publish / build (20.15.1) (push) Successful in 8m56s
2026-05-19 19:35:44 -07:00
shanshanzhong147 54daa923da 补单逻辑
Build docker and publish / build (20.15.1) (push) Has been cancelled
2026-05-06 04:59:04 -07:00
shanshanzhong147 0ec0e2b9d2 fix(order): align invite gift ownership
Build docker and publish / build (20.15.1) (push) Has been cancelled
2026-04-28 05:19:57 -07:00
shanshanzhong147 f1bfc78d66 fix: 统一日期统计查询方式,使用 DATE_FORMAT 替代 time.Time 边界
Build docker and publish / build (20.15.1) (push) Successful in 4m58s
QueryDateOrders 和 QueryDateUserCounts 改用 DATE_FORMAT 字符串比较,
与 QueryDailyOrdersList 的 GROUP BY 逻辑一致,避免 go-sql-driver 时区转换导致金额不一致。

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-20 22:36:16 -07:00
shanshanzhong147 c8258dc93b feat: 设备登录新增 base_payload 字段,前端传入后存储到 user_device 表
Build docker and publish / build (20.15.1) (push) Successful in 4m48s
2026-04-20 20:08:20 -07:00
shanshanzhong147 c0d839deb9 fix: 修复仪表盘时区统计偏移、重复订阅、新增map_apple字段
Build docker and publish / build (20.15.1) (push) Successful in 5m23s
- fix(order/model): QueryDateOrders/QueryDailyOrdersList 使用 time.Date 替代 Truncate 修复 UTC+8 时区偏移
- fix(user/model): QueryResisterUserTotalByDate 同样修复时区截断
- fix(traffic/model): QueryServerTrafficByDay 同样修复时区截断
- fix(activateOrder): 兜底查询防止过期用户重购产生重复订阅
- feat(api): SubscribeDiscount 新增 map_apple 字段
2026-04-20 02:34:23 -07:00
shanshanzhong147 ea34718a0b fix: 设备变更时同步清除用户缓存,修复 user_devices 为空问题
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
shanshanzhong147 abc9864d46 fix: 单订阅模式下避免重复创建订阅
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
shanshanzhong147 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
shanshanzhong147 507ee16a30 x
Build docker and publish / build (20.15.1) (push) Successful in 8m20s
2026-03-28 09:06:24 -07:00
shanshanzhong147 2bdda7558c fix: JSON_CONTAINS node_group_ids 参数需用引号包裹
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
shanshanzhong147 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
shanshanzhong147 f703b5089a 分组概念
Build docker and publish / build (20.15.1) (push) Successful in 7m58s
2026-03-19 03:21:47 -07:00
shanshanzhong147 e5e9f93f68 Merge remote-tracking branch 'origin/master' into internal 2026-03-19 01:55:01 -07:00
shanshanzhong147 dcdbabdb13 注销
Build docker and publish / build (20.15.1) (push) Successful in 7m34s
2026-03-17 07:12:42 -07:00
shanshanzhong147 1d2f2a594a feat: 增强用户搜索功能,支持通过设备ID哈希进行查找。
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
shanshanzhong147 9b6efe2901 DefaultFamilyMaxSize
Build docker and publish / build (20.15.1) (push) Successful in 7m32s
2026-03-12 01:41:39 -07:00
shanshanzhong147 7c2eddf9c3 feat: 为订单表添加 app_account_token 字段并增强 Apple IAP 对账逻辑,支持通过交易历史记录查找。
Build docker and publish / build (20.15.1) (push) Successful in 7m25s
2026-03-10 20:47:24 -07:00
shanshanzhong147 26f6400e74 feat: 苹果支付uuid 及设备逻辑
Build docker and publish / build (20.15.1) (push) Successful in 8m3s
2026-03-10 19:53:19 -07:00
shanshanzhong147 5f884ed737 fix: 修复 读写不一致 appleiap 的问题
Build docker and publish / build (20.15.1) (push) Successful in 7m39s
2026-03-09 05:17:26 -07:00
shanshanzhong147 130fb702ab fix: IAP 支付流程优化与关键 bug 修复
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
shanshanzhong147 dcfcd036de x
Build docker and publish / build (20.15.1) (push) Successful in 7m46s
2026-03-08 22:37:58 -07:00
shanshanzhong147 79a97ec569 限制套餐具体到 档位
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
shanshanzhong147 69028898a4 搜索
Build docker and publish / build (20.15.1) (push) Successful in 7m52s
2026-03-08 08:05:26 -07:00
shanshanzhong147 7a3a53f1a9 ipa
Build docker and publish / build (20.15.1) (push) Successful in 7m47s
2026-03-08 05:12:28 -07:00
shanshanzhong147 4d913c1728 修复缓存
Build docker and publish / build (20.15.1) (push) Successful in 7m26s
2026-03-06 21:58:29 -08:00
shanshanzhong147 7308aa9191 无订阅 支付后出现两个订阅
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
shanshanzhong147 70c0483ca9 修复订阅
Build docker and publish / build (20.15.1) (push) Failing after 8m2s
2026-03-04 23:08:46 -08:00
shanshanzhong147 4752f844ef 各种配置项修复,优化到后台管理端配置
Build docker and publish / build (20.15.1) (push) Has been cancelled
2026-03-04 17:58:40 -08:00
shanshanzhong147 a01570b59d fix gitea workflow path and runner label
Build docker and publish / build (20.15.1) (push) Failing after 8m21s
2026-03-04 06:33:14 -08:00
shanshanzhong147 b0eb6595ac add: 新增ci diamanté 2026-03-03 17:29:45 -08:00
shanshanzhong147 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