Commit 4fcc94553e4124a552383caeec047ccae3ac5755
1 parent
ededc30d
Exists in
master
返回新增加成金币
Showing
3 changed files
with
46 additions
and
39 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| ... | ... | @@ -4,16 +4,17 @@ type AddcointotoutiaoReq struct { |
| 4 | 4 | Access_token string `json:"access_token"` |
| 5 | 5 | Open_id string `json:"open_id"` |
| 6 | 6 | //Device_id int `json:"device_id"` |
| 7 | - Amount int `json:"amount"` | |
| 8 | - Description string `json:"description"` | |
| 9 | - Bonus_type string `json:"bonus_type"` | |
| 10 | - GlobalID int64 `json:"global_id"` | |
| 7 | + Amount int `json:"amount"` | |
| 8 | + Description string `json:"description"` | |
| 9 | + Bonus_type string `json:"bonus_type"` | |
| 10 | + GlobalID int64 `json:"global_id"` | |
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | type AddcointotoutiaoResp struct { |
| 14 | - Errcode int `json:"errcode"` | |
| 15 | - Errmsg string `json:"errmsg"` | |
| 16 | - Data int `json:"data"` | |
| 14 | + Errcode int `json:"errcode"` | |
| 15 | + Errmsg string `json:"errmsg"` | |
| 16 | + Data int `json:"data"` | |
| 17 | + Extra_ADD int `json:"gold_coin_extra_add"` | |
| 17 | 18 | } |
| 18 | 19 | |
| 19 | 20 | type GetAccessTokenResp struct { |
| ... | ... | @@ -31,9 +32,9 @@ type GetOpenidResp struct { |
| 31 | 32 | } |
| 32 | 33 | |
| 33 | 34 | type GetGlobalIDResp struct { |
| 34 | - GlobalID int64 `json:"global_id"` | |
| 35 | - Errcode int `json:"errcode"` | |
| 36 | - Errmsg string `json:"errmsg"` | |
| 35 | + GlobalID int64 `json:"global_id"` | |
| 36 | + Errcode int `json:"errcode"` | |
| 37 | + Errmsg string `json:"errmsg"` | |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | //-------------------------------------------------------------------------- |
| ... | ... | @@ -68,6 +69,7 @@ type FetchproteryboxData struct { |
| 68 | 69 | Curlevle int64 `json:"curlevle"` |
| 69 | 70 | Leftcnt int `json:"leftcnt"` |
| 70 | 71 | Curpoerty int64 `json:"curpoerty"` |
| 72 | + ExtraGold int `json:"extragold"` | |
| 71 | 73 | } |
| 72 | 74 | |
| 73 | 75 | type FetchproteryboxResp struct { |
| ... | ... | @@ -95,12 +97,13 @@ type AddgoldReq struct { |
| 95 | 97 | Openid string `json:"openid"` |
| 96 | 98 | Device_id int `json:"device_id"` |
| 97 | 99 | Gold_num int `json:"gold_num"` |
| 98 | - Gold_Type int `json:"gold_type"` | |
| 100 | + Gold_Type int `json:"gold_type"` | |
| 99 | 101 | } |
| 100 | 102 | |
| 101 | 103 | type AddgoldData struct { |
| 102 | 104 | Taoalgoldnum int `json:"taoalgoldnum"` |
| 103 | 105 | Rewardgold int `json:"rewardgold"` |
| 106 | + ExtraGold int `json:"extragold"` | |
| 104 | 107 | } |
| 105 | 108 | |
| 106 | 109 | type AddgoldResp struct { |
| ... | ... | @@ -135,6 +138,7 @@ type DosignData struct { |
| 135 | 138 | Curday int `json:"curday"` |
| 136 | 139 | Issigntaday int `json:"issigntaday"` |
| 137 | 140 | Taoalgoldnum int `json:"taoalgoldnum"` |
| 141 | + ExtraGold int `json:"extragold"` | |
| 138 | 142 | } |
| 139 | 143 | |
| 140 | 144 | type DosignResp struct { |
| ... | ... | @@ -235,27 +239,24 @@ type PlayerData struct { |
| 235 | 239 | OnLineGold int `json:"onLineGold"` |
| 236 | 240 | } |
| 237 | 241 | |
| 238 | - | |
| 239 | 242 | type GetToutiaoGrowthRightResp struct { |
| 240 | - StatusCode int `json:"status_code"` | |
| 241 | - Message string `json:"message"` | |
| 242 | - ServerTime int `json:"server_time"` | |
| 243 | - Data GetToutiaoGrowthRightDataResp `json:"data"` | |
| 243 | + StatusCode int `json:"status_code"` | |
| 244 | + Message string `json:"message"` | |
| 245 | + ServerTime int `json:"server_time"` | |
| 246 | + Data GetToutiaoGrowthRightDataResp `json:"data"` | |
| 244 | 247 | } |
| 245 | 248 | |
| 246 | 249 | type GetToutiaoGrowthRightDataResp struct { |
| 247 | - GrowthType int `json:"growth_type"` | |
| 248 | - GrowthLv int `json:"growth_lv"` | |
| 249 | - CoinBuff int `json:"coin_buff"` | |
| 250 | - SpeedBuff int `json:"speed_buff"` | |
| 250 | + GrowthType int `json:"growth_type"` | |
| 251 | + GrowthLv int `json:"growth_lv"` | |
| 252 | + CoinBuff int `json:"coin_buff"` | |
| 253 | + SpeedBuff int `json:"speed_buff"` | |
| 251 | 254 | RewardStatus int `json:"reward_status"` |
| 252 | 255 | } |
| 253 | 256 | |
| 254 | - | |
| 255 | - | |
| 256 | 257 | type GetGrowthRightResp struct { |
| 257 | - ErrNum int `json:"errNum"` | |
| 258 | - RetMsg string `json:"retMsg"` | |
| 258 | + ErrNum int `json:"errNum"` | |
| 259 | + RetMsg string `json:"retMsg"` | |
| 259 | 260 | RetData GetToutiaoGrowthRightDataResp `json:"retData"` |
| 260 | 261 | } |
| 261 | 262 | |
| ... | ... | @@ -263,4 +264,3 @@ type GetGrowthRightReq struct { |
| 263 | 264 | Openid string `json:"openid"` |
| 264 | 265 | Device_id int `json:"device_id"` |
| 265 | 266 | } |
| 266 | - | ... | ... |
src/HttpServer/logic/function.go
| ... | ... | @@ -273,18 +273,21 @@ func GetCoinFromToutiao(openid string, deviceid int) (int, error) { |
| 273 | 273 | return tmp.Data, nil |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | -func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, error) { | |
| 276 | +func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype string) (int, int, int, error) { | |
| 277 | + | |
| 278 | + gold_coin_extra_add := 0 | |
| 279 | + | |
| 277 | 280 | acctoken, err := GetAccessToken() |
| 278 | 281 | if err != nil { |
| 279 | 282 | logger.Error("AddCoinToTouTiao err=%v", err) |
| 280 | - return 0, 0, err | |
| 283 | + return 0, 0, gold_coin_extra_add, err | |
| 281 | 284 | } |
| 282 | 285 | |
| 283 | 286 | //获取 GlobalID |
| 284 | 287 | globalid, err := GetBytedanceGlobalID(acctoken, openid) |
| 285 | 288 | if err != nil { |
| 286 | 289 | logger.Error("AddCoinToTouTiao GetBytedanceGlobalID err=%v", err) |
| 287 | - return 0, 0, err | |
| 290 | + return 0, 0, gold_coin_extra_add, err | |
| 288 | 291 | } |
| 289 | 292 | |
| 290 | 293 | var reqdata AddcointotoutiaoReq |
| ... | ... | @@ -299,7 +302,7 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s |
| 299 | 302 | bys, err := json.Marshal(&reqdata) |
| 300 | 303 | if err != nil { |
| 301 | 304 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 302 | - return 0, 0, err | |
| 305 | + return 0, 0, gold_coin_extra_add, err | |
| 303 | 306 | } |
| 304 | 307 | |
| 305 | 308 | //计算签名 |
| ... | ... | @@ -307,32 +310,33 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s |
| 307 | 310 | signature := CreateCommonBytedanceSign(bys, openid) |
| 308 | 311 | apiurl := ADDCOINTOTOUTIAOURL + "?signature=" + signature |
| 309 | 312 | |
| 310 | - | |
| 311 | 313 | res, err := BeegoHttpPost(apiurl, reqdata) |
| 312 | 314 | if err != nil { |
| 313 | 315 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 314 | - return 0, 0, err | |
| 316 | + return 0, 0, gold_coin_extra_add, err | |
| 315 | 317 | } |
| 316 | 318 | |
| 317 | - | |
| 318 | 319 | var resp AddcointotoutiaoResp |
| 319 | 320 | err = json.Unmarshal([]byte(res), &resp) |
| 320 | 321 | if err != nil { |
| 321 | 322 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 322 | - return 0, 0, err | |
| 323 | + return 0, 0, gold_coin_extra_add, err | |
| 323 | 324 | } |
| 324 | 325 | |
| 325 | 326 | if resp.Errcode != 0 { |
| 326 | 327 | logger.Error("AddCoinToTouTiao failed=%v", resp) |
| 327 | - return 0, 0, errors.New(resp.Errmsg) | |
| 328 | + return 0, 0, gold_coin_extra_add, errors.New(resp.Errmsg) | |
| 328 | 329 | } |
| 329 | 330 | |
| 330 | 331 | newcoin, err := GetCoinFromToutiao(openid, 1) |
| 331 | 332 | if err != nil { |
| 332 | 333 | logger.Error("AddCoinToTouTiao failed=%v", err) |
| 333 | - return 0, 0, err | |
| 334 | + return 0, 0, gold_coin_extra_add, err | |
| 334 | 335 | } |
| 335 | - return resp.Data, newcoin, nil | |
| 336 | + | |
| 337 | + gold_coin_extra_add = resp.Extra_ADD | |
| 338 | + | |
| 339 | + return resp.Data, newcoin, gold_coin_extra_add, nil | |
| 336 | 340 | } |
| 337 | 341 | |
| 338 | 342 | 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 | 250 | } |
| 251 | 251 | |
| 252 | 252 | //加金币 |
| 253 | - _, sumgold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") | |
| 253 | + _, sumgold, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "签到奖励", "other") | |
| 254 | 254 | if err != nil { |
| 255 | 255 | logger.Info(" HandlerAddgold AddCoinToTouTiao failed:%v,for:%v", err, data) |
| 256 | 256 | resp.RetMsg = "调用头条接口失败" |
| ... | ... | @@ -262,6 +262,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { |
| 262 | 262 | resp.RetData.Curround = uinfo.SignRound |
| 263 | 263 | resp.RetData.Curday = uinfo.SingDay |
| 264 | 264 | resp.RetData.Taoalgoldnum = sumgold |
| 265 | + resp.RetData.ExtraGold = extragold | |
| 265 | 266 | |
| 266 | 267 | break |
| 267 | 268 | } |
| ... | ... | @@ -342,7 +343,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { |
| 342 | 343 | break |
| 343 | 344 | } |
| 344 | 345 | |
| 345 | - addnum, sumnum, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") | |
| 346 | + addnum, sumnum, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, rdata.Gold_num, "闯关送金币", "other") | |
| 346 | 347 | if err != nil { |
| 347 | 348 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) |
| 348 | 349 | resp.RetMsg = "调用头条接口失败" |
| ... | ... | @@ -353,6 +354,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { |
| 353 | 354 | uinfo.PassLvGold += addnum |
| 354 | 355 | resp.RetData.Taoalgoldnum = sumnum |
| 355 | 356 | resp.RetData.Rewardgold = rdata.Gold_num |
| 357 | + resp.RetData.ExtraGold = extragold | |
| 356 | 358 | //保存 |
| 357 | 359 | err = SaveUserInfo(uinfo) |
| 358 | 360 | if err != nil { |
| ... | ... | @@ -475,7 +477,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { |
| 475 | 477 | } |
| 476 | 478 | |
| 477 | 479 | //加金币 |
| 478 | - addgold, sumgold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") | |
| 480 | + addgold, sumgold, extragold, err := AddCoinToTouTiao(rdata.Openid, 1, cfg.Reward, "每日领取宝箱奖励", "other") | |
| 479 | 481 | if err != nil { |
| 480 | 482 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) |
| 481 | 483 | resp.RetMsg = "调用头条接口失败" |
| ... | ... | @@ -493,6 +495,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { |
| 493 | 495 | resp.RetData.Leftcnt = uinfo.LeftCnt |
| 494 | 496 | //resp.RetData.Leftcnt = Decrcurrency(currkey, rdata.Openid) |
| 495 | 497 | resp.RetData.Curpoerty = uinfo.Property |
| 498 | + resp.RetData.ExtraGold = extragold | |
| 496 | 499 | |
| 497 | 500 | //保存 |
| 498 | 501 | err = SaveUserInfo(uinfo) | ... | ... |