fix(wallet): enforce consistent withdrawal accounting

This commit is contained in:
david
2026-07-31 09:54:17 +08:00
parent 36a5ced1c0
commit 42a2322c8e
23 changed files with 1405 additions and 250 deletions

View File

@@ -4,9 +4,9 @@ import (
"fmt"
sdkmiddleware "git.apinb.com/bsm-sdk/core/middleware"
clientcommon "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/common"
stafflogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/staff"
userlogic "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/client/user"
common "git.apinb.com/heqiapp/platforms/backend/api/internal/logic/common"
"github.com/gin-gonic/gin"
)
@@ -19,7 +19,7 @@ func RegisterClient(serviceKey string, engine *gin.Engine) {
func registerUserClient(serviceKey string, engine *gin.Engine) {
basePath := fmt.Sprintf("/%s/client/v1/user", serviceKey)
anonymous := engine.Group(basePath)
anonymous.POST("/auth/verification-code", clientcommon.SendVerificationCode("user_app"))
anonymous.POST("/auth/verification-code", common.SendVerificationCode("user_app"))
anonymous.POST("/auth/register", userlogic.Register)
anonymous.POST("/auth/login", userlogic.Login)
anonymous.POST("/auth/reset-password", userlogic.ResetPassword)
@@ -29,7 +29,7 @@ func registerUserClient(serviceKey string, engine *gin.Engine) {
anonymous.GET("/public/products", userlogic.PublicProducts)
protected := engine.Group(basePath)
protected.Use(sdkmiddleware.JwtAuth(true), clientcommon.RequireClient("user_app"))
protected.Use(sdkmiddleware.JwtAuth(true), common.RequireClient("user_app"))
protected.GET("/auth/profile", userlogic.Profile)
protected.PUT("/auth/profile", userlogic.UpdateProfile)
protected.PUT("/auth/password", userlogic.ChangePassword)
@@ -55,12 +55,12 @@ func registerUserClient(serviceKey string, engine *gin.Engine) {
func registerStaffClient(serviceKey string, engine *gin.Engine) {
basePath := fmt.Sprintf("/%s/client/v1/staff", serviceKey)
anonymous := engine.Group(basePath)
anonymous.POST("/auth/verification-code", clientcommon.SendVerificationCode("service_app"))
anonymous.POST("/auth/verification-code", common.SendVerificationCode("service_app"))
anonymous.POST("/auth/login", stafflogic.Login)
anonymous.POST("/auth/reset-password", stafflogic.ResetPassword)
protected := engine.Group(basePath)
protected.Use(sdkmiddleware.JwtAuth(true), clientcommon.RequireClient("service_app"))
protected.Use(sdkmiddleware.JwtAuth(true), common.RequireClient("service_app"))
protected.GET("/auth/profile", stafflogic.Profile)
protected.GET("/preflight", stafflogic.Preflight)
protected.PUT("/auth/password", stafflogic.ChangePassword)
@@ -83,14 +83,14 @@ func registerStaffClient(serviceKey string, engine *gin.Engine) {
}
func registerClientWalletRoutes(group *gin.RouterGroup, client string) {
group.GET("/wallet", clientcommon.GetWallet(client))
group.PUT("/wallet/payment-password", clientcommon.SetPaymentPassword(client))
group.GET("/wallet/records", clientcommon.ListWalletRecords(client))
group.POST("/wallet/recharges", clientcommon.CreateRecharge(client))
group.POST("/wallet/recharges/:identity/mock-confirm", clientcommon.ConfirmMockRecharge(client))
group.GET("/wallet/banks", clientcommon.ListBanks(client))
group.POST("/wallet/banks", clientcommon.BindBank(client))
group.DELETE("/wallet/banks/:identity", clientcommon.UnbindBank(client))
group.GET("/wallet/withdrawals", clientcommon.ListWithdrawals(client))
group.POST("/wallet/withdrawals", clientcommon.CreateWithdrawal(client))
group.GET("/wallet", common.GetWallet(client))
group.PUT("/wallet/payment-password", common.SetPaymentPassword(client))
group.GET("/wallet/records", common.ListWalletRecords(client))
group.POST("/wallet/recharges", common.CreateRecharge(client))
group.POST("/wallet/recharges/:identity/mock-confirm", common.ConfirmMockRecharge(client))
group.GET("/wallet/banks", common.ListBanks(client))
group.POST("/wallet/banks", common.BindBank(client))
group.DELETE("/wallet/banks/:identity", common.UnbindBank(client))
group.GET("/wallet/withdrawals", common.ListWithdrawals(client))
group.POST("/wallet/withdrawals", common.CreateWithdrawal(client))
}