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
+2 -1
View File
@@ -33,8 +33,9 @@ type ProductResolver interface {
}
// WebhookEnqueuer receives a domain payload to deliver to the business system.
// refundID 为退款事件的幂等维度(payment 事件传 "")。
type WebhookEnqueuer interface {
Enqueue(outTradeNo, bizSystem, eventType string, data map[string]any) error
Enqueue(outTradeNo, bizSystem, eventType, refundID string, data map[string]any) error
}
type Gateway struct {
+1 -1
View File
@@ -38,7 +38,7 @@ type spyEnqueuer struct {
failNext bool // 置 true 模拟 outbox 入队失败(settle 崩溃窗口测试用)
}
func (s *spyEnqueuer) Enqueue(outTradeNo, bizSystem, eventType string, data map[string]any) error {
func (s *spyEnqueuer) Enqueue(outTradeNo, bizSystem, eventType, refundID string, data map[string]any) error {
if s.failNext {
s.failNext = false
return errors.New("outbox down")
+1 -1
View File
@@ -92,7 +92,7 @@ func (g *Gateway) enqueuePaymentSucceeded(att *model.Attempt, paidAt time.Time)
"channel": att.Channel,
"paid_at": paidAt.Format(time.RFC3339),
}
return g.webhook.Enqueue(o.OutTradeNo, o.BizSystem, "payment.succeeded", data)
return g.webhook.Enqueue(o.OutTradeNo, o.BizSystem, "payment.succeeded", "", data)
}
// HandleCallback runs a channel's raw callback through its Provider.VerifyCallback