Commit 799b7b2a5b02fd5ce9322a739f22b72b9c08c5c1

Authored by 陆恒
1 parent 738472be
Exists in master

提交

src/HttpServer/logic/constdef.go
... ... @@ -56,6 +56,7 @@ const (
56 56 TIMEINGREWARDLIMIT = 8 //整点奖励限制次数
57 57 OFFLINETIMESLIMIT = 10 //离线奖励领取次数限制
58 58 WATCHADSGOLDLRATE = 7200 //看广告领取金币的秒数
  59 + SHAKEGOLDMULT = 300 //摇一摇金币秒数
59 60 ZHENGHOURMULT = 600 //整点领取金币的秒数
60 61 DRAWTICKETNUM = 3 //每日送的抽奖券次数
61 62 DRAWTICKETGETLIMIT = 5 //每日抽奖券获得次数
... ...
src/HttpServer/logic/datadef.go
... ... @@ -582,6 +582,17 @@ type FetchlvredbagResp struct {
582 582 Data FetchlvredbagData `json:"data"`
583 583 }
584 584  
  585 +type ShakeaddgoldData struct {
  586 + Goldnum int64 `json:"goldnum"`
  587 + Goldsumnum int64 `json:"goldsumnum"`
  588 +}
  589 +
  590 +type ShakeaddgoldResp struct {
  591 + Code int `json:"code"`
  592 + Message string `json:"message"`
  593 + Data ShakeaddgoldData `json:"data"`
  594 +}
  595 +
585 596 type QueryWareHouseData struct {
586 597 CatList []int `json:"catList"`
587 598 CatCapacity int `json:"catCapacity"`
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -189,6 +189,7 @@ func startServerHttpServe() {
189 189 http.HandleFunc("/api/happycat/uploadusercost", Uploadusercost) // 上报玩家消耗次数(摇一摇)
190 190 http.HandleFunc("/api/happycat/quertlvredbag", Quertlvredbag) // 上报玩家消耗次数(摇一摇)
191 191 http.HandleFunc("/api/happycat/fetchlvredbag", Fetchlvredbag) // 请求领取等级红包
  192 + http.HandleFunc("/api/happycat/shakeaddgold", Shakeaddgold) // 摇一摇增加金币
192 193  
193 194 /////---------------------------------------------------------------------old
194 195 //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置
... ... @@ -1199,6 +1200,24 @@ func AddAd(w http.ResponseWriter, r *http.Request) {
1199 1200 HandlerAddAd(w, s, Uuid)
1200 1201 }
1201 1202  
  1203 +func Shakeaddgold(w http.ResponseWriter, r *http.Request) {
  1204 + Uuid := 0
  1205 + if len(r.Header) > 0 {
  1206 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1207 + }
  1208 + if Uuid == 0 {
  1209 + SetHeader(w)
  1210 + return
  1211 + }
  1212 + result, _ := ioutil.ReadAll(r.Body)
  1213 + r.Body.Close()
  1214 +
  1215 + s := string(result)
  1216 + logger.Info("Shakeaddgold , body:%v,uuid=%v", s, Uuid)
  1217 +
  1218 + HandlerShakeaddgold(w, s, Uuid)
  1219 +}
  1220 +
1202 1221 func Fetchlvredbag(w http.ResponseWriter, r *http.Request) {
1203 1222 Uuid := 0
1204 1223 if len(r.Header) > 0 {
... ...
src/HttpServer/logic/logic.go
... ... @@ -627,6 +627,38 @@ func HandlerGetflyboxreward(w http.ResponseWriter, data string, uuid int) {
627 627 fmt.Fprint(w, string(respstr))
628 628 }
629 629  
  630 +func HandlerShakeaddgold(w http.ResponseWriter, data string, uuid int) {
  631 + SetHeader(w)
  632 + var resp ShakeaddgoldResp
  633 + resp.Code = 0
  634 + resp.Message = "success"
  635 + for {
  636 +
  637 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  638 + if err != nil || uinfo == nil {
  639 + logger.Error("HandlerFetchlvredbag getuserinfo failed=%v", err)
  640 + resp.Code = 1
  641 + resp.Message = "get userinfo failed"
  642 + break
  643 + }
  644 +
  645 + addgold := SHAKEGOLDMULT * uinfo.Goldrate
  646 + uinfo.Gold += addgold
  647 +
  648 + resp.Data.Goldnum = addgold
  649 + resp.Data.Goldsumnum = uinfo.Gold
  650 + resp.Code = 0
  651 + //保存
  652 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
  653 +
  654 + break
  655 +
  656 + }
  657 + //回包
  658 + respstr, _ := json.Marshal(&resp)
  659 + fmt.Fprint(w, string(respstr))
  660 +}
  661 +
630 662 func HandlerFetchlvredbag(w http.ResponseWriter, data string, uuid int) {
631 663 SetHeader(w)
632 664 var resp FetchlvredbagResp
... ...