package dispute import ( "context" "errors" "gorm.io/gorm" ) type Repository struct { db *gorm.DB refundFunc RefundFunc } // RefundFunc 由 payment 模块注入,避免 dispute 与 payment 形成循环依赖。 // RefundFunc 由 payment 模块注入,避免 dispute 与 payment 形成循环依赖。 type RefundFunc func(ctx context.Context, orderID uint64, refundAmountCent int64, bizType string, remark string) (status string, err error) type refundAction struct { OrderID uint64 RefundAmountCent int64 BizType string Remark string } func NewRepository(db *gorm.DB) *Repository { return &Repository{db: db} } func (r *Repository) SetRefundFunc(fn RefundFunc) { r.refundFunc = fn } func IsNotFound(err error) bool { return errors.Is(err, gorm.ErrRecordNotFound) }