Commit 127b9d2bbe851caf1396c9f7e79485d9b9fdbc83
1 parent
c69654bb
Exists in
master
金币新增返回 extralimit字段
Showing
3 changed files
with
39 additions
and
30 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| @@ -11,10 +11,11 @@ type AddcointotoutiaoReq struct { | @@ -11,10 +11,11 @@ type AddcointotoutiaoReq struct { | ||
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | type AddcointotoutiaoResp struct { | 13 | type AddcointotoutiaoResp struct { |
| 14 | - Errcode int `json:"errcode"` | ||
| 15 | - Errmsg string `json:"errmsg"` | ||
| 16 | - Data int `json:"data"` | ||
| 17 | - Extra_ADD int `json:"gold_coin_extra_add"` | 14 | + Errcode int `json:"errcode"` |
| 15 | + Errmsg string `json:"errmsg"` | ||
| 16 | + Data int `json:"data"` | ||
| 17 | + Extra_ADD int `json:"gold_coin_extra_add"` | ||
| 18 | + Extra_Limit bool `json:"gold_coin_extra_limit"` | ||
| 18 | } | 19 | } |
| 19 | 20 | ||
| 20 | type GetAccessTokenResp struct { | 21 | type GetAccessTokenResp struct { |
| @@ -64,12 +65,13 @@ type FetchproteryboxReq struct { | @@ -64,12 +65,13 @@ type FetchproteryboxReq struct { | ||
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | type FetchproteryboxData struct { | 67 | type FetchproteryboxData struct { |
| 67 | - Goldnum int `json:"goldnum"` | ||
| 68 | - Sumgold int `json:"sumgold"` | ||
| 69 | - Curlevle int64 `json:"curlevle"` | ||
| 70 | - Leftcnt int `json:"leftcnt"` | ||
| 71 | - Curpoerty int64 `json:"curpoerty"` | ||
| 72 | - ExtraGold int `json:"extragold"` | 68 | + Goldnum int `json:"goldnum"` |
| 69 | + Sumgold int `json:"sumgold"` | ||
| 70 | + Curlevle int64 `json:"curlevle"` | ||
| 71 | + Leftcnt int `json:"leftcnt"` | ||
| 72 | + Curpoerty int64 `json:"curpoerty"` | ||
| 73 | + ExtraGold int `json:"extragold"` | ||
| 74 | + ExtraLimit bool `json:"extralimit"` | ||
| 73 | } | 75 | } |
| 74 | 76 | ||
| 75 | type FetchproteryboxResp struct { | 77 | type FetchproteryboxResp struct { |
| @@ -101,9 +103,10 @@ type AddgoldReq struct { | @@ -101,9 +103,10 @@ type AddgoldReq struct { | ||
| 101 | } | 103 | } |
| 102 | 104 | ||
| 103 | type AddgoldData struct { | 105 | type AddgoldData struct { |
| 104 | - Taoalgoldnum int `json:"taoalgoldnum"` | ||
| 105 | - Rewardgold int `json:"rewardgold"` | ||
| 106 | - ExtraGold int `json:"extragold"` | 106 | + Taoalgoldnum int `json:"taoalgoldnum"` |
| 107 | + Rewardgold int `json:"rewardgold"` | ||
| 108 | + ExtraGold int `json:"extragold"` | ||
| 109 | + ExtraLimit bool `json:"extralimit"` | ||
| 107 | } | 110 | } |
| 108 | 111 | ||
| 109 | type AddgoldResp struct { | 112 | type AddgoldResp struct { |
| @@ -134,11 +137,12 @@ type DosignReq struct { | @@ -134,11 +137,12 @@ type DosignReq struct { | ||
| 134 | } | 137 | } |
| 135 | 138 | ||
| 136 | type DosignData struct { | 139 | type DosignData struct { |
| 137 | - Curround int `json:"curround"` | ||
| 138 | - Curday int `json:"curday"` | ||
| 139 | - Issigntaday int `json:"issigntaday"` | ||
| 140 | - Taoalgoldnum int `json:"taoalgoldnum"` | ||
| 141 | - ExtraGold int `json:"extragold"` | 140 | + Curround int `json:"curround"` |
| 141 | + Curday int `json:"curday"` | ||
| 142 | + Issigntaday int `json:"issigntaday"` | ||
| 143 | + Taoalgoldnum int `json:"taoalgoldnum"` | ||
| 144 | + ExtraGold int `json:"extragold"` | ||
| 145 | + ExtraLimit bool `json:"extralimit"` | ||
| 142 | } | 146 | } |
| 143 | 147 | ||
| 144 | type DosignResp struct { | 148 | type DosignResp struct { |
src/HttpServer/logic/function.go
| @@ -273,21 +273,22 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { | @@ -273,21 +273,22 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { | ||
| 273 | return tmp.Data, nil | 273 | return tmp.Data, nil |
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | -func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, int, error) { | 276 | +func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, int, bool, error) { |
| 277 | 277 | ||
| 278 | gold_coin_extra_add := 0 | 278 | gold_coin_extra_add := 0 |
| 279 | + gold_coin_extra_limit := false | ||
| 279 | 280 | ||
| 280 | acctoken, err := GetAccessToken() | 281 | acctoken, err := GetAccessToken() |
| 281 | if err != nil { | 282 | if err != nil { |
| 282 | logger.Error("AddCoinToTouTiao err=%v", err) | 283 | logger.Error("AddCoinToTouTiao err=%v", err) |
| 283 | - return 0, 0, gold_coin_extra_add, err | 284 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 284 | } | 285 | } |
| 285 | 286 | ||
| 286 | //获取 GlobalID | 287 | //获取 GlobalID |
| 287 | globalid, err := GetBytedanceGlobalID(acctoken, openid) | 288 | globalid, err := GetBytedanceGlobalID(acctoken, openid) |
| 288 | if err != nil { | 289 | if err != nil { |
| 289 | logger.Error("AddCoinToTouTiao GetBytedanceGlobalID err=%v", err) | 290 | logger.Error("AddCoinToTouTiao GetBytedanceGlobalID err=%v", err) |
| 290 | - return 0, 0, gold_coin_extra_add, err | 291 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 291 | } | 292 | } |
| 292 | 293 | ||
| 293 | var reqdata AddcointotoutiaoReq | 294 | var reqdata AddcointotoutiaoReq |
| @@ -302,7 +303,7 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | @@ -302,7 +303,7 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | ||
| 302 | bys, err := json.Marshal(&reqdata) | 303 | bys, err := json.Marshal(&reqdata) |
| 303 | if err != nil { | 304 | if err != nil { |
| 304 | logger.Error("AddCoinToTouTiao failed=%v", err) | 305 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 305 | - return 0, 0, gold_coin_extra_add, err | 306 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 306 | } | 307 | } |
| 307 | 308 | ||
| 308 | //计算签名 | 309 | //计算签名 |
| @@ -313,30 +314,31 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | @@ -313,30 +314,31 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | ||
| 313 | res, err := BeegoHttpPost(apiurl, reqdata) | 314 | res, err := BeegoHttpPost(apiurl, reqdata) |
| 314 | if err != nil { | 315 | if err != nil { |
| 315 | logger.Error("AddCoinToTouTiao failed=%v", err) | 316 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 316 | - return 0, 0, gold_coin_extra_add, err | 317 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 317 | } | 318 | } |
| 318 | 319 | ||
| 319 | var resp AddcointotoutiaoResp | 320 | var resp AddcointotoutiaoResp |
| 320 | err = json.Unmarshal([]byte(res), &resp) | 321 | err = json.Unmarshal([]byte(res), &resp) |
| 321 | if err != nil { | 322 | if err != nil { |
| 322 | logger.Error("AddCoinToTouTiao failed=%v", err) | 323 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 323 | - return 0, 0, gold_coin_extra_add, err | 324 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 324 | } | 325 | } |
| 325 | 326 | ||
| 326 | if resp.Errcode != 0 { | 327 | if resp.Errcode != 0 { |
| 327 | logger.Error("AddCoinToTouTiao failed=%v", resp) | 328 | logger.Error("AddCoinToTouTiao failed=%v", resp) |
| 328 | - return 0, 0, gold_coin_extra_add, errors.New(resp.Errmsg) | 329 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, errors.New(resp.Errmsg) |
| 329 | } | 330 | } |
| 330 | 331 | ||
| 331 | newcoin, err := GetCoinFromToutiao(openid, 1) | 332 | newcoin, err := GetCoinFromToutiao(openid, 1) |
| 332 | if err != nil { | 333 | if err != nil { |
| 333 | logger.Error("AddCoinToTouTiao failed=%v", err) | 334 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 334 | - return 0, 0, gold_coin_extra_add, err | 335 | + return 0, 0, gold_coin_extra_add, gold_coin_extra_limit, err |
| 335 | } | 336 | } |
| 336 | 337 | ||
| 337 | gold_coin_extra_add = resp.Extra_ADD | 338 | gold_coin_extra_add = resp.Extra_ADD |
| 339 | + gold_coin_extra_limit = resp.Extra_Limit | ||
| 338 | 340 | ||
| 339 | - return resp.Data, newcoin, gold_coin_extra_add, nil | 341 | + return resp.Data, newcoin, gold_coin_extra_add, gold_coin_extra_limit, nil |
| 340 | } | 342 | } |
| 341 | 343 | ||
| 342 | func BeegoHttpPost(url string, reqdata AddcointotoutiaoReq) (string, error) { | 344 | func BeegoHttpPost(url string, reqdata AddcointotoutiaoReq) (string, error) { |
src/HttpServer/logic/logic.go
| @@ -250,7 +250,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | @@ -250,7 +250,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | ||
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | //加金币 | 252 | //加金币 |
| 253 | - _, sumgold, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") | 253 | + _, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") |
| 254 | if err != nil { | 254 | if err != nil { |
| 255 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) | 255 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) |
| 256 | resp.RetMsg = "调用头条接口失败" | 256 | resp.RetMsg = "调用头条接口失败" |
| @@ -263,6 +263,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | @@ -263,6 +263,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | ||
| 263 | resp.RetData.Curday = uinfo.SingDay | 263 | resp.RetData.Curday = uinfo.SingDay |
| 264 | resp.RetData.Taoalgoldnum = sumgold | 264 | resp.RetData.Taoalgoldnum = sumgold |
| 265 | resp.RetData.ExtraGold = extragold | 265 | resp.RetData.ExtraGold = extragold |
| 266 | + resp.RetData.ExtraLimit = extralimit | ||
| 266 | 267 | ||
| 267 | break | 268 | break |
| 268 | } | 269 | } |
| @@ -343,7 +344,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | @@ -343,7 +344,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | ||
| 343 | break | 344 | break |
| 344 | } | 345 | } |
| 345 | 346 | ||
| 346 | - addnum, sumnum, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") | 347 | + addnum, sumnum, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") |
| 347 | if err != nil { | 348 | if err != nil { |
| 348 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) | 349 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) |
| 349 | resp.RetMsg = "调用头条接口失败" | 350 | resp.RetMsg = "调用头条接口失败" |
| @@ -355,6 +356,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | @@ -355,6 +356,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | ||
| 355 | resp.RetData.Taoalgoldnum = sumnum | 356 | resp.RetData.Taoalgoldnum = sumnum |
| 356 | resp.RetData.Rewardgold = rdata.Gold_num | 357 | resp.RetData.Rewardgold = rdata.Gold_num |
| 357 | resp.RetData.ExtraGold = extragold | 358 | resp.RetData.ExtraGold = extragold |
| 359 | + resp.RetData.ExtraLimit = extralimit | ||
| 358 | //保存 | 360 | //保存 |
| 359 | err = SaveUserInfo(uinfo) | 361 | err = SaveUserInfo(uinfo) |
| 360 | if err != nil { | 362 | if err != nil { |
| @@ -477,7 +479,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | @@ -477,7 +479,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | ||
| 477 | } | 479 | } |
| 478 | 480 | ||
| 479 | //加金币 | 481 | //加金币 |
| 480 | - addgold, sumgold, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") | 482 | + addgold, sumgold, extragold, extralimit, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") |
| 481 | if err != nil { | 483 | if err != nil { |
| 482 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) | 484 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) |
| 483 | resp.RetMsg = "调用头条接口失败" | 485 | resp.RetMsg = "调用头条接口失败" |
| @@ -496,6 +498,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | @@ -496,6 +498,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | ||
| 496 | //resp.RetData.Leftcnt = Decrcurrency(currkey, rdata.Openid) | 498 | //resp.RetData.Leftcnt = Decrcurrency(currkey, rdata.Openid) |
| 497 | resp.RetData.Curpoerty = uinfo.Property | 499 | resp.RetData.Curpoerty = uinfo.Property |
| 498 | resp.RetData.ExtraGold = extragold | 500 | resp.RetData.ExtraGold = extragold |
| 501 | + resp.RetData.ExtraLimit = extralimit | ||
| 499 | 502 | ||
| 500 | //保存 | 503 | //保存 |
| 501 | err = SaveUserInfo(uinfo) | 504 | err = SaveUserInfo(uinfo) |