开始增加支付-1

This commit is contained in:
yml
2026-06-03 12:21:23 +08:00
parent 6dcea2d56c
commit ae8928f458
22 changed files with 2098 additions and 33 deletions
@@ -0,0 +1,66 @@
package payment
import "errors"
var (
ErrDependencyUnavailable = errors.New("dependency unavailable")
ErrPaymentUnavailable = errors.New("payment unavailable")
ErrPaymentCannotStart = errors.New("payment cannot start")
ErrPaymentVerifyFailed = errors.New("payment verify failed")
ErrPaymentNotFound = errors.New("payment not found")
)
type Service struct {
repo *Repository
}
func NewService(repo *Repository) *Service {
return &Service{repo: repo}
}
func (s *Service) Start(userID uint64, orderID uint64, req StartPaymentRequest, clientIP string) (*PaymentDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
if userID == 0 || orderID == 0 {
return nil, ErrPaymentCannotStart
}
return s.repo.Start(userID, orderID, req, clientIP)
}
func (s *Service) Query(userID uint64, orderID uint64) (*PaymentDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
if userID == 0 || orderID == 0 {
return nil, ErrPaymentNotFound
}
return s.repo.Query(userID, orderID)
}
func (s *Service) StartWalletRecharge(userID uint64, req WalletRechargePaymentRequest, clientIP string) (*PaymentDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
if userID == 0 || req.Amount <= 0 {
return nil, ErrPaymentCannotStart
}
return s.repo.StartWalletRecharge(userID, req, clientIP)
}
func (s *Service) QueryWalletRecharge(userID uint64, paymentID uint64) (*PaymentDTO, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
if userID == 0 || paymentID == 0 {
return nil, ErrPaymentNotFound
}
return s.repo.QueryWalletRecharge(userID, paymentID)
}
func (s *Service) HandleLeshuaNotify(params map[string]string) (*NotifyResult, error) {
if s.repo == nil {
return nil, ErrDependencyUnavailable
}
return s.repo.HandleLeshuaNotify(params)
}