Constraint: 在线热修前必须保存当前迭代分支全部有效代码进展 Confidence: medium Scope-risk: broad Directive: 后续修改需保持审计事件与业务事务边界一致 Tested: git diff --cached --check Not-tested: 未运行全量测试,提交用于切换分支前保存既有工作
70 lines
2.1 KiB
Go
70 lines
2.1 KiB
Go
package agentrecharge
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/break/junhong_cmp_fiber/internal/model"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
// PaymentAudit 描述代理充值支付记录的实际生命周期变化。
|
|
type PaymentAudit struct {
|
|
ActionCode string
|
|
Summary string
|
|
Payment *model.Payment
|
|
Recharge *model.AgentRechargeRecord
|
|
BeforeData map[string]any
|
|
AfterData map[string]any
|
|
RechargeBeforeData map[string]any
|
|
RechargeAfterData map[string]any
|
|
}
|
|
|
|
// PaymentAuditWriter 在支付业务事务内追加统一 Audit Event。
|
|
type PaymentAuditWriter interface {
|
|
WriteAgentRechargePayment(ctx context.Context, tx *gorm.DB, change PaymentAudit) error
|
|
}
|
|
|
|
const (
|
|
// OnlinePaymentStatePending 表示渠道仍在等待付款。
|
|
OnlinePaymentStatePending = "pending"
|
|
// OnlinePaymentStatePaid 表示渠道已确认收款。
|
|
OnlinePaymentStatePaid = "paid"
|
|
// OnlinePaymentStateClosed 表示渠道订单已明确关闭。
|
|
OnlinePaymentStateClosed = "closed"
|
|
// OnlinePaymentStateUnknown 表示渠道状态暂时无法确定。
|
|
OnlinePaymentStateUnknown = "unknown"
|
|
)
|
|
|
|
// OnlinePaymentRequest 描述生成支付链接与主动查单所需的最小事实。
|
|
type OnlinePaymentRequest struct {
|
|
PaymentID uint
|
|
PaymentNo string
|
|
CorrelationID string
|
|
Description string
|
|
Amount int64
|
|
ExpireAt time.Time
|
|
PayerClientIP string
|
|
Config *model.WechatConfig
|
|
}
|
|
|
|
// OnlinePaymentResult 描述渠道返回的支付链接。
|
|
type OnlinePaymentResult struct {
|
|
QRContent string
|
|
}
|
|
|
|
// OnlinePaymentQueryResult 描述统一后的渠道支付状态。
|
|
type OnlinePaymentQueryResult struct {
|
|
State string
|
|
ThirdPartyTradeNo string
|
|
Amount int64
|
|
PaidAt *time.Time
|
|
}
|
|
|
|
// OnlinePaymentPort 定义代理在线充值需要的最小渠道能力。
|
|
type OnlinePaymentPort interface {
|
|
Available(config *model.WechatConfig) bool
|
|
CreatePaymentURL(ctx context.Context, request OnlinePaymentRequest) (OnlinePaymentResult, error)
|
|
Query(ctx context.Context, request OnlinePaymentRequest) (OnlinePaymentQueryResult, error)
|
|
}
|