完善租客等级免押与积分管理

This commit is contained in:
yml2213
2026-07-26 18:07:10 +08:00
parent 379536e5c5
commit c594b543d1
24 changed files with 1296 additions and 178 deletions
@@ -120,6 +120,29 @@ func (h *Handler) SetDepositFreeQuota(c *gin.Context) {
response.OK(c, item)
}
func (h *Handler) AdjustGrowthPoints(c *gin.Context) {
adminID, ok := currentAdminID(c)
if !ok {
response.Unauthorized(c, "缺少管理员上下文")
return
}
userID, ok := parseID(c)
if !ok {
return
}
var req GrowthPointsAdjustRequest
if err := c.ShouldBindJSON(&req); err != nil {
response.BadRequest(c, "成长积分调整参数不正确")
return
}
item, err := h.service.AdjustGrowthPoints(c.Request.Context(), adminID, userID, req, auditMeta(c))
if err != nil {
writeAdminUserError(c, err)
return
}
response.OK(c, item)
}
func (h *Handler) RevokeRealname(c *gin.Context) {
adminID, ok := currentAdminID(c)
if !ok {
@@ -232,6 +255,12 @@ func writeAdminUserError(c *gin.Context, err error) {
response.BadRequest(c, "请填写 2-200 字的调账原因")
case errors.Is(err, ErrInsufficientBalance):
response.Error(c, http.StatusConflict, "insufficient_balance", "用户可用余额不足,无法扣款")
case errors.Is(err, ErrInvalidGrowthPoints):
response.BadRequest(c, "目标积分不正确,需在 0 到 10 亿之间")
case errors.Is(err, ErrInvalidGrowthReason):
response.BadRequest(c, "请填写 2-200 字的积分调整原因")
case errors.Is(err, ErrGrowthPointsUnchanged):
response.Error(c, http.StatusConflict, "growth_points_unchanged", "目标积分与当前积分相同")
case IsNotFound(err):
response.Error(c, http.StatusNotFound, "not_found", "用户不存在")
default: