From 9a9b560cd502a41e6621f4a8ee520ffcefa78d65 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Fri, 19 Jun 2020 15:41:13 +0800 Subject: [PATCH] 提交新的接口 --- src/HttpServer/logic/datadef.go | 11 +++++++++++ src/HttpServer/logic/httpserver.go | 19 +++++++++++++++++++ src/HttpServer/logic/logic.go | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 0 deletions(-) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 55c4149..f8e381d 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -175,6 +175,17 @@ type GetboxrewardResp struct { Data GetboxrewardData `json:"data"` } +type QueryemptyboxData struct { + Money float32 `json:"money"` + Goldnum int64 `json:"goldnum"` +} + +type QueryemptyboxResp struct { + Code int `json:"code"` + Message string `json:"message"` + Data QueryemptyboxData `json:"data"` +} + type WithDrawRecord struct { Coin int `json:"coin"` Create_time int `json:"create_time"` diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 4f81bc9..1e38970 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -154,6 +154,7 @@ func startServerHttpServe() { //新增的接口 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包 + http.HandleFunc("/api/happycat/queryemptybox", Queryemptybox) //请求刷空格礼包诗句 http.HandleFunc("/api/happycat/getboxreward", Getboxreward) // 请求领取空格礼包 http.HandleFunc("/api/happycat/getflyboxreward", Getflyboxreward) // 请求领取飞天宝箱 http.HandleFunc("/api/happycat/querygetcashinfo", Querygetcashinfo) // 请求提现档位信息 @@ -1243,6 +1244,24 @@ func Getflyboxreward(w http.ResponseWriter, r *http.Request) { HandlerGetflyboxreward(w, s, Uuid) } +func Queryemptybox(w http.ResponseWriter, r *http.Request) { + Uuid := 0 + if len(r.Header) > 0 { + Uuid, _ = strconv.Atoi(r.Header.Get("uid")) + } + if Uuid == 0 { + SetHeader(w) + return + } + result, _ := ioutil.ReadAll(r.Body) + r.Body.Close() + + s := string(result) + logger.Info("Queryemptybox , body:%v,uuid=%v", s, Uuid) + + HandlerQueryemptybox(w, s, Uuid) +} + func Getboxreward(w http.ResponseWriter, r *http.Request) { Uuid := 0 if len(r.Header) > 0 { diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 46fccc2..08f3c62 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -809,6 +809,57 @@ func HandlerQuerygetcashinfo(w http.ResponseWriter, data string, uuid int) { fmt.Fprint(w, string(respstr)) } +func HandlerQueryemptybox(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp QueryemptyboxResp + resp.Code = 0 + resp.Message = "success" + + for { + + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) + if err != nil || uinfo == nil { + logger.Error("HandlerQueryemptybox getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + if uinfo.PosInfo[BOXGIFTPOS].Cat < BOXGIFTEXTRA { + //没有存在合法的空格礼物 + logger.Error("HandlerQueryemptybox empty failed=%v", err) + resp.Code = 1 + resp.Message = "empty" + break + } + + boxid := uinfo.PosInfo[BOXGIFTPOS].Cat - BOXGIFTEXTRA + cfg := jsonconf.GetGiftConfif(boxid) + if cfg == nil { + logger.Error("HandlerQueryemptybox getcfgfailed failed=%v", err) + resp.Code = 1 + resp.Message = "getcfgfailed" + break + } + + if cfg.Ttype == 1 { + //金币 + resp.Data.Goldnum = int64(float32(uinfo.Goldrate) * cfg.Time) + } else if cfg.Ttype == 2 { + //红包 + resp.Data.Money = cfg.Time + + } + + //SaveUserInfo(uinfo, strconv.Itoa(uuid)) + + break + } + + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) +} + func HandlerGetboxreward(w http.ResponseWriter, data string, uuid int) { SetHeader(w) var resp GetboxrewardResp -- libgit2 0.21.0