Compare commits
2 Commits
9212efc176
...
b57221598d
| Author | SHA1 | Date | |
|---|---|---|---|
| b57221598d | |||
| 86d9c6e9c7 |
@ -81,7 +81,10 @@ func (l *ActivateOrderLogic) ProcessTask(ctx context.Context, task *asynq.Task)
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
l.finalizeCouponAndOrder(ctx, orderInfo)
|
if err := l.finalizeCouponAndOrder(ctx, orderInfo); err != nil {
|
||||||
|
logger.WithContext(ctx).Error("[ActivateOrderLogic] Finalize order failed", logger.Field("error", err.Error()))
|
||||||
|
return err
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +143,7 @@ func (l *ActivateOrderLogic) processOrderByType(ctx context.Context, orderInfo *
|
|||||||
|
|
||||||
// finalizeCouponAndOrder handles post-processing tasks including coupon updates
|
// finalizeCouponAndOrder handles post-processing tasks including coupon updates
|
||||||
// and order status finalization
|
// and order status finalization
|
||||||
func (l *ActivateOrderLogic) finalizeCouponAndOrder(ctx context.Context, orderInfo *order.Order) {
|
func (l *ActivateOrderLogic) finalizeCouponAndOrder(ctx context.Context, orderInfo *order.Order) error {
|
||||||
// Update coupon if exists
|
// Update coupon if exists
|
||||||
if orderInfo.Coupon != "" {
|
if orderInfo.Coupon != "" {
|
||||||
if err := l.svc.CouponModel.UpdateCount(ctx, orderInfo.Coupon); err != nil {
|
if err := l.svc.CouponModel.UpdateCount(ctx, orderInfo.Coupon); err != nil {
|
||||||
@ -158,7 +161,9 @@ func (l *ActivateOrderLogic) finalizeCouponAndOrder(ctx context.Context, orderIn
|
|||||||
logger.Field("error", err.Error()),
|
logger.Field("error", err.Error()),
|
||||||
logger.Field("order_no", orderInfo.OrderNo),
|
logger.Field("order_no", orderInfo.OrderNo),
|
||||||
)
|
)
|
||||||
|
return err
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPurchase handles new subscription purchase including user creation,
|
// NewPurchase handles new subscription purchase including user creation,
|
||||||
|
|||||||
14
说明文档.md
Normal file
14
说明文档.md
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# 项目说明文档
|
||||||
|
|
||||||
|
## 1. 项目规划
|
||||||
|
- [ ] 核心业务逻辑维护与Bug修复
|
||||||
|
- [ ] 确保支付与订单流程闭环
|
||||||
|
|
||||||
|
## 2. 实施方案
|
||||||
|
- **订单状态修复**:针对支付后订单状态未更新问题,完善异步任务的错误处理机制。
|
||||||
|
|
||||||
|
## 3. 进度记录
|
||||||
|
- **2026-01-15 [已完成] 修复订单状态更新 Bug**
|
||||||
|
- **问题描述**:用户支付成功后,订单状态停留在“已支付”,未流转到“已完成”,导致订阅未下发。
|
||||||
|
- **原因分析**:`finalizeCouponAndOrder` 函数在更新数据库失败时仅打印日志未返回错误,导致 Asynq 消息队列误判任务成功,未触发重试机制。
|
||||||
|
- **解决方案**:重构该函数及其调用方 `ProcessTask`,确保数据库更新错误能向上抛出,触发 Asynq 的自动重试策略。
|
||||||
Loading…
x
Reference in New Issue
Block a user