|
|
@@ -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,
|
|
|
|