refactor(utils): 修复密码哈希比较逻辑错误 feat(user): 新增按状态筛选优惠券接口 docs: 添加虚拟发货与任务中心相关文档 fix(wechat): 修正Code2Session上下文传递问题 test: 补充订单折扣与积分转换测试用例 build: 更新配置文件与构建脚本 style: 清理多余的空行与注释
48 lines
2.8 KiB
Go
48 lines
2.8 KiB
Go
package admin
|
|
|
|
import (
|
|
"net/http"
|
|
"strconv"
|
|
"bindbox-game/internal/code"
|
|
"bindbox-game/internal/pkg/core"
|
|
"bindbox-game/internal/repository/mysql/dao"
|
|
activitysvc "bindbox-game/internal/service/activity"
|
|
)
|
|
|
|
type activityCommitGenerateResp struct{ SeedVersion int32 `json:"seed_version"` }
|
|
type activityCommitSummaryResp struct{ SeedVersion int32 `json:"seed_version"`; Algo string `json:"algo"`; HasSeed bool `json:"has_seed"`; LenSeedMaster int `json:"len_seed_master"`; LenSeedHash int `json:"len_seed_hash"`; LenItemsRoot int `json:"len_items_root"`; ItemsRootHex string `json:"items_root_hex"` }
|
|
|
|
func (h *handler) GenerateActivityCommitmentGeneral() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
activityID, err := strconv.ParseInt(ctx.Param("activity_id"), 10, 64); if err != nil { ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "未传递活动ID")); return }
|
|
svc := activitysvc.NewActivityCommitmentService(dao.Use(h.repo.GetDbR()), dao.Use(h.repo.GetDbW()), h.repo)
|
|
ver, e := svc.Generate(ctx.RequestContext(), activityID)
|
|
if e != nil { ctx.AbortWithError(core.Error(http.StatusBadRequest, 170301, e.Error())); return }
|
|
ctx.Payload(&activityCommitGenerateResp{SeedVersion: ver})
|
|
}
|
|
}
|
|
|
|
func (h *handler) GetActivityCommitmentSummaryGeneral() core.HandlerFunc {
|
|
return func(ctx core.Context) {
|
|
activityID, err := strconv.ParseInt(ctx.Param("activity_id"), 10, 64); if err != nil { ctx.AbortWithError(core.Error(http.StatusBadRequest, code.ParamBindError, "未传递活动ID")); return }
|
|
svc := activitysvc.NewActivityCommitmentService(dao.Use(h.repo.GetDbR()), dao.Use(h.repo.GetDbW()), h.repo)
|
|
sum, e := svc.Summary(ctx.RequestContext(), activityID)
|
|
if e != nil { ctx.AbortWithError(core.Error(http.StatusBadRequest, 170302, e.Error())); return }
|
|
var lenMaster, lenHash, lenRoot *int
|
|
_ = h.repo.GetDbR().Raw("SELECT LENGTH(commitment_seed_master) FROM activities WHERE id=?", activityID).Scan(&lenMaster)
|
|
_ = h.repo.GetDbR().Raw("SELECT LENGTH(commitment_seed_hash) FROM activities WHERE id=?", activityID).Scan(&lenHash)
|
|
_ = h.repo.GetDbR().Raw("SELECT LENGTH(commitment_items_root) FROM activities WHERE id=?", activityID).Scan(&lenRoot)
|
|
var itemsHex *string
|
|
_ = h.repo.GetDbR().Raw("SELECT HEX(commitment_items_root) FROM activities WHERE id=?", activityID).Scan(&itemsHex)
|
|
|
|
lm, lh, lr := 0, 0, 0
|
|
if lenMaster != nil { lm = *lenMaster }
|
|
if lenHash != nil { lh = *lenHash }
|
|
if lenRoot != nil { lr = *lenRoot }
|
|
ih := ""
|
|
if itemsHex != nil { ih = *itemsHex }
|
|
|
|
ctx.Payload(&activityCommitSummaryResp{SeedVersion: sum.SeedVersion, Algo: sum.Algo, HasSeed: sum.HasSeed, LenSeedMaster: lm, LenSeedHash: lh, LenItemsRoot: lr, ItemsRootHex: ih})
|
|
}
|
|
}
|