diff --git a/src/HttpServer/logic/constdef.go b/src/HttpServer/logic/constdef.go index 39f975c..52bc850 100644 --- a/src/HttpServer/logic/constdef.go +++ b/src/HttpServer/logic/constdef.go @@ -56,6 +56,7 @@ const ( TIMEINGREWARDLIMIT = 8 //整点奖励限制次数 OFFLINETIMESLIMIT = 10 //离线奖励领取次数限制 WATCHADSGOLDLRATE = 7200 //看广告领取金币的秒数 + SHAKEGOLDMULT = 300 //摇一摇金币秒数 ZHENGHOURMULT = 600 //整点领取金币的秒数 DRAWTICKETNUM = 3 //每日送的抽奖券次数 DRAWTICKETGETLIMIT = 5 //每日抽奖券获得次数 diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 111f47b..3305624 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -582,6 +582,17 @@ type FetchlvredbagResp struct { Data FetchlvredbagData `json:"data"` } +type ShakeaddgoldData struct { + Goldnum int64 `json:"goldnum"` + Goldsumnum int64 `json:"goldsumnum"` +} + +type ShakeaddgoldResp struct { + Code int `json:"code"` + Message string `json:"message"` + Data ShakeaddgoldData `json:"data"` +} + type QueryWareHouseData struct { CatList []int `json:"catList"` CatCapacity int `json:"catCapacity"` diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index ecc5a1e..43b2e16 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -189,6 +189,7 @@ func startServerHttpServe() { http.HandleFunc("/api/happycat/uploadusercost", Uploadusercost) // 上报玩家消耗次数(摇一摇) http.HandleFunc("/api/happycat/quertlvredbag", Quertlvredbag) // 上报玩家消耗次数(摇一摇) http.HandleFunc("/api/happycat/fetchlvredbag", Fetchlvredbag) // 请求领取等级红包 + http.HandleFunc("/api/happycat/shakeaddgold", Shakeaddgold) // 摇一摇增加金币 /////---------------------------------------------------------------------old //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 @@ -1199,6 +1200,24 @@ func AddAd(w http.ResponseWriter, r *http.Request) { HandlerAddAd(w, s, Uuid) } +func Shakeaddgold(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("Shakeaddgold , body:%v,uuid=%v", s, Uuid) + + HandlerShakeaddgold(w, s, Uuid) +} + func Fetchlvredbag(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 9bf4868..c7123c0 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -627,6 +627,38 @@ func HandlerGetflyboxreward(w http.ResponseWriter, data string, uuid int) { fmt.Fprint(w, string(respstr)) } +func HandlerShakeaddgold(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp ShakeaddgoldResp + resp.Code = 0 + resp.Message = "success" + for { + + uinfo, err := GetUserInfo(strconv.Itoa(uuid)) + if err != nil || uinfo == nil { + logger.Error("HandlerFetchlvredbag getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + + addgold := SHAKEGOLDMULT * uinfo.Goldrate + uinfo.Gold += addgold + + resp.Data.Goldnum = addgold + resp.Data.Goldsumnum = uinfo.Gold + resp.Code = 0 + //保存 + SaveUserInfo(uinfo, strconv.Itoa(uuid)) + + break + + } + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) +} + func HandlerFetchlvredbag(w http.ResponseWriter, data string, uuid int) { SetHeader(w) var resp FetchlvredbagResp -- libgit2 0.21.0