feat: 新增退款管理模块 — 完整的退款审批流程、佣金回扣和资产重置
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m8s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m8s
新增退款申请全生命周期管理:创建/列表/详情/审批通过/拒绝/退回/重新提交 审批通过后异步执行佣金全额回扣(扣减各代理佣金钱包)和资产重置(套餐失效+停机+世代重置) 新增 tb_refund_request 表(迁移 000093)、RefundRequest Model、8 个 DTO 新增 Store/Service/Handler/路由注册,仅平台用户可访问
This commit is contained in:
@@ -122,4 +122,7 @@ func RegisterAdminRoutes(router fiber.Router, handlers *bootstrap.Handlers, midd
|
||||
if handlers.AgentRecharge != nil {
|
||||
registerAgentRechargeRoutes(authGroup, handlers.AgentRecharge, doc, basePath)
|
||||
}
|
||||
if handlers.Refund != nil {
|
||||
registerRefundRoutes(authGroup, handlers.Refund, doc, basePath)
|
||||
}
|
||||
}
|
||||
|
||||
81
internal/routes/refund.go
Normal file
81
internal/routes/refund.go
Normal file
@@ -0,0 +1,81 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model/dto"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/errors"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/middleware"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/openapi"
|
||||
)
|
||||
|
||||
// registerRefundRoutes 注册退款管理路由
|
||||
// 仅平台用户(超级管理员和平台用户)可访问
|
||||
func registerRefundRoutes(router fiber.Router, handler *admin.RefundHandler, doc *openapi.Generator, basePath string) {
|
||||
refund := router.Group("/refunds", func(c *fiber.Ctx) error {
|
||||
userType := middleware.GetUserTypeFromContext(c.UserContext())
|
||||
if userType != constants.UserTypeSuperAdmin && userType != constants.UserTypePlatform {
|
||||
return errors.New(errors.CodeForbidden, "无权限访问退款管理功能")
|
||||
}
|
||||
return c.Next()
|
||||
})
|
||||
groupPath := basePath + "/refunds"
|
||||
|
||||
Register(refund, doc, groupPath, "POST", "/", handler.Create, RouteSpec{
|
||||
Summary: "创建退款申请",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.CreateRefundRequest),
|
||||
Output: new(dto.RefundResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "GET", "/", handler.List, RouteSpec{
|
||||
Summary: "退款申请列表",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.RefundListRequest),
|
||||
Output: new(dto.RefundListResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "GET", "/:id", handler.GetByID, RouteSpec{
|
||||
Summary: "退款申请详情",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.RefundIDRequest),
|
||||
Output: new(dto.RefundResponse),
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "POST", "/:id/approve", handler.Approve, RouteSpec{
|
||||
Summary: "审批通过退款申请",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.ApproveRefundRequest),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "POST", "/:id/reject", handler.Reject, RouteSpec{
|
||||
Summary: "审批拒绝退款申请",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.RejectRefundRequest),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "POST", "/:id/return", handler.Return, RouteSpec{
|
||||
Summary: "退回退款申请",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.ReturnRefundRequest),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
|
||||
Register(refund, doc, groupPath, "POST", "/:id/resubmit", handler.Resubmit, RouteSpec{
|
||||
Summary: "重新提交退款申请",
|
||||
Tags: []string{"退款管理"},
|
||||
Input: new(dto.ResubmitRefundRequest),
|
||||
Output: nil,
|
||||
Auth: true,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user