Commit 9a9b560cd502a41e6621f4a8ee520ffcefa78d65

Authored by 陆恒
1 parent 4dd5b6e4
Exists in master

提交新的接口

src/HttpServer/logic/datadef.go
@@ -175,6 +175,17 @@ type GetboxrewardResp struct { @@ -175,6 +175,17 @@ type GetboxrewardResp struct {
175 Data GetboxrewardData `json:"data"` 175 Data GetboxrewardData `json:"data"`
176 } 176 }
177 177
  178 +type QueryemptyboxData struct {
  179 + Money float32 `json:"money"`
  180 + Goldnum int64 `json:"goldnum"`
  181 +}
  182 +
  183 +type QueryemptyboxResp struct {
  184 + Code int `json:"code"`
  185 + Message string `json:"message"`
  186 + Data QueryemptyboxData `json:"data"`
  187 +}
  188 +
178 type WithDrawRecord struct { 189 type WithDrawRecord struct {
179 Coin int `json:"coin"` 190 Coin int `json:"coin"`
180 Create_time int `json:"create_time"` 191 Create_time int `json:"create_time"`
src/HttpServer/logic/httpserver.go
@@ -154,6 +154,7 @@ func startServerHttpServe() { @@ -154,6 +154,7 @@ func startServerHttpServe() {
154 //新增的接口 154 //新增的接口
155 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包 155 http.HandleFunc("/api/happycat/getrandredbag", Getrandredbag) //领取随机红包
156 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包 156 http.HandleFunc("/api/happycat/generatebox", Generatebox) //请求刷出空格礼包
  157 + http.HandleFunc("/api/happycat/queryemptybox", Queryemptybox) //请求刷空格礼包诗句
157 http.HandleFunc("/api/happycat/getboxreward", Getboxreward) // 请求领取空格礼包 158 http.HandleFunc("/api/happycat/getboxreward", Getboxreward) // 请求领取空格礼包
158 http.HandleFunc("/api/happycat/getflyboxreward", Getflyboxreward) // 请求领取飞天宝箱 159 http.HandleFunc("/api/happycat/getflyboxreward", Getflyboxreward) // 请求领取飞天宝箱
159 http.HandleFunc("/api/happycat/querygetcashinfo", Querygetcashinfo) // 请求提现档位信息 160 http.HandleFunc("/api/happycat/querygetcashinfo", Querygetcashinfo) // 请求提现档位信息
@@ -1243,6 +1244,24 @@ func Getflyboxreward(w http.ResponseWriter, r *http.Request) { @@ -1243,6 +1244,24 @@ func Getflyboxreward(w http.ResponseWriter, r *http.Request) {
1243 HandlerGetflyboxreward(w, s, Uuid) 1244 HandlerGetflyboxreward(w, s, Uuid)
1244 } 1245 }
1245 1246
  1247 +func Queryemptybox(w http.ResponseWriter, r *http.Request) {
  1248 + Uuid := 0
  1249 + if len(r.Header) > 0 {
  1250 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1251 + }
  1252 + if Uuid == 0 {
  1253 + SetHeader(w)
  1254 + return
  1255 + }
  1256 + result, _ := ioutil.ReadAll(r.Body)
  1257 + r.Body.Close()
  1258 +
  1259 + s := string(result)
  1260 + logger.Info("Queryemptybox , body:%v,uuid=%v", s, Uuid)
  1261 +
  1262 + HandlerQueryemptybox(w, s, Uuid)
  1263 +}
  1264 +
1246 func Getboxreward(w http.ResponseWriter, r *http.Request) { 1265 func Getboxreward(w http.ResponseWriter, r *http.Request) {
1247 Uuid := 0 1266 Uuid := 0
1248 if len(r.Header) > 0 { 1267 if len(r.Header) > 0 {
src/HttpServer/logic/logic.go
@@ -809,6 +809,57 @@ func HandlerQuerygetcashinfo(w http.ResponseWriter, data string, uuid int) { @@ -809,6 +809,57 @@ func HandlerQuerygetcashinfo(w http.ResponseWriter, data string, uuid int) {
809 fmt.Fprint(w, string(respstr)) 809 fmt.Fprint(w, string(respstr))
810 } 810 }
811 811
  812 +func HandlerQueryemptybox(w http.ResponseWriter, data string, uuid int) {
  813 + SetHeader(w)
  814 + var resp QueryemptyboxResp
  815 + resp.Code = 0
  816 + resp.Message = "success"
  817 +
  818 + for {
  819 +
  820 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  821 + if err != nil || uinfo == nil {
  822 + logger.Error("HandlerQueryemptybox getuserinfo failed=%v", err)
  823 + resp.Code = 1
  824 + resp.Message = "get userinfo failed"
  825 + break
  826 + }
  827 + if uinfo.PosInfo[BOXGIFTPOS].Cat < BOXGIFTEXTRA {
  828 + //没有存在合法的空格礼物
  829 + logger.Error("HandlerQueryemptybox empty failed=%v", err)
  830 + resp.Code = 1
  831 + resp.Message = "empty"
  832 + break
  833 + }
  834 +
  835 + boxid := uinfo.PosInfo[BOXGIFTPOS].Cat - BOXGIFTEXTRA
  836 + cfg := jsonconf.GetGiftConfif(boxid)
  837 + if cfg == nil {
  838 + logger.Error("HandlerQueryemptybox getcfgfailed failed=%v", err)
  839 + resp.Code = 1
  840 + resp.Message = "getcfgfailed"
  841 + break
  842 + }
  843 +
  844 + if cfg.Ttype == 1 {
  845 + //金币
  846 + resp.Data.Goldnum = int64(float32(uinfo.Goldrate) * cfg.Time)
  847 + } else if cfg.Ttype == 2 {
  848 + //红包
  849 + resp.Data.Money = cfg.Time
  850 +
  851 + }
  852 +
  853 + //SaveUserInfo(uinfo, strconv.Itoa(uuid))
  854 +
  855 + break
  856 + }
  857 +
  858 + //回包
  859 + respstr, _ := json.Marshal(&resp)
  860 + fmt.Fprint(w, string(respstr))
  861 +}
  862 +
812 func HandlerGetboxreward(w http.ResponseWriter, data string, uuid int) { 863 func HandlerGetboxreward(w http.ResponseWriter, data string, uuid int) {
813 SetHeader(w) 864 SetHeader(w)
814 var resp GetboxrewardResp 865 var resp GetboxrewardResp