Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
@@ -49,6 +49,7 @@ const (
|
||||
OrderStatusClose = 3 // Order closed/cancelled
|
||||
OrderStatusFailed = 4 // Order processing failed
|
||||
OrderStatusClaimed = 6 // Internal transient claim while a worker processes the order
|
||||
OrderStatusRefunded = 7 // Order refunded terminal state
|
||||
OrderStatusFinished = 5 // Order successfully completed
|
||||
)
|
||||
|
||||
@@ -272,25 +273,6 @@ func (l *ActivateOrderLogic) claimAndGetOrder(ctx context.Context, orderNo strin
|
||||
}
|
||||
|
||||
func (l *ActivateOrderLogic) releaseClaim(ctx context.Context, orderNo string) error {
|
||||
// 终态守卫:OrderStatusClaimed(6) 与 orderStatusRefunded(6) 共用同一枚举值。
|
||||
// 若已存在 333 退款日志,说明此处的 status=6 是「已退款」,不能再降回 5,
|
||||
// 否则下次 activate 会重新激活订阅、且管理员可二次触发退款导致佣金被多次扣减。
|
||||
// 详见 HIF-131 / HIF-132。
|
||||
refunded, err := log.HasRefundCommissionLog(l.svc.DB.WithContext(ctx), orderNo)
|
||||
if err != nil {
|
||||
logger.WithContext(ctx).Error("Check refund log before release claim failed",
|
||||
logger.Field("error", err.Error()),
|
||||
logger.Field("order_no", orderNo),
|
||||
)
|
||||
return fmt.Errorf("check refund log failed for order %s: %w", orderNo, err)
|
||||
}
|
||||
if refunded {
|
||||
logger.WithContext(ctx).Info("Skip release claim for refunded order (status=6 + refund log)",
|
||||
logger.Field("order_no", orderNo),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
if err := l.svc.DB.WithContext(ctx).
|
||||
Model(&order.Order{}).
|
||||
Where("order_no = ? AND status = ?", orderNo, OrderStatusClaimed).
|
||||
|
||||
Reference in New Issue
Block a user