优化支付退款钱包链路
This commit is contained in:
@@ -105,6 +105,16 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
}
|
||||
paymentService := payment.NewService(paymentRepo)
|
||||
paymentHandler := payment.NewHandler(paymentService)
|
||||
// Inject refund function into order repo to avoid circular dependency
|
||||
if orderRepo != nil && paymentRepo != nil {
|
||||
orderRepo.SetRefundFunc(func(orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
|
||||
dto, err := paymentRepo.StartRefund(orderID, refundAmountCent, bizType, remark)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return dto.Status, nil
|
||||
})
|
||||
}
|
||||
var notificationRepo *notification.Repository
|
||||
if deps.DB != nil {
|
||||
notificationRepo = notification.NewRepository(deps.DB)
|
||||
@@ -223,6 +233,8 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
orderRoutes.GET("/:id", orderHandler.Detail)
|
||||
orderRoutes.GET("/:id/chat", chatHandler.OrderConversation)
|
||||
orderRoutes.POST("/:id/pay", orderHandler.Pay)
|
||||
orderRoutes.POST("/:id/start-payment", paymentHandler.Start)
|
||||
orderRoutes.GET("/:id/query-payment", paymentHandler.Query)
|
||||
orderRoutes.POST("/:id/cancel", orderHandler.Cancel)
|
||||
orderRoutes.POST("/:id/handoff", orderHandler.SubmitHandoff)
|
||||
orderRoutes.GET("/:id/handoff-records", orderHandler.HandoffRecords)
|
||||
@@ -234,6 +246,7 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
orderRoutes.POST("/:id/checkout/counter", orderHandler.CounterCheckout)
|
||||
orderRoutes.POST("/:id/checkout/accept", orderHandler.AcceptCheckout)
|
||||
orderRoutes.POST("/:id/dispute", disputeHandler.Create)
|
||||
orderRoutes.GET("/:id/refund-status", paymentHandler.QueryRefundStatus)
|
||||
}
|
||||
|
||||
disputeRoutes := api.Group("/disputes", requireAuth)
|
||||
@@ -249,6 +262,7 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
walletRoutes.POST("/recharge", walletHandler.Recharge)
|
||||
walletRoutes.POST("/recharge/pay", paymentHandler.WalletRecharge)
|
||||
walletRoutes.POST("/recharge/pay/:id/query", paymentHandler.WalletRechargeQuery)
|
||||
walletRoutes.POST("/withdraw", walletHandler.Withdraw)
|
||||
}
|
||||
|
||||
fileRoutes := api.Group("/files", requireAuth)
|
||||
@@ -304,6 +318,8 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
adminRoutes.GET("/orders/:id/handoff-records", requirePerm("order:view"), orderHandler.AdminHandoffRecords)
|
||||
adminRoutes.POST("/orders/:id/close", requirePerm("order:close"), orderHandler.AdminClose)
|
||||
adminRoutes.POST("/orders/:id/mark-abnormal", requirePerm("order:mark_abnormal"), orderHandler.AdminMarkAbnormal)
|
||||
adminRoutes.POST("/orders/:id/refund", requirePerm("order:close"), orderHandler.AdminRefund)
|
||||
adminRoutes.GET("/orders/:id/refund-status", requirePerm("order:view"), orderHandler.AdminRefundStatus)
|
||||
adminRoutes.GET("/listings", requirePerm("listing:view"), listingHandler.ListAdmin)
|
||||
adminRoutes.GET("/listings/pending", requirePerm("listing:approve"), listingHandler.ListPendingReview)
|
||||
adminRoutes.GET("/listings/:id", requirePerm("listing:view"), listingHandler.FindAdmin)
|
||||
|
||||
Reference in New Issue
Block a user