fix(order): 处理finalizeCouponAndOrder的错误并添加日志记录
在finalizeCouponAndOrder函数中添加错误返回并记录日志,确保错误能够被捕获和处理
This commit is contained in:
parent
9212efc176
commit
86d9c6e9c7
@ -81,7 +81,10 @@ func (l *ActivateOrderLogic) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
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
|
||||
}
|
||||
|
||||
@ -140,7 +143,7 @@ func (l *ActivateOrderLogic) processOrderByType(ctx context.Context, orderInfo *
|
||||
|
||||
// finalizeCouponAndOrder handles post-processing tasks including coupon updates
|
||||
// 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
|
||||
if orderInfo.Coupon != "" {
|
||||
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("order_no", orderInfo.OrderNo),
|
||||
)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewPurchase handles new subscription purchase including user creation,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user