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,16 +4,17 @@ type AddcointotoutiaoReq struct { | ||
| 4 | Access_token string `json:"access_token"` | 4 | Access_token string `json:"access_token"` |
| 5 | Open_id string `json:"open_id"` | 5 | Open_id string `json:"open_id"` |
| 6 | //Device_id int `json:"device_id"` | 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 | type AddcointotoutiaoResp struct { | 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 | type GetAccessTokenResp struct { | 20 | type GetAccessTokenResp struct { |
| @@ -31,9 +32,9 @@ type GetOpenidResp struct { | @@ -31,9 +32,9 @@ type GetOpenidResp struct { | ||
| 31 | } | 32 | } |
| 32 | 33 | ||
| 33 | type GetGlobalIDResp struct { | 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,6 +69,7 @@ type FetchproteryboxData struct { | ||
| 68 | Curlevle int64 `json:"curlevle"` | 69 | Curlevle int64 `json:"curlevle"` |
| 69 | Leftcnt int `json:"leftcnt"` | 70 | Leftcnt int `json:"leftcnt"` |
| 70 | Curpoerty int64 `json:"curpoerty"` | 71 | Curpoerty int64 `json:"curpoerty"` |
| 72 | + ExtraGold int `json:"extragold"` | ||
| 71 | } | 73 | } |
| 72 | 74 | ||
| 73 | type FetchproteryboxResp struct { | 75 | type FetchproteryboxResp struct { |
| @@ -95,12 +97,13 @@ type AddgoldReq struct { | @@ -95,12 +97,13 @@ type AddgoldReq struct { | ||
| 95 | Openid string `json:"openid"` | 97 | Openid string `json:"openid"` |
| 96 | Device_id int `json:"device_id"` | 98 | Device_id int `json:"device_id"` |
| 97 | Gold_num int `json:"gold_num"` | 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 | type AddgoldData struct { | 103 | type AddgoldData struct { |
| 102 | Taoalgoldnum int `json:"taoalgoldnum"` | 104 | Taoalgoldnum int `json:"taoalgoldnum"` |
| 103 | Rewardgold int `json:"rewardgold"` | 105 | Rewardgold int `json:"rewardgold"` |
| 106 | + ExtraGold int `json:"extragold"` | ||
| 104 | } | 107 | } |
| 105 | 108 | ||
| 106 | type AddgoldResp struct { | 109 | type AddgoldResp struct { |
| @@ -135,6 +138,7 @@ type DosignData struct { | @@ -135,6 +138,7 @@ type DosignData struct { | ||
| 135 | Curday int `json:"curday"` | 138 | Curday int `json:"curday"` |
| 136 | Issigntaday int `json:"issigntaday"` | 139 | Issigntaday int `json:"issigntaday"` |
| 137 | Taoalgoldnum int `json:"taoalgoldnum"` | 140 | Taoalgoldnum int `json:"taoalgoldnum"` |
| 141 | + ExtraGold int `json:"extragold"` | ||
| 138 | } | 142 | } |
| 139 | 143 | ||
| 140 | type DosignResp struct { | 144 | type DosignResp struct { |
| @@ -235,27 +239,24 @@ type PlayerData struct { | @@ -235,27 +239,24 @@ type PlayerData struct { | ||
| 235 | OnLineGold int `json:"onLineGold"` | 239 | OnLineGold int `json:"onLineGold"` |
| 236 | } | 240 | } |
| 237 | 241 | ||
| 238 | - | ||
| 239 | type GetToutiaoGrowthRightResp struct { | 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 | type GetToutiaoGrowthRightDataResp struct { | 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 | RewardStatus int `json:"reward_status"` | 254 | RewardStatus int `json:"reward_status"` |
| 252 | } | 255 | } |
| 253 | 256 | ||
| 254 | - | ||
| 255 | - | ||
| 256 | type GetGrowthRightResp struct { | 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 | RetData GetToutiaoGrowthRightDataResp `json:"retData"` | 260 | RetData GetToutiaoGrowthRightDataResp `json:"retData"` |
| 260 | } | 261 | } |
| 261 | 262 | ||
| @@ -263,4 +264,3 @@ type GetGrowthRightReq struct { | @@ -263,4 +264,3 @@ type GetGrowthRightReq struct { | ||
| 263 | Openid string `json:"openid"` | 264 | Openid string `json:"openid"` |
| 264 | Device_id int `json:"device_id"` | 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,18 +273,21 @@ 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, 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 | acctoken, err := GetAccessToken() | 280 | acctoken, err := GetAccessToken() |
| 278 | if err != nil { | 281 | if err != nil { |
| 279 | logger.Error("AddCoinToTouTiao err=%v", err) | 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 | //获取 GlobalID | 286 | //获取 GlobalID |
| 284 | globalid, err := GetBytedanceGlobalID(acctoken, openid) | 287 | globalid, err := GetBytedanceGlobalID(acctoken, openid) |
| 285 | if err != nil { | 288 | if err != nil { |
| 286 | logger.Error("AddCoinToTouTiao GetBytedanceGlobalID err=%v", err) | 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 | var reqdata AddcointotoutiaoReq | 293 | var reqdata AddcointotoutiaoReq |
| @@ -299,7 +302,7 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | @@ -299,7 +302,7 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | ||
| 299 | bys, err := json.Marshal(&reqdata) | 302 | bys, err := json.Marshal(&reqdata) |
| 300 | if err != nil { | 303 | if err != nil { |
| 301 | logger.Error("AddCoinToTouTiao failed=%v", err) | 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,32 +310,33 @@ func AddCoinToTouTiao(openid string, deviceid, amount int, descr string, btype s | ||
| 307 | signature := CreateCommonBytedanceSign(bys, openid) | 310 | signature := CreateCommonBytedanceSign(bys, openid) |
| 308 | apiurl := ADDCOINTOTOUTIAOURL + "?signature=" + signature | 311 | apiurl := ADDCOINTOTOUTIAOURL + "?signature=" + signature |
| 309 | 312 | ||
| 310 | - | ||
| 311 | res, err := BeegoHttpPost(apiurl, reqdata) | 313 | res, err := BeegoHttpPost(apiurl, reqdata) |
| 312 | if err != nil { | 314 | if err != nil { |
| 313 | logger.Error("AddCoinToTouTiao failed=%v", err) | 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 | var resp AddcointotoutiaoResp | 319 | var resp AddcointotoutiaoResp |
| 319 | err = json.Unmarshal([]byte(res), &resp) | 320 | err = json.Unmarshal([]byte(res), &resp) |
| 320 | if err != nil { | 321 | if err != nil { |
| 321 | logger.Error("AddCoinToTouTiao failed=%v", err) | 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 | if resp.Errcode != 0 { | 326 | if resp.Errcode != 0 { |
| 326 | logger.Error("AddCoinToTouTiao failed=%v", resp) | 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 | newcoin, err := GetCoinFromToutiao(openid, 1) | 331 | newcoin, err := GetCoinFromToutiao(openid, 1) |
| 331 | if err != nil { | 332 | if err != nil { |
| 332 | logger.Error("AddCoinToTouTiao failed=%v", err) | 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 | func BeegoHttpPost(url string, reqdata AddcointotoutiaoReq) (string, error) { | 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,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 | 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 = "调用头条接口失败" |
| @@ -262,6 +262,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | @@ -262,6 +262,7 @@ func HandlerDosign(w http.ResponseWriter, data string) { | ||
| 262 | resp.RetData.Curround = uinfo.SignRound | 262 | resp.RetData.Curround = uinfo.SignRound |
| 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 | 266 | ||
| 266 | break | 267 | break |
| 267 | } | 268 | } |
| @@ -342,7 +343,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | @@ -342,7 +343,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | ||
| 342 | break | 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 | if err != nil { | 347 | if err != nil { |
| 347 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) | 348 | logger.Info(" HandlerAddgold property failed:%v,for:%v", err, data) |
| 348 | resp.RetMsg = "调用头条接口失败" | 349 | resp.RetMsg = "调用头条接口失败" |
| @@ -353,6 +354,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | @@ -353,6 +354,7 @@ func HandlerAddgold(w http.ResponseWriter, data string) { | ||
| 353 | uinfo.PassLvGold += addnum | 354 | uinfo.PassLvGold += addnum |
| 354 | resp.RetData.Taoalgoldnum = sumnum | 355 | resp.RetData.Taoalgoldnum = sumnum |
| 355 | resp.RetData.Rewardgold = rdata.Gold_num | 356 | resp.RetData.Rewardgold = rdata.Gold_num |
| 357 | + resp.RetData.ExtraGold = extragold | ||
| 356 | //保存 | 358 | //保存 |
| 357 | err = SaveUserInfo(uinfo) | 359 | err = SaveUserInfo(uinfo) |
| 358 | if err != nil { | 360 | if err != nil { |
| @@ -475,7 +477,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | @@ -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 | if err != nil { | 481 | if err != nil { |
| 480 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) | 482 | logger.Info(" HandlerFetchproterybox property failed:%v,for:%v", err, data) |
| 481 | resp.RetMsg = "调用头条接口失败" | 483 | resp.RetMsg = "调用头条接口失败" |
| @@ -493,6 +495,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | @@ -493,6 +495,7 @@ func HandlerFetchproterybox(w http.ResponseWriter, data string) { | ||
| 493 | resp.RetData.Leftcnt = uinfo.LeftCnt | 495 | resp.RetData.Leftcnt = uinfo.LeftCnt |
| 494 | //resp.RetData.Leftcnt = Decrcurrency(currkey, rdata.Openid) | 496 | //resp.RetData.Leftcnt = Decrcurrency(currkey, rdata.Openid) |
| 495 | resp.RetData.Curpoerty = uinfo.Property | 497 | resp.RetData.Curpoerty = uinfo.Property |
| 498 | + resp.RetData.ExtraGold = extragold | ||
| 496 | 499 | ||
| 497 | //保存 | 500 | //保存 |
| 498 | err = SaveUserInfo(uinfo) | 501 | err = SaveUserInfo(uinfo) |