Some checks failed
Build docker and publish / linux (1.24.5) (push) Failing after 40s
feat(pay): 添加支付API基础结构 feat(miniapp): 创建支付测试小程序页面与配置 feat(wechatpay): 配置微信支付参数与证书 fix(guild): 修复成员列表查询条件 docs: 更新代码规范文档与需求文档 style: 统一前后端枚举显示与注释格式 refactor(admin): 重构用户奖励发放接口参数处理 test(title): 添加称号效果参数验证测试
138 lines
4.4 KiB
Go
138 lines
4.4 KiB
Go
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
|
|
"bindbox-game/internal/code"
|
|
"bindbox-game/internal/pkg/core"
|
|
)
|
|
|
|
type getDrawReceiptResponse struct {
|
|
ID int64 `json:"id"`
|
|
DrawLogID int64 `json:"draw_log_id"`
|
|
AlgoVersion string `json:"algo_version"`
|
|
RoundID int64 `json:"round_id"`
|
|
DrawID int64 `json:"draw_id"`
|
|
ClientID int64 `json:"client_id"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
ServerSeedHash string `json:"server_seed_hash"`
|
|
ServerSubSeed string `json:"server_sub_seed"`
|
|
ClientSeed string `json:"client_seed"`
|
|
Nonce int64 `json:"nonce"`
|
|
ItemsRoot string `json:"items_root"`
|
|
WeightsTotal int64 `json:"weights_total"`
|
|
SelectedIndex int32 `json:"selected_index"`
|
|
RandProof string `json:"rand_proof"`
|
|
Signature string `json:"signature"`
|
|
ItemsSnapshot string `json:"items_snapshot"`
|
|
}
|
|
|
|
// GetDrawReceipt 获取抽奖收据
|
|
// @Summary 获取抽奖收据
|
|
// @Description 通过抽奖ID查询可验证的抽奖收据详情
|
|
// @Tags 管理端.活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param draw_id path integer true "抽奖ID"
|
|
// @Success 200 {object} getDrawReceiptResponse
|
|
// @Failure 404 {object} code.Failure
|
|
// @Security LoginVerifyToken
|
|
// @Router /api/admin/draw_receipts/{draw_id} [get]
|
|
func (h *handler) GetDrawReceipt() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
drawIDStr := ctx.Param("draw_id")
|
|
if drawIDStr == "" {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "未传递抽奖ID"))
|
|
return
|
|
}
|
|
|
|
drawID, err := strconv.ParseInt(drawIDStr, 10, 64)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "抽奖ID格式错误"))
|
|
return
|
|
}
|
|
|
|
receipt, err := h.activity.GetDrawReceipt(ctx.RequestContext(), drawID)
|
|
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusNotFound, code.GetDrawReceiptError, "未找到抽奖收据"))
|
|
return
|
|
}
|
|
|
|
ctx.Payload(&getDrawReceiptResponse{
|
|
ID: receipt.ID,
|
|
DrawLogID: receipt.DrawLogID,
|
|
AlgoVersion: receipt.AlgoVersion,
|
|
RoundID: receipt.RoundID,
|
|
DrawID: receipt.DrawID,
|
|
ClientID: receipt.ClientID,
|
|
Timestamp: receipt.Timestamp,
|
|
ServerSeedHash: receipt.ServerSeedHash,
|
|
ServerSubSeed: receipt.ServerSubSeed,
|
|
ClientSeed: receipt.ClientSeed,
|
|
Nonce: receipt.Nonce,
|
|
ItemsRoot: receipt.ItemsRoot,
|
|
WeightsTotal: receipt.WeightsTotal,
|
|
SelectedIndex: receipt.SelectedIndex,
|
|
RandProof: receipt.RandProof,
|
|
Signature: receipt.Signature,
|
|
ItemsSnapshot: receipt.ItemsSnapshot,
|
|
})
|
|
}
|
|
}
|
|
|
|
// GetDrawReceiptByLogID 通过日志ID获取抽奖收据
|
|
// @Summary 通过日志ID获取抽奖收据
|
|
// @Description 通过抽奖日志ID查询收据详情
|
|
// @Tags 管理端.活动
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Param log_id path integer true "日志ID"
|
|
// @Success 200 {object} getDrawReceiptResponse
|
|
// @Failure 404 {object} code.Failure
|
|
// @Security LoginVerifyToken
|
|
// @Router /api/admin/draw_receipts/log/{log_id} [get]
|
|
func (h *handler) GetDrawReceiptByLogID() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
logIDStr := ctx.Param("log_id")
|
|
if logIDStr == "" {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "未传递日志ID"))
|
|
return
|
|
}
|
|
|
|
logID, err := strconv.ParseInt(logIDStr, 10, 64)
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "日志ID格式错误"))
|
|
return
|
|
}
|
|
|
|
receipt, err := h.activity.GetDrawReceiptByLogID(ctx.RequestContext(), logID)
|
|
|
|
if err != nil {
|
|
ctx.AbortWithError(core.Error(http.StatusNotFound, code.GetDrawReceiptError, "未找到抽奖收据"))
|
|
return
|
|
}
|
|
|
|
ctx.Payload(&getDrawReceiptResponse{
|
|
ID: receipt.ID,
|
|
DrawLogID: receipt.DrawLogID,
|
|
AlgoVersion: receipt.AlgoVersion,
|
|
RoundID: receipt.RoundID,
|
|
DrawID: receipt.DrawID,
|
|
ClientID: receipt.ClientID,
|
|
Timestamp: receipt.Timestamp,
|
|
ServerSeedHash: receipt.ServerSeedHash,
|
|
ServerSubSeed: receipt.ServerSubSeed,
|
|
ClientSeed: receipt.ClientSeed,
|
|
Nonce: receipt.Nonce,
|
|
ItemsRoot: receipt.ItemsRoot,
|
|
WeightsTotal: receipt.WeightsTotal,
|
|
SelectedIndex: receipt.SelectedIndex,
|
|
RandProof: receipt.RandProof,
|
|
Signature: receipt.Signature,
|
|
ItemsSnapshot: receipt.ItemsSnapshot,
|
|
})
|
|
}
|
|
}
|