feat: 添加订单详情和退款功能,更新用户角色管理,增强超级管理员鉴权
This commit is contained in:
@@ -1,9 +1,15 @@
|
||||
package super
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"quyun/v2/app/errorx"
|
||||
"quyun/v2/app/http/super/dto"
|
||||
"quyun/v2/app/requests"
|
||||
"quyun/v2/app/services"
|
||||
"quyun/v2/database/models"
|
||||
"quyun/v2/pkg/consts"
|
||||
"quyun/v2/providers/jwt"
|
||||
|
||||
"github.com/gofiber/fiber/v3"
|
||||
)
|
||||
@@ -26,6 +32,56 @@ func (*order) list(ctx fiber.Ctx, filter *dto.OrderPageFilter) (*requests.Pager,
|
||||
return services.Order.SuperOrderPage(ctx, filter)
|
||||
}
|
||||
|
||||
// detail
|
||||
//
|
||||
// @Summary 订单详情
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderID path int64 true "OrderID"
|
||||
// @Success 200 {object} dto.SuperOrderDetail
|
||||
//
|
||||
// @Router /super/v1/orders/:orderID [get]
|
||||
// @Bind orderID path
|
||||
func (*order) detail(ctx fiber.Ctx, orderID int64) (*dto.SuperOrderDetail, error) {
|
||||
return services.Order.SuperOrderDetail(ctx, orderID)
|
||||
}
|
||||
|
||||
// refund
|
||||
//
|
||||
// @Summary 订单退款(平台)
|
||||
// @Description 该接口只负责将订单从 paid 推进到 refunding,并提交异步退款任务;退款入账与权益回收由 worker 异步完成。
|
||||
// @Tags Super
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param orderID path int64 true "OrderID"
|
||||
// @Param form body dto.SuperOrderRefundForm true "Form"
|
||||
// @Success 200 {object} models.Order
|
||||
//
|
||||
// @Router /super/v1/orders/:orderID/refund [post]
|
||||
// @Bind orderID path
|
||||
// @Bind form body
|
||||
func (*order) refund(ctx fiber.Ctx, orderID int64, form *dto.SuperOrderRefundForm) (*models.Order, error) {
|
||||
if form == nil {
|
||||
return nil, errorx.ErrInvalidParameter
|
||||
}
|
||||
|
||||
claims, ok := ctx.Locals(consts.CtxKeyClaims).(*jwt.Claims)
|
||||
if !ok || claims == nil || claims.UserID <= 0 {
|
||||
return nil, errorx.ErrTokenInvalid
|
||||
}
|
||||
|
||||
return services.Order.SuperRefundOrder(
|
||||
ctx,
|
||||
claims.UserID,
|
||||
orderID,
|
||||
form.Force,
|
||||
form.Reason,
|
||||
form.IdempotencyKey,
|
||||
time.Now(),
|
||||
)
|
||||
}
|
||||
|
||||
// statistics
|
||||
//
|
||||
// @Summary 订单统计信息
|
||||
|
||||
Reference in New Issue
Block a user