package payment import ( "context" "github.com/hibiken/asynq" refundchannel "github.com/break/junhong_cmp_fiber/internal/application/refundchannel" "github.com/break/junhong_cmp_fiber/pkg/auditcontext" "github.com/break/junhong_cmp_fiber/pkg/constants" "github.com/break/junhong_cmp_fiber/pkg/errors" ) // RefundChannelRecoveryTaskHandler 执行渠道原路退款结果恢复任务。 type RefundChannelRecoveryTaskHandler struct { service *refundchannel.Service } // NewRefundChannelRecoveryTaskHandler 创建渠道原路退款结果恢复任务 Handler。 func NewRefundChannelRecoveryTaskHandler(service *refundchannel.Service) *RefundChannelRecoveryTaskHandler { return &RefundChannelRecoveryTaskHandler{service: service} } // Handle 扫描原路处理中的退款并只查询渠道回填结果,绝不重复发起资金动作。 func (h *RefundChannelRecoveryTaskHandler) Handle(ctx context.Context, task *asynq.Task) error { if h == nil || h.service == nil { return errors.New(errors.CodeServiceUnavailable, "渠道原路退款恢复任务未配置") } taskType := constants.TaskTypeRefundChannelRecovery if task != nil && task.Type() != "" { taskType = task.Type() } ctx = auditcontext.With(ctx, auditcontext.Context{ ActorKind: constants.AuditActorScheduledJob, ActorID: taskType, ActorName: "渠道原路退款结果恢复计划任务", Source: constants.AuditSourceScheduler, }) _, err := h.service.ProcessBatch(ctx) return err }