From 07a9037d122baf82eb189dcb11c50a2ddee64556 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Tue, 28 Jul 2020 10:23:08 +0800 Subject: [PATCH] 提交 --- src/HttpServer/logic/constdef.go | 2 ++ src/HttpServer/logic/datadef.go | 2 ++ src/HttpServer/logic/function.go | 2 ++ src/HttpServer/logic/httpserver.go | 19 +++++++++++++++++++ src/HttpServer/logic/logic.go | 32 ++++++++++++++++++++++++++++++++ 5 files changed, 57 insertions(+), 0 deletions(-) diff --git a/src/HttpServer/logic/constdef.go b/src/HttpServer/logic/constdef.go index 52bc850..5a4be5a 100644 --- a/src/HttpServer/logic/constdef.go +++ b/src/HttpServer/logic/constdef.go @@ -69,6 +69,8 @@ const ( FLYBOXNUMLIMIT = 6 //飞天宝箱每日次数限制 EMPTYBOXLIMIT = 20 //空格宝箱每日限制次数 SHAKETIMELIMIT = 20 //摇一摇每日次数 + HITCATLIMIT = 5 //撸猫次数限制 + HITCATMULT = 300 //撸猫收益 ) var CATNAMELIST = []string{ diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index 3305624..4330486 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -110,6 +110,7 @@ type GetUserDataData struct { Now int `json:"now"` TimingRewardTimes int `json:"timingRewardTimes"` Shakeleftcnt int `json:"shakeleftcnt"` + Hitcatleftcnt int `json:"hitcatleftcnt"` } type GetUserDataResp struct { @@ -1045,6 +1046,7 @@ type UserData struct { EmptyBoxLeftTime int //空格宝箱生意领取次数 IsResetToday int //当天中午十二点是否重置 0表示未 1表示已重置 ShakeTime int //摇一摇次数 + HitCatTime int //撸猫剩余次数 WaitFetchLv []int //当前可领取的等级红包等级 WaitFetchList []LimitListDesc //待领取的分红猫列表 领取完删除 CatShopInfo CatShopData //猫咖门店数据 diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 0830dce..770a19b 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -558,6 +558,7 @@ func (u *UserData) HandlePassDay() { u.LeftOfflineTimes = OFFLINETIMESLIMIT u.EmptyBoxLeftTime = EMPTYBOXLIMIT u.ShakeTime = SHAKETIMELIMIT + u.HitCatTime = HITCATLIMIT u.IsResetToday = 0 /*randint := rand.Intn(100) @@ -644,6 +645,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) { udata.LeftOfflineTimes = OFFLINETIMESLIMIT udata.EmptyBoxLeftTime = EMPTYBOXLIMIT udata.ShakeTime = SHAKETIMELIMIT + udata.HitCatTime = HITCATLIMIT /*randint := rand.Intn(100) floatval := float32(randint) / 100 udata.TodayZhaocai = 180 + floatval*/ diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index 261460e..7ef6eb0 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -190,6 +190,7 @@ func startServerHttpServe() { http.HandleFunc("/api/happycat/quertlvredbag", Quertlvredbag) // 上报玩家消耗次数(摇一摇) http.HandleFunc("/api/happycat/fetchlvredbag", Fetchlvredbag) // 请求领取等级红包 http.HandleFunc("/api/happycat/shakeaddgold", Shakeaddgold) // 摇一摇增加金币 + http.HandleFunc("/api/happycat/hitcataddgold", Hitcataddgold) // 撸猫增加金币 /////---------------------------------------------------------------------old //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置 @@ -1201,6 +1202,24 @@ func AddAd(w http.ResponseWriter, r *http.Request) { HandlerAddAd(w, s, Uuid) } +func Hitcataddgold(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("Hitcataddgold , body:%v,uuid=%v", s, Uuid) + + HandlerHitcataddgold(w, s, Uuid) +} + func Shakeaddgold(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 f1b074e..57593ed 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -628,6 +628,38 @@ func HandlerGetflyboxreward(w http.ResponseWriter, data string, uuid int) { fmt.Fprint(w, string(respstr)) } +func HandlerHitcataddgold(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("HandlerHitcataddgold getuserinfo failed=%v", err) + resp.Code = 1 + resp.Message = "get userinfo failed" + break + } + + addgold := HITCATMULT * 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 HandlerShakeaddgold(w http.ResponseWriter, data string, uuid int) { SetHeader(w) var resp ShakeaddgoldResp -- libgit2 0.21.0