feat: integrate unified payment and wallet refunds

This commit is contained in:
2026-08-02 23:24:32 +08:00
parent f0b8af0bc8
commit 82a2106a97
64 changed files with 1519 additions and 254 deletions

View File

@@ -40,6 +40,8 @@ func registerUserClient(serviceKey string, engine *gin.Engine) {
protected.GET("/gas/contracts", userlogic.ListGasContracts)
protected.GET("/gas/orders", userlogic.ListGasOrders)
protected.POST("/gas/orders/:identity/cancel", userlogic.CancelGasOrder)
protected.POST("/gas/orders/:identity/pay", userlogic.PayGasOrder)
protected.POST("/gas/orders/:identity/refunds", userlogic.CreateRefund("gasorder"))
protected.GET("/tickets", userlogic.ListTickets)
protected.POST("/tickets", userlogic.CreateTicket)
protected.POST("/tickets/:identity/confirm", userlogic.ConfirmTicket)
@@ -48,7 +50,9 @@ func registerUserClient(serviceKey string, engine *gin.Engine) {
protected.POST("/shop/orders", userlogic.CreateShopOrder)
protected.POST("/shop/orders/:identity/cancel", userlogic.CancelShopOrder)
protected.POST("/shop/orders/:identity/pay", userlogic.PayShopOrder)
protected.POST("/shop/orders/:identity/refunds", userlogic.CreateRefund("ec_order"))
protected.POST("/shop/orders/:identity/confirm-receipt", userlogic.ConfirmShopReceipt)
protected.GET("/refunds", userlogic.ListRefunds)
registerClientWalletRoutes(protected, "user_app")
}

View File

@@ -93,12 +93,12 @@ func RegisterDelivery(serviceKey string, engine *gin.Engine) {
protected.POST("/wallet_recharge", deliverylogic.Recharge)
protected.GET("/wallet_bank", deliverylogic.ListBank)
protected.GET("/wallet_bank/:identity", deliverylogic.GetBank)
protected.GET("/wallet_payment", deliverylogic.ListPayment)
protected.GET("/wallet_payment/:identity", deliverylogic.GetPayment)
protected.GET("/payment_order", deliverylogic.ListPayment)
protected.GET("/payment_order/:identity", deliverylogic.GetPayment)
protected.GET("/wallet_record", deliverylogic.ListRecord)
protected.GET("/wallet_record/:identity", deliverylogic.GetRecord)
protected.GET("/wallet_refund", deliverylogic.ListRefund)
protected.GET("/wallet_refund/:identity", deliverylogic.GetRefund)
protected.GET("/payment_refund", deliverylogic.ListRefund)
protected.GET("/payment_refund/:identity", deliverylogic.GetRefund)
protected.GET("/wallet_apply_cash", deliverylogic.ListApplyCash)
protected.POST("/wallet_apply_cash", deliverylogic.CreateApplyCash)
protected.GET("/wallet_apply_cash/:identity", deliverylogic.GetApplyCash)

View File

@@ -89,9 +89,9 @@ func registerGasBusinessRoutes(group *gin.RouterGroup) {
group.GET("/wallet_basic", gaslogic.ListWalletBasic)
group.GET("/wallet_bank", gaslogic.ListWalletBank)
group.GET("/wallet_payment", gaslogic.ListWalletPayment)
group.GET("/payment_order", gaslogic.ListPaymentOrder)
group.GET("/wallet_record", gaslogic.ListWalletRecord)
group.GET("/wallet_refund", gaslogic.ListWalletRefund)
group.GET("/payment_refund", gaslogic.ListPaymentRefund)
group.GET("/wallet_apply_cash", gaslogic.ListWalletApplyCash)
group.POST("/wallet_apply_cash", gaslogic.CreateWalletApplyCash)
group.GET("/fin_settlement", gaslogic.ListFinSettlement)

View File

@@ -0,0 +1,15 @@
package routers
import (
"fmt"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/payment"
"github.com/gin-gonic/gin"
)
// RegisterPaymentReturn 注册无 JWT 的渠道回调;安全性由渠道签名、商户、金额和支付单校验保证。
func RegisterPaymentReturn(serviceKey string, engine *gin.Engine) {
group := engine.Group(fmt.Sprintf("/%s/payment-return/v1", serviceKey))
group.POST("/alipay/notify", payment.AlipayNotify)
group.POST("/wechat/notify", payment.WechatNotify)
engine.POST(fmt.Sprintf("/%s/internal/v1/payment/close-expired", serviceKey), payment.CloseExpiredHandler)
}

View File

@@ -12,6 +12,7 @@ import (
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/fin"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/gas"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/gasorder"
paymentlogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/payment"
platformlogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/platform"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/product"
"git.apinb.com/heqiapp/platforms/backend/api/internal/logic/platform/staff"
@@ -148,18 +149,14 @@ func registerWalletRoute(group *gin.RouterGroup) {
bank.GET("", wallet.ListWalletBank)
bank.GET("/:identity", wallet.GetWalletBank)
payment := group.Group("/wallet_payment")
payment.GET("", wallet.ListWalletPayment)
payment.GET("/:identity", wallet.GetWalletPayment)
payment := group.Group("/payment_order")
payment.GET("", wallet.ListPaymentOrder)
payment.GET("/:identity", wallet.GetPaymentOrder)
record := group.Group("/wallet_record")
record.GET("", wallet.ListWalletRecord)
record.GET("/:identity", wallet.GetWalletRecord)
refund := group.Group("/wallet_refund")
refund.GET("", wallet.ListWalletRefund)
refund.GET("/:identity", wallet.GetWalletRefund)
applyCash := group.Group("/wallet_apply_cash")
applyCash.GET("", wallet.ListWalletApplyCash)
applyCash.GET("/:identity", wallet.GetWalletApplyCash)
@@ -213,6 +210,11 @@ func registerPlatformRoute(group *gin.RouterGroup) {
}
func registerFinanceRoute(group *gin.RouterGroup) {
refund := group.Group("/payment_refund")
refund.GET("", paymentlogic.ListRefund)
refund.GET("/:identity", paymentlogic.GetRefund)
refund.POST("/:identity/approve", paymentlogic.ApproveRefund)
refund.POST("/:identity/reject", paymentlogic.RejectRefund)
registerReadOnlyResource(group, "/fin_payment", &models.FinPayment{})
settlementList, settlementCreate, settlementGet, settlementUpdate := fin.FinSettlementHandlers()
registerWritableResource(group, "/fin_settlement", settlementList, settlementCreate, settlementGet, settlementUpdate, &models.FinSettlement{})

View File

@@ -211,7 +211,7 @@ func TestPlatformFinanceContentRoutesFollowTheirContracts(t *testing.T) {
}
for _, resource := range []string{
"/wallet_basic", "/wallet_bank", "/wallet_payment", "/wallet_record", "/wallet_refund", "/wallet_apply_cash",
"/wallet_basic", "/wallet_bank", "/payment_order", "/wallet_record", "/payment_refund", "/wallet_apply_cash",
} {
path := "/heqi/platform/v1" + resource
assertRouteMethods(t, routes, path, http.MethodGet)

View File

@@ -9,5 +9,6 @@ func Register(serviceKey string, engine *gin.Engine) {
RegisterGas(serviceKey, engine)
RegisterDelivery(serviceKey, engine)
RegisterClient(serviceKey, engine)
RegisterPaymentReturn(serviceKey, engine)
registerUploadRoute(serviceKey, engine)
}