Commit 07a9037d122baf82eb189dcb11c50a2ddee64556

Authored by 陆恒
1 parent 376a3e4d
Exists in master

提交

src/HttpServer/logic/constdef.go
... ... @@ -69,6 +69,8 @@ const (
69 69 FLYBOXNUMLIMIT = 6 //飞天宝箱每日次数限制
70 70 EMPTYBOXLIMIT = 20 //空格宝箱每日限制次数
71 71 SHAKETIMELIMIT = 20 //摇一摇每日次数
  72 + HITCATLIMIT = 5 //撸猫次数限制
  73 + HITCATMULT = 300 //撸猫收益
72 74 )
73 75  
74 76 var CATNAMELIST = []string{
... ...
src/HttpServer/logic/datadef.go
... ... @@ -110,6 +110,7 @@ type GetUserDataData struct {
110 110 Now int `json:"now"`
111 111 TimingRewardTimes int `json:"timingRewardTimes"`
112 112 Shakeleftcnt int `json:"shakeleftcnt"`
  113 + Hitcatleftcnt int `json:"hitcatleftcnt"`
113 114 }
114 115  
115 116 type GetUserDataResp struct {
... ... @@ -1045,6 +1046,7 @@ type UserData struct {
1045 1046 EmptyBoxLeftTime int //空格宝箱生意领取次数
1046 1047 IsResetToday int //当天中午十二点是否重置 0表示未 1表示已重置
1047 1048 ShakeTime int //摇一摇次数
  1049 + HitCatTime int //撸猫剩余次数
1048 1050 WaitFetchLv []int //当前可领取的等级红包等级
1049 1051 WaitFetchList []LimitListDesc //待领取的分红猫列表 领取完删除
1050 1052 CatShopInfo CatShopData //猫咖门店数据
... ...
src/HttpServer/logic/function.go
... ... @@ -558,6 +558,7 @@ func (u *UserData) HandlePassDay() {
558 558 u.LeftOfflineTimes = OFFLINETIMESLIMIT
559 559 u.EmptyBoxLeftTime = EMPTYBOXLIMIT
560 560 u.ShakeTime = SHAKETIMELIMIT
  561 + u.HitCatTime = HITCATLIMIT
561 562  
562 563 u.IsResetToday = 0
563 564 /*randint := rand.Intn(100)
... ... @@ -644,6 +645,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) {
644 645 udata.LeftOfflineTimes = OFFLINETIMESLIMIT
645 646 udata.EmptyBoxLeftTime = EMPTYBOXLIMIT
646 647 udata.ShakeTime = SHAKETIMELIMIT
  648 + udata.HitCatTime = HITCATLIMIT
647 649 /*randint := rand.Intn(100)
648 650 floatval := float32(randint) / 100
649 651 udata.TodayZhaocai = 180 + floatval*/
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -190,6 +190,7 @@ func startServerHttpServe() {
190 190 http.HandleFunc("/api/happycat/quertlvredbag", Quertlvredbag) // 上报玩家消耗次数(摇一摇)
191 191 http.HandleFunc("/api/happycat/fetchlvredbag", Fetchlvredbag) // 请求领取等级红包
192 192 http.HandleFunc("/api/happycat/shakeaddgold", Shakeaddgold) // 摇一摇增加金币
  193 + http.HandleFunc("/api/happycat/hitcataddgold", Hitcataddgold) // 撸猫增加金币
193 194  
194 195 /////---------------------------------------------------------------------old
195 196 //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置
... ... @@ -1201,6 +1202,24 @@ func AddAd(w http.ResponseWriter, r *http.Request) {
1201 1202 HandlerAddAd(w, s, Uuid)
1202 1203 }
1203 1204  
  1205 +func Hitcataddgold(w http.ResponseWriter, r *http.Request) {
  1206 + Uuid := 0
  1207 + if len(r.Header) > 0 {
  1208 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1209 + }
  1210 + if Uuid == 0 {
  1211 + SetHeader(w)
  1212 + return
  1213 + }
  1214 + result, _ := ioutil.ReadAll(r.Body)
  1215 + r.Body.Close()
  1216 +
  1217 + s := string(result)
  1218 + logger.Info("Hitcataddgold , body:%v,uuid=%v", s, Uuid)
  1219 +
  1220 + HandlerHitcataddgold(w, s, Uuid)
  1221 +}
  1222 +
1204 1223 func Shakeaddgold(w http.ResponseWriter, r *http.Request) {
1205 1224 Uuid := 0
1206 1225 if len(r.Header) > 0 {
... ...
src/HttpServer/logic/logic.go
... ... @@ -628,6 +628,38 @@ func HandlerGetflyboxreward(w http.ResponseWriter, data string, uuid int) {
628 628 fmt.Fprint(w, string(respstr))
629 629 }
630 630  
  631 +func HandlerHitcataddgold(w http.ResponseWriter, data string, uuid int) {
  632 + SetHeader(w)
  633 + var resp ShakeaddgoldResp
  634 + resp.Code = 0
  635 + resp.Message = "success"
  636 + for {
  637 +
  638 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  639 + if err != nil || uinfo == nil {
  640 + logger.Error("HandlerHitcataddgold getuserinfo failed=%v", err)
  641 + resp.Code = 1
  642 + resp.Message = "get userinfo failed"
  643 + break
  644 + }
  645 +
  646 + addgold := HITCATMULT * uinfo.Goldrate
  647 + uinfo.Gold += addgold
  648 +
  649 + resp.Data.Goldnum = addgold
  650 + resp.Data.Goldsumnum = uinfo.Gold
  651 + resp.Code = 0
  652 + //保存
  653 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
  654 +
  655 + break
  656 +
  657 + }
  658 + //回包
  659 + respstr, _ := json.Marshal(&resp)
  660 + fmt.Fprint(w, string(respstr))
  661 +}
  662 +
631 663 func HandlerShakeaddgold(w http.ResponseWriter, data string, uuid int) {
632 664 SetHeader(w)
633 665 var resp ShakeaddgoldResp
... ...