Commit 3e479fb8173994b3b014bfbc72b7389ee83d6b4d
1 parent
dc87470e
Exists in
master
提交接口
Showing
5 changed files
with
137 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/constdef.go
src/HttpServer/logic/datadef.go
| ... | ... | @@ -189,6 +189,27 @@ type LimitCatListResp struct { |
| 189 | 189 | Data []LimitCatListData `json:"data"` |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | +type QueryTurntableData struct { | |
| 193 | + TicketCount int `json:"ticketCount"` | |
| 194 | + LeftTime int `json:"leftTime"` | |
| 195 | + LimitTicket int `json:"limitTicket"` | |
| 196 | +} | |
| 197 | + | |
| 198 | +type QueryTurntableResp struct { | |
| 199 | + Code int `json:"code"` | |
| 200 | + Message string `json:"message"` | |
| 201 | + Data QueryTurntableData `json:"data"` | |
| 202 | +} | |
| 203 | + | |
| 204 | +type AddTicketData struct { | |
| 205 | +} | |
| 206 | + | |
| 207 | +type AddTicketResp struct { | |
| 208 | + Code int `json:"code"` | |
| 209 | + Message string `json:"message"` | |
| 210 | + Data AddTicketData `json:"data"` | |
| 211 | +} | |
| 212 | + | |
| 192 | 213 | type AcclecteBoxResp struct { |
| 193 | 214 | Code int `json:"code"` |
| 194 | 215 | Message string `json:"message"` |
| ... | ... | @@ -561,6 +582,8 @@ type UserData struct { |
| 561 | 582 | StartDoubleTime int //开始双倍时间 |
| 562 | 583 | DoubleLeftTimes int //剩余加速金币次数 |
| 563 | 584 | GetWatchAdsGoldTime int //看广告领金币次数 |
| 585 | + DrawTicket int //抽奖券次数 | |
| 586 | + DrawTicketTimes int //剩余增加抽奖券次数 | |
| 564 | 587 | IsAuto int //当前是否自动合成 |
| 565 | 588 | IsBoxAcc int //是否处于加速生成箱子状态 |
| 566 | 589 | RandGiftNum int //当前剩余空投猫粮次数 | ... | ... |
src/HttpServer/logic/function.go
| ... | ... | @@ -107,6 +107,8 @@ func (u *UserData) HandlePassDay() { |
| 107 | 107 | //跨天了 |
| 108 | 108 | u.DoubleLeftTimes = ACCGOLDRATELIMIT |
| 109 | 109 | u.GetWatchAdsGoldTime = WATCHADSGOLDLIMIT |
| 110 | + u.DrawTicket = DRAWTICKETNUM | |
| 111 | + u.DoubleLeftTimes = DRAWTICKETGETLIMIT | |
| 110 | 112 | } |
| 111 | 113 | |
| 112 | 114 | u.LastLoginTime = int(nowtime.Unix()) |
| ... | ... | @@ -163,6 +165,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { |
| 163 | 165 | udata.GetWatchAdsGoldTime = WATCHADSGOLDLIMIT |
| 164 | 166 | udata.RegTime = int(time.Now().Unix()) |
| 165 | 167 | udata.LastLoginTime = int(time.Now().Unix()) |
| 168 | + udata.DrawTicket = DRAWTICKETNUM | |
| 169 | + udata.DoubleLeftTimes = DRAWTICKETGETLIMIT | |
| 166 | 170 | |
| 167 | 171 | //初始化16个猫爬架 |
| 168 | 172 | for i := 0; i < 16; i++ { | ... | ... |
src/HttpServer/logic/httpserver.go
| ... | ... | @@ -41,6 +41,8 @@ func startServerHttpServe() { |
| 41 | 41 | http.HandleFunc("/api/home/compose", Compose) //五猫合成 |
| 42 | 42 | http.HandleFunc("/api/home/recvRedCat", RecvRedCat) //红包猫领取 |
| 43 | 43 | http.HandleFunc("/api/home/limitCatList", LimitCatList) //分红猫列表 |
| 44 | + http.HandleFunc("/api/turntable/index", QueryTurntable) //转盘主页 | |
| 45 | + http.HandleFunc("/api/turntable/addTicket", AddTicket) //增加抽奖券 | |
| 44 | 46 | |
| 45 | 47 | /////---------------------------------------------------------------------old |
| 46 | 48 | http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 |
| ... | ... | @@ -635,6 +637,42 @@ func RedCatList(w http.ResponseWriter, r *http.Request) { |
| 635 | 637 | //HandlerRecvTimingReward(w, s, Uuid) |
| 636 | 638 | } |
| 637 | 639 | |
| 640 | +func AddTicket(w http.ResponseWriter, r *http.Request) { | |
| 641 | + Uuid := 0 | |
| 642 | + if len(r.Header) > 0 { | |
| 643 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | |
| 644 | + } | |
| 645 | + if Uuid == 0 { | |
| 646 | + SetHeader(w) | |
| 647 | + return | |
| 648 | + } | |
| 649 | + result, _ := ioutil.ReadAll(r.Body) | |
| 650 | + r.Body.Close() | |
| 651 | + | |
| 652 | + s := string(result) | |
| 653 | + logger.Info("AddTicket , body:%v,uuid=%v", s, Uuid) | |
| 654 | + | |
| 655 | + HandlerAddTicket(w, s, Uuid) | |
| 656 | +} | |
| 657 | + | |
| 658 | +func QueryTurntable(w http.ResponseWriter, r *http.Request) { | |
| 659 | + Uuid := 0 | |
| 660 | + if len(r.Header) > 0 { | |
| 661 | + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) | |
| 662 | + } | |
| 663 | + if Uuid == 0 { | |
| 664 | + SetHeader(w) | |
| 665 | + return | |
| 666 | + } | |
| 667 | + result, _ := ioutil.ReadAll(r.Body) | |
| 668 | + r.Body.Close() | |
| 669 | + | |
| 670 | + s := string(result) | |
| 671 | + logger.Info("QueryTurntable , body:%v,uuid=%v", s, Uuid) | |
| 672 | + | |
| 673 | + HandlerQueryTurntable(w, s, Uuid) | |
| 674 | +} | |
| 675 | + | |
| 638 | 676 | func LimitCatList(w http.ResponseWriter, r *http.Request) { |
| 639 | 677 | Uuid := 0 |
| 640 | 678 | if len(r.Header) > 0 { | ... | ... |
src/HttpServer/logic/logic.go
| ... | ... | @@ -403,6 +403,75 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { |
| 403 | 403 | fmt.Fprint(w, string(respstr)) |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | +func HandlerAddTicket(w http.ResponseWriter, data string, uuid int) { | |
| 407 | + SetHeader(w) | |
| 408 | + var resp AddTicketResp | |
| 409 | + resp.Code = 0 | |
| 410 | + resp.Message = "success" | |
| 411 | + | |
| 412 | + for { | |
| 413 | + | |
| 414 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | |
| 415 | + if err != nil || uinfo == nil { | |
| 416 | + logger.Error("HandlerQueryTurntable getuserinfo failed=%v", err) | |
| 417 | + resp.Code = 1 | |
| 418 | + resp.Message = "get userinfo failed" | |
| 419 | + break | |
| 420 | + } | |
| 421 | + | |
| 422 | + if uinfo.DoubleLeftTimes == 0 { | |
| 423 | + logger.Error("HandlerQueryTurntable DoubleLeftTimes failed=%v", err) | |
| 424 | + resp.Code = 1 | |
| 425 | + resp.Message = "DoubleLeftTimes not enough" | |
| 426 | + break | |
| 427 | + } | |
| 428 | + | |
| 429 | + uinfo.DoubleLeftTimes-- | |
| 430 | + uinfo.DrawTicket += 5 | |
| 431 | + if uinfo.DrawTicket > DRAWTICKETNUMLIMIT { | |
| 432 | + uinfo.DrawTicket = DRAWTICKETNUMLIMIT | |
| 433 | + } | |
| 434 | + | |
| 435 | + resp.Code = 0 | |
| 436 | + break | |
| 437 | + } | |
| 438 | + | |
| 439 | + //回包 | |
| 440 | + respstr, _ := json.Marshal(&resp) | |
| 441 | + fmt.Fprint(w, string(respstr)) | |
| 442 | + | |
| 443 | +} | |
| 444 | + | |
| 445 | +func HandlerQueryTurntable(w http.ResponseWriter, data string, uuid int) { | |
| 446 | + SetHeader(w) | |
| 447 | + var resp QueryTurntableResp | |
| 448 | + resp.Code = 0 | |
| 449 | + resp.Message = "success" | |
| 450 | + | |
| 451 | + for { | |
| 452 | + | |
| 453 | + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) | |
| 454 | + if err != nil || uinfo == nil { | |
| 455 | + logger.Error("HandlerQueryTurntable getuserinfo failed=%v", err) | |
| 456 | + resp.Code = 1 | |
| 457 | + resp.Message = "get userinfo failed" | |
| 458 | + break | |
| 459 | + } | |
| 460 | + | |
| 461 | + resp.Data.TicketCount = uinfo.DrawTicket | |
| 462 | + resp.Data.LeftTime = uinfo.DoubleLeftTimes | |
| 463 | + resp.Data.LimitTicket = DRAWTICKETNUMLIMIT | |
| 464 | + | |
| 465 | + resp.Code = 0 | |
| 466 | + break | |
| 467 | + } | |
| 468 | + | |
| 469 | + //回包 | |
| 470 | + respstr, _ := json.Marshal(&resp) | |
| 471 | + fmt.Fprint(w, string(respstr)) | |
| 472 | + | |
| 473 | +} | |
| 474 | + | |
| 406 | 475 | func HandlerLimitCatList(w http.ResponseWriter, data string, uuid int) { |
| 407 | 476 | SetHeader(w) |
| 408 | 477 | var resp LimitCatListResp | ... | ... |