Commit 11935c04bc31107532b9975588a50267dd9660ff
1 parent
28bd72a3
Exists in
master
提交
Showing
3 changed files
with
89 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| @@ -386,6 +386,24 @@ type UploadhigestscoreResp struct { | @@ -386,6 +386,24 @@ type UploadhigestscoreResp struct { | ||
| 386 | Data UploadhigestscoreData `json:"data"` | 386 | Data UploadhigestscoreData `json:"data"` |
| 387 | } | 387 | } |
| 388 | 388 | ||
| 389 | + | ||
| 390 | +type TurntablebagReq struct { | ||
| 391 | + Num int `json:"num"` | ||
| 392 | + Gameid string `json:"gameid"` | ||
| 393 | + Channel string `json:"channel"` | ||
| 394 | +} | ||
| 395 | + | ||
| 396 | +type TurntablebagData struct { | ||
| 397 | + Getgoldnum int `json:"getgoldnum"` | ||
| 398 | + Walletgold int `json:"walletgold"` | ||
| 399 | +} | ||
| 400 | + | ||
| 401 | +type TurntablebagResp struct { | ||
| 402 | + Code int `json:"code"` | ||
| 403 | + Message string `json:"message"` | ||
| 404 | + Data TurntablebagData `json:"data"` | ||
| 405 | +} | ||
| 406 | + | ||
| 389 | // | 407 | // |
| 390 | type AchieveMentInfo struct { | 408 | type AchieveMentInfo struct { |
| 391 | WatchAdsCnt int //观看广告数 | 409 | WatchAdsCnt int //观看广告数 |
src/HttpServer/logic/httpserver.go
| @@ -75,6 +75,7 @@ func startServerHttpServe() { | @@ -75,6 +75,7 @@ func startServerHttpServe() { | ||
| 75 | http.HandleFunc("/ballbattle/getdata", Getdata) //获取数据 | 75 | http.HandleFunc("/ballbattle/getdata", Getdata) //获取数据 |
| 76 | http.HandleFunc("/ballbattle/uploadscore", Uploadscore) //上报当天积分 | 76 | http.HandleFunc("/ballbattle/uploadscore", Uploadscore) //上报当天积分 |
| 77 | http.HandleFunc("/ballbattle/queryrankinfo", Queryrankinfo) //获取排行榜信息 | 77 | http.HandleFunc("/ballbattle/queryrankinfo", Queryrankinfo) //获取排行榜信息 |
| 78 | + http.HandleFunc("/ballbattle/turntablebag", Turntablebag) //转盘红包 | ||
| 78 | // | 79 | // |
| 79 | http.HandleFunc("/ballbattle/readNumUpload", ReadNumUpload) //阅读量上报 | 80 | http.HandleFunc("/ballbattle/readNumUpload", ReadNumUpload) //阅读量上报 |
| 80 | http.HandleFunc("/ballbattle/queryreadgold", QueryReadGold) //获取微转发金币数 | 81 | http.HandleFunc("/ballbattle/queryreadgold", QueryReadGold) //获取微转发金币数 |
| @@ -156,6 +157,28 @@ func Savadata(w http.ResponseWriter, r *http.Request) { | @@ -156,6 +157,28 @@ func Savadata(w http.ResponseWriter, r *http.Request) { | ||
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | 159 | ||
| 160 | +func Turntablebag(w http.ResponseWriter, r *http.Request) { | ||
| 161 | + | ||
| 162 | + Uuid := 0 | ||
| 163 | + if len(r.Header) > 0 { | ||
| 164 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + if Uuid == 0 { | ||
| 168 | + SetHeader(w) | ||
| 169 | + //logger.Error("Uuid is nil!") | ||
| 170 | + return | ||
| 171 | + } | ||
| 172 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 173 | + r.Body.Close() | ||
| 174 | + | ||
| 175 | + s := string(result) | ||
| 176 | + logger.Info("Turntablebag , body:%v,uuid=%v", s, Uuid) | ||
| 177 | + | ||
| 178 | + HandlerTurntablebag(w, s, Uuid) | ||
| 179 | +} | ||
| 180 | + | ||
| 181 | + | ||
| 159 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { | 182 | func Queryrankinfo(w http.ResponseWriter, r *http.Request) { |
| 160 | 183 | ||
| 161 | Uuid := 0 | 184 | Uuid := 0 |
src/HttpServer/logic/logic.go
| @@ -571,6 +571,54 @@ func HandlerUploadscore(w http.ResponseWriter, data string, uuid int) { | @@ -571,6 +571,54 @@ func HandlerUploadscore(w http.ResponseWriter, data string, uuid int) { | ||
| 571 | fmt.Fprint(w, string(respstr)) | 571 | fmt.Fprint(w, string(respstr)) |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | +func HandlerTurntablebag(w http.ResponseWriter, data string, uuid int) { | ||
| 575 | + SetHeader(w) | ||
| 576 | + var resp TurntablebagResp | ||
| 577 | + resp.Code = 0 | ||
| 578 | + resp.Message = "success" | ||
| 579 | + var rdata TurntablebagReq | ||
| 580 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 581 | + for { | ||
| 582 | + if err != nil { | ||
| 583 | + logger.Info("json decode HandlerTurntablebag data failed:%v,for:%v", err, data) | ||
| 584 | + resp.Message = "网络错误" | ||
| 585 | + resp.Code = ERROR_JSONUNMASH_ERROR | ||
| 586 | + break | ||
| 587 | + } | ||
| 588 | + | ||
| 589 | + //需要加上渠道才是唯一的玩家id,不同渠道视为不同数据 | ||
| 590 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
| 591 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 592 | + if err != nil || uinfo == nil { | ||
| 593 | + logger.Error("redis failed err=%v", err) | ||
| 594 | + resp.Message = "服务器错误" | ||
| 595 | + resp.Code = ERROR_SRV_ERROR | ||
| 596 | + break | ||
| 597 | + } | ||
| 598 | + | ||
| 599 | + goldnum, _, err := AddCoinToSdk(uuid, rdata.Num, rdata.Gameid, rdata.Channel, 104) | ||
| 600 | + if err != nil { | ||
| 601 | + logger.Error("AddCoinToSdk failed rdata=%v", rdata) | ||
| 602 | + resp.Message = "网络错误" | ||
| 603 | + resp.Code = ERROR_SRV_ERROR | ||
| 604 | + break | ||
| 605 | + } | ||
| 606 | + uinfo.RealGold = goldnum | ||
| 607 | + | ||
| 608 | + resp.Data.Walletgold = goldnum | ||
| 609 | + resp.Data.Getgoldnum = rdata.Num | ||
| 610 | + //加入排行榜 | ||
| 611 | + SaveUserInfo(uinfo, uniqueuuid) | ||
| 612 | + | ||
| 613 | + resp.Code = ERROR_OK | ||
| 614 | + break | ||
| 615 | + } | ||
| 616 | + | ||
| 617 | + //回包 | ||
| 618 | + respstr, _ := json.Marshal(&resp) | ||
| 619 | + fmt.Fprint(w, string(respstr)) | ||
| 620 | +} | ||
| 621 | + | ||
| 574 | 622 | ||
| 575 | func HandlerQueryrankinfo(w http.ResponseWriter, data string, uuid int) { | 623 | func HandlerQueryrankinfo(w http.ResponseWriter, data string, uuid int) { |
| 576 | SetHeader(w) | 624 | SetHeader(w) |