feat(v2): outbox 退款感知(refund_id 进唯一键)+ 投递门禁放行退款态 + Enqueue 贯通 refundID

This commit is contained in:
wangjia
2026-07-10 16:26:32 +08:00
parent 0912027c69
commit ed5ec5c894
12 changed files with 84 additions and 28 deletions
+4 -3
View File
@@ -43,13 +43,14 @@ func NewNotifier(ws *store.WebhookStore, bizConfig BizConfigFunc, orderPaid Orde
}
// Enqueue implements gateway.WebhookEnqueuer: serialize the domain payload and
// idempotently persist it to the outbox (delivery happens async).
func (n *Notifier) Enqueue(outTradeNo, bizSystem, eventType string, data map[string]any) error {
// idempotently persist it to the outbox (delivery happens async). refundID is
// the refund's idempotency dimension (payment events pass "").
func (n *Notifier) Enqueue(outTradeNo, bizSystem, eventType, refundID string, data map[string]any) error {
body, err := json.Marshal(data)
if err != nil {
return fmt.Errorf("webhook.Enqueue marshal: %w", err)
}
return n.deliveries.EnqueueDelivery(outTradeNo, bizSystem, eventType, string(body))
return n.deliveries.EnqueueDelivery(outTradeNo, bizSystem, eventType, refundID, string(body))
}
// DeliverPending flushes undelivered rows; returns how many succeeded this pass.