快照订单号以及退款订单号
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m27s
This commit is contained in:
@@ -491,12 +491,12 @@ func (s *ActivationService) syncCarrierStatusActivated(ctx context.Context, tx *
|
||||
}
|
||||
}
|
||||
|
||||
// InvalidatePackagesForRefund 退款精准失效套餐
|
||||
// InvalidatePackagesForRefund 退款精准失效套餐并写入退款快照
|
||||
// 规则:
|
||||
// 1. 优先按 packageUsageID 精准失效单条套餐(且必须属于当前退款订单)
|
||||
// 2. 未传 packageUsageID 时,按 orderID 失效该订单生成的套餐
|
||||
// 3. 若命中主套餐,级联失效其加油包,避免残留挂靠关系
|
||||
func (s *ActivationService) InvalidatePackagesForRefund(ctx context.Context, assetType string, assetID uint, orderID uint, packageUsageID *uint) error {
|
||||
func (s *ActivationService) InvalidatePackagesForRefund(ctx context.Context, assetType string, assetID uint, orderID uint, refundID uint, refundNo string, packageUsageID *uint) error {
|
||||
if orderID == 0 {
|
||||
return errors.New(errors.CodeInvalidParam, "无效的订单ID")
|
||||
}
|
||||
@@ -584,10 +584,20 @@ func (s *ActivationService) InvalidatePackagesForRefund(ctx context.Context, ass
|
||||
return nil
|
||||
}
|
||||
|
||||
updates := map[string]any{
|
||||
"status": constants.PackageUsageStatusInvalidated,
|
||||
}
|
||||
if refundID > 0 {
|
||||
updates["refund_id"] = refundID
|
||||
}
|
||||
if refundNo != "" {
|
||||
updates["refund_no"] = refundNo
|
||||
}
|
||||
|
||||
result := s.db.WithContext(ctx).
|
||||
Model(&model.PackageUsage{}).
|
||||
Where("id IN ?", targetIDs).
|
||||
Update("status", constants.PackageUsageStatusInvalidated)
|
||||
Updates(updates)
|
||||
if result.Error != nil {
|
||||
return errors.Wrap(errors.CodeDatabaseError, result.Error, "退款失效套餐失败")
|
||||
}
|
||||
@@ -596,6 +606,8 @@ func (s *ActivationService) InvalidatePackagesForRefund(ctx context.Context, ass
|
||||
zap.String("asset_type", assetType),
|
||||
zap.Uint("asset_id", assetID),
|
||||
zap.Uint("order_id", orderID),
|
||||
zap.Uint("refund_id", refundID),
|
||||
zap.String("refund_no", refundNo),
|
||||
zap.Int("target_count", len(targetIDs)),
|
||||
zap.Int64("affected", result.RowsAffected),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user