package admin

import (
	"bindbox-game/internal/code"
	"bindbox-game/internal/pkg/core"
	"net/http"
)

// GetMatchingAudit 获取对对碰审计数据
// @Summary 获取对对碰审计数据
// @Description 运营通过单号查询发牌过程
// @Tags 管理端.对对碰
// @Accept json
// @Produce json
// @Security AdminAuth
// @Param order_no path string true "订单号"
// @Success 200 {object} activity.MatchingGame
// @Failure 400 {object} code.Failure
// @Router /api/admin/matching/audit/{order_no} [get]
func (h *handler) GetMatchingAudit() core.HandlerFunc {
	return func(ctx core.Context) {
		orderNo := ctx.Param("order_no")
		if orderNo == "" {
			ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "order_no required"))
			return
		}

		game, err := h.activity.ReconstructMatchingGame(ctx.RequestContext(), orderNo)
		if err != nil {
			ctx.AbortWithError(core.Error(http.StatusInternalServerError, code.ServerError, err.Error()))
			return
		}

		ctx.Payload(game)
	}
}
