feat: 实现平台抽成、提现审批、异步任务集成及安全审计功能

This commit is contained in:
2025-12-30 14:54:19 +08:00
parent 5e8dbec806
commit ee1acae3ed
25 changed files with 985 additions and 60 deletions

View File

@@ -201,6 +201,11 @@ func (r *Routes) Register(router fiber.Router) {
PathParam[string]("id"),
Body[dto.OrderPayForm]("form"),
))
r.log.Debugf("Registering route: Post /v1/webhook/payment/notify -> transaction.Webhook")
router.Post("/v1/webhook/payment/notify"[len(r.Path()):], DataFunc1(
r.transaction.Webhook,
Body[WebhookForm]("form"),
))
// Register routes for controller: User
r.log.Debugf("Registering route: Delete /v1/me/favorites/:contentId -> user.RemoveFavorite")
router.Delete("/v1/me/favorites/:contentId"[len(r.Path()):], Func1(

View File

@@ -56,3 +56,27 @@ func (t *Transaction) Pay(ctx fiber.Ctx, id string, form *dto.OrderPayForm) (*dt
func (t *Transaction) Status(ctx fiber.Ctx, id string) (*dto.OrderStatusResponse, error) {
return services.Order.Status(ctx.Context(), id)
}
type WebhookForm struct {
OrderID string `json:"order_id"`
ExternalID string `json:"external_id"`
}
// Payment Webhook
//
// @Router /v1/webhook/payment/notify [post]
// @Summary Payment Webhook
// @Description Payment Webhook
// @Tags Transaction
// @Accept json
// @Produce json
// @Param form body WebhookForm true "Webhook Data"
// @Success 200 {string} string "success"
// @Bind form body
func (t *Transaction) Webhook(ctx fiber.Ctx, form *WebhookForm) (string, error) {
err := services.Order.ProcessExternalPayment(ctx.Context(), form.OrderID, form.ExternalID)
if err != nil {
return "fail", err
}
return "success", nil
}

View File

@@ -3,6 +3,7 @@ package v1
import (
"quyun/v2/app/http/v1/dto"
auth_dto "quyun/v2/app/http/v1/dto"
"quyun/v2/app/requests"
"quyun/v2/app/services"
"github.com/gofiber/fiber/v3"