refactor wallet domain management

This commit is contained in:
david
2026-07-28 09:25:49 +08:00
parent 8d71a1fc08
commit 8c6d52cf8c
20 changed files with 606 additions and 68 deletions

View File

@@ -28,6 +28,7 @@ func RegisterPlatform(serviceKey string, engine *gin.Engine) {
registerStaffRoute(protected)
registerUserRoute(protected)
registerProductRoute(protected)
registerWalletRoute(protected)
registerCommerceRoute(protected)
registerFinanceRoute(protected)
registerContentRoute(protected)
@@ -87,6 +88,37 @@ func registerProductRoute(group *gin.RouterGroup) {
owner.GET("/:identity", ownerGet)
}
func registerWalletRoute(group *gin.RouterGroup) {
basic := group.Group("/wallet_basic")
basic.GET("", platform.ListWalletBasic)
basic.GET("/:identity", platform.GetWalletBasic)
basic.PATCH("/:identity/status", platform.UpdateWalletBasicStatus)
basic.POST("/:identity/recharge", platform.RechargeWalletBasic)
basic.GET("/owner/:owner_type/:owner_identity", platform.GetOrCreateOwnerWallet)
bank := group.Group("/wallet_bank")
bank.GET("", platform.ListWalletBank)
bank.GET("/:identity", platform.GetWalletBank)
payment := group.Group("/wallet_payment")
payment.GET("", platform.ListWalletPayment)
payment.GET("/:identity", platform.GetWalletPayment)
record := group.Group("/wallet_record")
record.GET("", platform.ListWalletRecord)
record.GET("/:identity", platform.GetWalletRecord)
refund := group.Group("/wallet_refund")
refund.GET("", platform.ListWalletRefund)
refund.GET("/:identity", platform.GetWalletRefund)
applyCash := group.Group("/wallet_apply_cash")
applyCash.GET("", platform.ListWalletApplyCash)
applyCash.GET("/:identity", platform.GetWalletApplyCash)
applyCash.POST("/:identity/approve", platform.ApproveWalletApplyCash)
applyCash.POST("/:identity/reject", platform.RejectWalletApplyCash)
}
func registerCommerceRoute(group *gin.RouterGroup) {
categoryRelations := []platform.ResourceRelation{optionalRelation("parent_identity", "parent_id", &models.EcCategory{})}
_, categoryCreate, _, categoryUpdate := platform.ResourceHandlers(&models.EcCategory{}, []string{"name", "sort_no"}, []string{"name", "sort_no"}, categoryRelations...)
@@ -140,10 +172,6 @@ func registerFinanceRoute(group *gin.RouterGroup) {
registerWritableResource(group, "/finance/fin_settlement", settlementList, settlementCreate, settlementGet, settlementUpdate, &models.FinSettlement{})
registerRestrictedWritableResource(group, "/finance/fin_reconciliation", &models.FinReconciliation{}, []string{"channel", "bill_date", "difference_amount"})
registerReadOnlyResource(group, "/wallet/wallet", &models.Wallet{})
registerReadOnlyResource(group, "/wallet/wallet_ledger", &models.WalletLedger{})
registerReadOnlyResource(group, "/wallet/wallet_recharge", &models.WalletRecharge{})
registerReadOnlyResource(group, "/wallet/wallet_withdrawal", &models.WalletWithdrawal{})
}
func registerContentRoute(group *gin.RouterGroup) {