调整奖励领取接口

This commit is contained in:
chy
2025-07-10 21:02:56 +08:00
parent 49fd919fe1
commit 4ae70786d3
3 changed files with 62 additions and 13 deletions

View File

@ -1,16 +1,17 @@
package ecode
var (
OK = New(0, "操作成功")
Sub = New(1, "") // 自定义错误信息
Fail = New(2, "服务器内部错误")
InvalidOperation = New(3, "非法的操作请求")
Params = New(4, "请求参数错误")
Logout = New(5, "用户未登录")
Disabled = New(6, "账户已被禁用")
Denied = New(7, "没有权限执行该操作")
Expire = New(8, "token已过期")
Auth = New(1000, "账户名或密码不正确")
Password = New(1001, "密码不正确")
EmailExist = New(1002, "该邮箱已被注册")
OK = New(0, "操作成功")
Sub = New(1, "") // 自定义错误信息
Fail = New(2, "服务器内部错误")
InvalidOperation = New(3, "非法的操作请求")
Params = New(4, "请求参数错误")
Logout = New(5, "用户未登录")
Disabled = New(6, "账户已被禁用")
Denied = New(7, "没有权限执行该操作")
Expire = New(8, "token已过期")
Auth = New(1000, "账户名或密码不正确")
Password = New(1001, "密码不正确")
EmailExist = New(1002, "该邮箱已被注册")
RewardExceedLimited = New(-1, "奖励领取数量超出限制")
)

View File

@ -3,6 +3,7 @@ package gamelife
import (
"context"
"encoding/json"
"errors"
"fmt"
"net/url"
"server/internal/dao"
@ -423,6 +424,22 @@ func (s *gamelifeClient) RequestActivity(ctx context.Context, in *model.QQNetbar
if err != nil || resp.IsError() {
return nil, ecode.Fail.Sub("请求出现异常")
}
// 判断是否为 -1 的异常
type RespData struct {
Ret int `json:"ret"`
ErrMsg string `json:"err_msg"`
ErrDesc string `json:"err_desc"`
}
var respData RespData
if err = json.Unmarshal(resp.Body(), &respData); err != nil {
return nil, ecode.Fail.Sub("解析请求结果失败")
}
if respData.Ret == -1 {
glog.Info(ctx, "奖励领取超出限制,-1")
return nil, errors.New("奖励领取超出限制,-1")
}
if result == nil {
return nil, ecode.Fail.Sub("请求结果为空")
}