调整奖励领取接口

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

@ -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("请求结果为空")
}