feat: 实现订单超时自动取消功能,支持钱包余额解冻和 Asynq Scheduler 统一调度
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m58s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m58s
- 新增 expires_at 字段和复合索引,待支付订单 30 分钟超时自动取消 - 实现 cancelOrder/unfreezeWalletForCancel 钱包余额解冻逻辑 - 创建 Asynq 定时任务(order_expire/alert_check/data_cleanup) - 将原有 time.Ticker 轮询迁移至 Asynq Scheduler 统一调度 - 同步 delta specs 到 main specs 并归档变更
This commit is contained in:
@@ -61,6 +61,13 @@ const (
|
||||
TaskTypePackageFirstActivation = "package:first:activation" // 首次实名激活
|
||||
TaskTypePackageQueueActivation = "package:queue:activation" // 主套餐排队激活
|
||||
TaskTypePackageDataReset = "package:data:reset" // 套餐流量重置
|
||||
|
||||
// 订单超时任务类型
|
||||
TaskTypeOrderExpire = "order:expire" // 订单超时自动取消
|
||||
|
||||
// 定时任务类型(由 Asynq Scheduler 调度)
|
||||
TaskTypeAlertCheck = "alert:check" // 告警检查
|
||||
TaskTypeDataCleanup = "data:cleanup" // 数据清理
|
||||
)
|
||||
|
||||
// 用户状态常量
|
||||
@@ -150,6 +157,12 @@ const (
|
||||
OrderStatusCancelled = "cancelled" // 已取消
|
||||
)
|
||||
|
||||
// 订单超时配置常量
|
||||
const (
|
||||
OrderExpireTimeout = 30 * time.Minute // 订单超时时间(30分钟)
|
||||
OrderExpireBatchSize = 100 // 每次批量处理超时订单的数量上限
|
||||
)
|
||||
|
||||
// 队列配置常量
|
||||
const (
|
||||
QueueCritical = "critical" // 关键任务队列
|
||||
|
||||
Reference in New Issue
Block a user