Commit 738472bece5330aff8dfee52cd6564e1e8c59f8a

Authored by 陆恒
1 parent 62901e9a
Exists in master

增加新的接口

src/HttpServer/jsonconf/CatConfig.json
... ... @@ -8,7 +8,8 @@
8 8 "gold_get": "1",
9 9 "ratio": 1.07,
10 10 "increse_limit": 100,
11   - "interval": 1
  11 + "interval": 1,
  12 + "redpacket": 0
12 13 },
13 14 {
14 15 "id": 2,
... ... @@ -19,7 +20,8 @@
19 20 "gold_get": "3",
20 21 "ratio": 1.1,
21 22 "increse_limit": 70,
22   - "interval": 1
  23 + "interval": 1,
  24 + "redpacket": 1.2
23 25 },
24 26 {
25 27 "id": 3,
... ... @@ -30,7 +32,8 @@
30 32 "gold_get": "7",
31 33 "ratio": 1.12,
32 34 "increse_limit": 60,
33   - "interval": 1
  35 + "interval": 1,
  36 + "redpacket": 1.2
34 37 },
35 38 {
36 39 "id": 4,
... ... @@ -41,7 +44,8 @@
41 44 "gold_get": "15",
42 45 "ratio": 1.17,
43 46 "increse_limit": 40,
44   - "interval": 1
  47 + "interval": 1,
  48 + "redpacket": 1.16
45 49 },
46 50 {
47 51 "id": 5,
... ... @@ -52,7 +56,8 @@
52 56 "gold_get": "30",
53 57 "ratio": 1.17,
54 58 "increse_limit": 35,
55   - "interval": 1.5
  59 + "interval": 1.5,
  60 + "redpacket": 1.06
56 61 },
57 62 {
58 63 "id": 6,
... ... @@ -63,7 +68,8 @@
63 68 "gold_get": "61",
64 69 "ratio": 1.17,
65 70 "increse_limit": 30,
66   - "interval": 1.5
  71 + "interval": 1.5,
  72 + "redpacket": 1.02
67 73 },
68 74 {
69 75 "id": 7,
... ... @@ -74,7 +80,8 @@
74 80 "gold_get": "124",
75 81 "ratio": 1.17,
76 82 "increse_limit": 25,
77   - "interval": 1.5
  83 + "interval": 1.5,
  84 + "redpacket": 0.86
78 85 },
79 86 {
80 87 "id": 8,
... ... @@ -85,7 +92,8 @@
85 92 "gold_get": "250",
86 93 "ratio": 1.17,
87 94 "increse_limit": 24,
88   - "interval": 1.5
  95 + "interval": 1.5,
  96 + "redpacket": 0.66
89 97 },
90 98 {
91 99 "id": 9,
... ... @@ -96,7 +104,8 @@
96 104 "gold_get": "504",
97 105 "ratio": 1.17,
98 106 "increse_limit": 23,
99   - "interval": 2
  107 + "interval": 2,
  108 + "redpacket": 0.64
100 109 },
101 110 {
102 111 "id": 10,
... ... @@ -107,7 +116,8 @@
107 116 "gold_get": "1015",
108 117 "ratio": 1.17,
109 118 "increse_limit": 22,
110   - "interval": 2
  119 + "interval": 2,
  120 + "redpacket": 0.86
111 121 },
112 122 {
113 123 "id": 11,
... ... @@ -118,7 +128,8 @@
118 128 "gold_get": "2043",
119 129 "ratio": 1.17,
120 130 "increse_limit": 21,
121   - "interval": 2
  131 + "interval": 2,
  132 + "redpacket": 0.42
122 133 },
123 134 {
124 135 "id": 12,
... ... @@ -129,7 +140,8 @@
129 140 "gold_get": "4112",
130 141 "ratio": 1.17,
131 142 "increse_limit": 20,
132   - "interval": 2
  143 + "interval": 2,
  144 + "redpacket": 0.36
133 145 },
134 146 {
135 147 "id": 13,
... ... @@ -140,7 +152,8 @@
140 152 "gold_get": "8276",
141 153 "ratio": 1.17,
142 154 "increse_limit": 19,
143   - "interval": 2.5
  155 + "interval": 2.5,
  156 + "redpacket": 0.32
144 157 },
145 158 {
146 159 "id": 14,
... ... @@ -151,7 +164,8 @@
151 164 "gold_get": "16657",
152 165 "ratio": 1.17,
153 166 "increse_limit": 18,
154   - "interval": 2.5
  167 + "interval": 2.5,
  168 + "redpacket": 0.28
155 169 },
156 170 {
157 171 "id": 15,
... ... @@ -162,7 +176,8 @@
162 176 "gold_get": "33523",
163 177 "ratio": 1.17,
164 178 "increse_limit": 15,
165   - "interval": 2.5
  179 + "interval": 2.5,
  180 + "redpacket": 0.28
166 181 },
167 182 {
168 183 "id": 16,
... ... @@ -173,7 +188,8 @@
173 188 "gold_get": "67466",
174 189 "ratio": 1.17,
175 190 "increse_limit": 16,
176   - "interval": 2.5
  191 + "interval": 2.5,
  192 + "redpacket": 0.22
177 193 },
178 194 {
179 195 "id": 17,
... ... @@ -184,7 +200,8 @@
184 200 "gold_get": "135778",
185 201 "ratio": 1.17,
186 202 "increse_limit": 15,
187   - "interval": 3
  203 + "interval": 3,
  204 + "redpacket": 0.18
188 205 },
189 206 {
190 207 "id": 18,
... ... @@ -195,7 +212,8 @@
195 212 "gold_get": "273255",
196 213 "ratio": 1.17,
197 214 "increse_limit": 14,
198   - "interval": 3
  215 + "interval": 3,
  216 + "redpacket": 0.48
199 217 },
200 218 {
201 219 "id": 19,
... ... @@ -206,7 +224,8 @@
206 224 "gold_get": "549930",
207 225 "ratio": 1.17,
208 226 "increse_limit": 13,
209   - "interval": 3
  227 + "interval": 3,
  228 + "redpacket": 0.18
210 229 },
211 230 {
212 231 "id": 20,
... ... @@ -217,7 +236,8 @@
217 236 "gold_get": "1106700",
218 237 "ratio": 1.17,
219 238 "increse_limit": 12,
220   - "interval": 3
  239 + "interval": 3,
  240 + "redpacket": 0.18
221 241 },
222 242 {
223 243 "id": 21,
... ... @@ -228,7 +248,8 @@
228 248 "gold_get": "2273000",
229 249 "ratio": 1.17,
230 250 "increse_limit": 11,
231   - "interval": 3.5
  251 + "interval": 3.5,
  252 + "redpacket": 0.18
232 253 },
233 254 {
234 255 "id": 22,
... ... @@ -239,7 +260,8 @@
239 260 "gold_get": "4482600",
240 261 "ratio": 1.17,
241 262 "increse_limit": 10,
242   - "interval": 3.5
  263 + "interval": 3.5,
  264 + "redpacket": 0.18
243 265 },
244 266 {
245 267 "id": 23,
... ... @@ -250,7 +272,8 @@
250 272 "gold_get": "9021200",
251 273 "ratio": 1.17,
252 274 "increse_limit": 9,
253   - "interval": 3.5
  275 + "interval": 3.5,
  276 + "redpacket": 0.18
254 277 },
255 278 {
256 279 "id": 24,
... ... @@ -261,7 +284,8 @@
261 284 "gold_get": "18155000",
262 285 "ratio": 1.17,
263 286 "increse_limit": 8,
264   - "interval": 3.5
  287 + "interval": 3.5,
  288 + "redpacket": 0.18
265 289 },
266 290 {
267 291 "id": 25,
... ... @@ -272,7 +296,8 @@
272 296 "gold_get": "36538000",
273 297 "ratio": 1.17,
274 298 "increse_limit": 8,
275   - "interval": 4
  299 + "interval": 4,
  300 + "redpacket": 0.18
276 301 },
277 302 {
278 303 "id": 26,
... ... @@ -283,7 +308,8 @@
283 308 "gold_get": "73533000",
284 309 "ratio": 1.17,
285 310 "increse_limit": 8,
286   - "interval": 4
  311 + "interval": 4,
  312 + "redpacket": 0.18
287 313 },
288 314 {
289 315 "id": 27,
... ... @@ -294,7 +320,8 @@
294 320 "gold_get": "147990000",
295 321 "ratio": 1.17,
296 322 "increse_limit": 8,
297   - "interval": 4
  323 + "interval": 4,
  324 + "redpacket": 0.18
298 325 },
299 326 {
300 327 "id": 28,
... ... @@ -305,7 +332,8 @@
305 332 "gold_get": "297830000",
306 333 "ratio": 1.17,
307 334 "increse_limit": 8,
308   - "interval": 4
  335 + "interval": 4,
  336 + "redpacket": 0.18
309 337 },
310 338 {
311 339 "id": 29,
... ... @@ -316,7 +344,8 @@
316 344 "gold_get": "599380000",
317 345 "ratio": 1.17,
318 346 "increse_limit": 8,
319   - "interval": 4.5
  347 + "interval": 4.5,
  348 + "redpacket": 0.18
320 349 },
321 350 {
322 351 "id": 30,
... ... @@ -327,7 +356,8 @@
327 356 "gold_get": "1206300000",
328 357 "ratio": 1.17,
329 358 "increse_limit": 8,
330   - "interval": 4.5
  359 + "interval": 4.5,
  360 + "redpacket": 0.18
331 361 },
332 362 {
333 363 "id": 31,
... ... @@ -338,7 +368,8 @@
338 368 "gold_get": "2427600000",
339 369 "ratio": 1.17,
340 370 "increse_limit": 8,
341   - "interval": 4.5
  371 + "interval": 4.5,
  372 + "redpacket": 0.18
342 373 },
343 374 {
344 375 "id": 32,
... ... @@ -349,7 +380,8 @@
349 380 "gold_get": "4885600000",
350 381 "ratio": 1.17,
351 382 "increse_limit": 8,
352   - "interval": 4.5
  383 + "interval": 4.5,
  384 + "redpacket": 0.18
353 385 },
354 386 {
355 387 "id": 33,
... ... @@ -360,7 +392,8 @@
360 392 "gold_get": "9832400000",
361 393 "ratio": 1.17,
362 394 "increse_limit": 8,
363   - "interval": 5
  395 + "interval": 5,
  396 + "redpacket": 0.18
364 397 },
365 398 {
366 399 "id": 34,
... ... @@ -371,7 +404,8 @@
371 404 "gold_get": "19788000000",
372 405 "ratio": 1.17,
373 406 "increse_limit": 8,
374   - "interval": 5
  407 + "interval": 5,
  408 + "redpacket": 0.18
375 409 },
376 410 {
377 411 "id": 35,
... ... @@ -382,7 +416,8 @@
382 416 "gold_get": "39823000000",
383 417 "ratio": 1.17,
384 418 "increse_limit": 8,
385   - "interval": 5
  419 + "interval": 5,
  420 + "redpacket": 0.18
386 421 },
387 422 {
388 423 "id": 36,
... ... @@ -393,7 +428,8 @@
393 428 "gold_get": "80145000000",
394 429 "ratio": 1.17,
395 430 "increse_limit": 8,
396   - "interval": 5
  431 + "interval": 5,
  432 + "redpacket": 0.18
397 433 },
398 434 {
399 435 "id": 37,
... ... @@ -404,6 +440,7 @@
404 440 "gold_get": "80145000000",
405 441 "ratio": 1.17,
406 442 "increse_limit": 8,
407   - "interval": 5
  443 + "interval": 5,
  444 + "redpacket": 0.18
408 445 }
409 446 ]
410 447 \ No newline at end of file
... ...
src/HttpServer/jsonconf/jsonconf.go
... ... @@ -29,6 +29,7 @@ type CatDesc struct {
29 29 Ratio float32 `json:"ratio"`
30 30 Increse_limit int `json:"increse_limit"`
31 31 Interval float32 `json:"interval"`
  32 + Redpacket float32 `json:"redpacket"`
32 33 }
33 34  
34 35 type RedCatDesc struct {
... ...
src/HttpServer/logic/constdef.go
... ... @@ -67,6 +67,7 @@ const (
67 67 DOUBLETIMELAST = 300 //金币加速持续时间
68 68 FLYBOXNUMLIMIT = 6 //飞天宝箱每日次数限制
69 69 EMPTYBOXLIMIT = 20 //空格宝箱每日限制次数
  70 + SHAKETIMELIMIT = 20 //摇一摇每日次数
70 71 )
71 72  
72 73 var CATNAMELIST = []string{
... ...
src/HttpServer/logic/datadef.go
... ... @@ -109,6 +109,7 @@ type GetUserDataData struct {
109 109 Coin string `json:"coin"`
110 110 Now int `json:"now"`
111 111 TimingRewardTimes int `json:"timingRewardTimes"`
  112 + Shakeleftcnt int `json:"shakeleftcnt"`
112 113 }
113 114  
114 115 type GetUserDataResp struct {
... ... @@ -237,6 +238,18 @@ type GethorsemessageResp struct {
237 238 Data GethorsemessageData `json:"data"`
238 239 }
239 240  
  241 +type QuertlvredbagData struct {
  242 + Catlv int `json:"catlv"`
  243 + Redbag float32 `json:"redbag"`
  244 + Canfetch int `json:"canfetch"`
  245 +}
  246 +
  247 +type QuertlvredbagResp struct {
  248 + Code int `json:"code"`
  249 + Message string `json:"message"`
  250 + Data QuertlvredbagData `json:"data"`
  251 +}
  252 +
240 253 type AddAdData struct {
241 254 }
242 255  
... ... @@ -540,6 +553,35 @@ type DoBuyCatResp struct {
540 553 Data DoBuyCatData `json:"data"`
541 554 }
542 555  
  556 +type UploadusercostReq struct {
  557 + Rtype int `json:"rtype"`
  558 + Value int `json:"value"`
  559 +}
  560 +
  561 +type UploadusercostData struct {
  562 + Lefttime int `json:"lefttime"`
  563 +}
  564 +
  565 +type UploadusercostResp struct {
  566 + Code int `json:"code"`
  567 + Message string `json:"message"`
  568 + Data UploadusercostData `json:"data"`
  569 +}
  570 +
  571 +type FetchlvredbagReq struct {
  572 + Catlv int `json:"catlv"`
  573 +}
  574 +
  575 +type FetchlvredbagData struct {
  576 + Redbag float32 `json:"redbag"`
  577 +}
  578 +
  579 +type FetchlvredbagResp struct {
  580 + Code int `json:"code"`
  581 + Message string `json:"message"`
  582 + Data FetchlvredbagData `json:"data"`
  583 +}
  584 +
543 585 type QueryWareHouseData struct {
544 586 CatList []int `json:"catList"`
545 587 CatCapacity int `json:"catCapacity"`
... ... @@ -991,6 +1033,8 @@ type UserData struct {
991 1033 LeftOfflineTimes int //离线奖励剩余领取次数
992 1034 EmptyBoxLeftTime int //空格宝箱生意领取次数
993 1035 IsResetToday int //当天中午十二点是否重置 0表示未 1表示已重置
  1036 + ShakeTime int //摇一摇次数
  1037 + WaitFetchLv []int //当前可领取的等级红包等级
994 1038 WaitFetchList []LimitListDesc //待领取的分红猫列表 领取完删除
995 1039 CatShopInfo CatShopData //猫咖门店数据
996 1040 Taskinfo TaskData //任务数据
... ...
src/HttpServer/logic/function.go
... ... @@ -557,6 +557,7 @@ func (u *UserData) HandlePassDay() {
557 557 u.LeftTimingRewardTimes = TIMEINGREWARDLIMIT
558 558 u.LeftOfflineTimes = OFFLINETIMESLIMIT
559 559 u.EmptyBoxLeftTime = EMPTYBOXLIMIT
  560 + u.ShakeTime = SHAKETIMELIMIT
560 561  
561 562 u.IsResetToday = 0
562 563 /*randint := rand.Intn(100)
... ... @@ -642,6 +643,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) {
642 643 udata.LeftTimingRewardTimes = TIMEINGREWARDLIMIT
643 644 udata.LeftOfflineTimes = OFFLINETIMESLIMIT
644 645 udata.EmptyBoxLeftTime = EMPTYBOXLIMIT
  646 + udata.ShakeTime = SHAKETIMELIMIT
645 647 /*randint := rand.Intn(100)
646 648 floatval := float32(randint) / 100
647 649 udata.TodayZhaocai = 180 + floatval*/
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -186,6 +186,9 @@ func startServerHttpServe() {
186 186 http.HandleFunc("/api/happycat/getcash", Getcash) // 请求提现
187 187 http.HandleFunc("/api/happycat/getcashrecord", Getcashrecord) // 请求提现
188 188 http.HandleFunc("/api/happycat/gethorsemessage", Gethorsemessage) // 请求跑马灯
  189 + http.HandleFunc("/api/happycat/uploadusercost", Uploadusercost) // 上报玩家消耗次数(摇一摇)
  190 + http.HandleFunc("/api/happycat/quertlvredbag", Quertlvredbag) // 上报玩家消耗次数(摇一摇)
  191 + http.HandleFunc("/api/happycat/fetchlvredbag", Fetchlvredbag) // 请求领取等级红包
189 192  
190 193 /////---------------------------------------------------------------------old
191 194 //http.HandleFunc("/happycat/exchangetwoPos", ExchangePos) //交换位置
... ... @@ -1196,6 +1199,60 @@ func AddAd(w http.ResponseWriter, r *http.Request) {
1196 1199 HandlerAddAd(w, s, Uuid)
1197 1200 }
1198 1201  
  1202 +func Fetchlvredbag(w http.ResponseWriter, r *http.Request) {
  1203 + Uuid := 0
  1204 + if len(r.Header) > 0 {
  1205 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1206 + }
  1207 + if Uuid == 0 {
  1208 + SetHeader(w)
  1209 + return
  1210 + }
  1211 + result, _ := ioutil.ReadAll(r.Body)
  1212 + r.Body.Close()
  1213 +
  1214 + s := string(result)
  1215 + logger.Info("Fetchlvredbag , body:%v,uuid=%v", s, Uuid)
  1216 +
  1217 + HandlerFetchlvredbag(w, s, Uuid)
  1218 +}
  1219 +
  1220 +func Quertlvredbag(w http.ResponseWriter, r *http.Request) {
  1221 + Uuid := 0
  1222 + if len(r.Header) > 0 {
  1223 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1224 + }
  1225 + if Uuid == 0 {
  1226 + SetHeader(w)
  1227 + return
  1228 + }
  1229 + result, _ := ioutil.ReadAll(r.Body)
  1230 + r.Body.Close()
  1231 +
  1232 + s := string(result)
  1233 + logger.Info("Quertlvredbag , body:%v,uuid=%v", s, Uuid)
  1234 +
  1235 + HandlerQuertlvredbag(w, s, Uuid)
  1236 +}
  1237 +
  1238 +func Uploadusercost(w http.ResponseWriter, r *http.Request) {
  1239 + Uuid := 0
  1240 + if len(r.Header) > 0 {
  1241 + Uuid, _ = strconv.Atoi(r.Header.Get("uid"))
  1242 + }
  1243 + if Uuid == 0 {
  1244 + SetHeader(w)
  1245 + return
  1246 + }
  1247 + result, _ := ioutil.ReadAll(r.Body)
  1248 + r.Body.Close()
  1249 +
  1250 + s := string(result)
  1251 + logger.Info("Uploadusercost , body:%v,uuid=%v", s, Uuid)
  1252 +
  1253 + HandlerUploadusercost(w, s, Uuid)
  1254 +}
  1255 +
1199 1256 func Gethorsemessage(w http.ResponseWriter, r *http.Request) {
1200 1257 Uuid := 0
1201 1258 if len(r.Header) > 0 {
... ...
src/HttpServer/logic/logic.go
... ... @@ -9,6 +9,7 @@ import (
9 9 "fmt"
10 10 "math/rand"
11 11 "net/http"
  12 + "sort"
12 13 "strconv"
13 14 "sync"
14 15 "time"
... ... @@ -626,6 +627,160 @@ func HandlerGetflyboxreward(w http.ResponseWriter, data string, uuid int) {
626 627 fmt.Fprint(w, string(respstr))
627 628 }
628 629  
  630 +func HandlerFetchlvredbag(w http.ResponseWriter, data string, uuid int) {
  631 + SetHeader(w)
  632 + var resp FetchlvredbagResp
  633 + resp.Code = 0
  634 + resp.Message = "success"
  635 + var rdata FetchlvredbagReq
  636 + err := json.Unmarshal([]byte(data), &rdata)
  637 + for {
  638 + if err != nil {
  639 + logger.Error("HandlerFetchlvredbag json unmarshal failed=%v", err)
  640 + resp.Code = 1
  641 + resp.Message = "json failed"
  642 + break
  643 + }
  644 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  645 + if err != nil || uinfo == nil {
  646 + logger.Error("HandlerFetchlvredbag getuserinfo failed=%v", err)
  647 + resp.Code = 1
  648 + resp.Message = "get userinfo failed"
  649 + break
  650 + }
  651 +
  652 + if rdata.Catlv != uinfo.WaitFetchLv[0] {
  653 + //请求领取的等级红包不正确
  654 + logger.Error("HandlerFetchlvredbag catlv failed=%v", err)
  655 + resp.Code = 1
  656 + resp.Message = "请求领取的等级红包不正确"
  657 + break
  658 + }
  659 +
  660 + cfg := jsonconf.GetCatConfig(rdata.Catlv)
  661 + if cfg == nil {
  662 + logger.Error("HandlerFetchlvredbag GetCatConfig failed=%v", err)
  663 + resp.Code = 1
  664 + resp.Message = "获取配置失败"
  665 + break
  666 + }
  667 +
  668 + newgold, err := uinfo.AddRedPackect(cfg.Redpacket, 100)
  669 + if err != nil {
  670 + logger.Error("HandlerFetchlvredbag GetCatConfig failed=%v", err)
  671 + resp.Code = 1
  672 + resp.Message = "后台加红包失败!"
  673 + break
  674 + }
  675 +
  676 + uinfo.WaitFetchLv = uinfo.WaitFetchLv[1:]
  677 +
  678 + resp.Data.Redbag = float32(newgold) / 100
  679 + resp.Code = 0
  680 + //保存
  681 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
  682 +
  683 + break
  684 +
  685 + }
  686 + //回包
  687 + respstr, _ := json.Marshal(&resp)
  688 + fmt.Fprint(w, string(respstr))
  689 +}
  690 +
  691 +func HandlerUploadusercost(w http.ResponseWriter, data string, uuid int) {
  692 + SetHeader(w)
  693 + var resp UploadusercostResp
  694 + resp.Code = 0
  695 + resp.Message = "success"
  696 + var rdata UploadusercostReq
  697 + err := json.Unmarshal([]byte(data), &rdata)
  698 + for {
  699 + if err != nil {
  700 + logger.Error("HandlerUploadusercost json unmarshal failed=%v", err)
  701 + resp.Code = 1
  702 + resp.Message = "json failed"
  703 + break
  704 + }
  705 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  706 + if err != nil || uinfo == nil {
  707 + logger.Error("HandlerUploadusercost getuserinfo failed=%v", err)
  708 + resp.Code = 1
  709 + resp.Message = "get userinfo failed"
  710 + break
  711 + }
  712 +
  713 + if rdata.Rtype == 1 {
  714 + //摇一摇次数
  715 + uinfo.ShakeTime -= rdata.Value
  716 + if uinfo.ShakeTime < 0 {
  717 + uinfo.ShakeTime = 0
  718 + }
  719 + resp.Data.Lefttime = uinfo.ShakeTime
  720 + } else {
  721 + resp.Code = 1
  722 + resp.Message = "类型不正确!"
  723 + break
  724 + }
  725 + resp.Code = 0
  726 +
  727 + //保存
  728 + SaveUserInfo(uinfo, strconv.Itoa(uuid))
  729 +
  730 + break
  731 +
  732 + }
  733 + //回包
  734 + respstr, _ := json.Marshal(&resp)
  735 + fmt.Fprint(w, string(respstr))
  736 +}
  737 +
  738 +func HandlerQuertlvredbag(w http.ResponseWriter, data string, uuid int) {
  739 + SetHeader(w)
  740 + var resp QuertlvredbagResp
  741 + resp.Code = 0
  742 + resp.Message = "success"
  743 + for {
  744 +
  745 + uinfo, err := GetUserInfo(strconv.Itoa(uuid))
  746 + if err != nil || uinfo == nil {
  747 + logger.Error("HandlerQuertlvredbag getuserinfo failed=%v", err)
  748 + resp.Code = 1
  749 + resp.Message = "get userinfo failed"
  750 + break
  751 + }
  752 +
  753 + if len(uinfo.WaitFetchLv) == 0 {
  754 + //没有可领取的
  755 +
  756 + if uinfo.Highestlv < 36 {
  757 + resp.Data.Catlv = uinfo.Highestlv + 1
  758 + } else {
  759 + resp.Data.Catlv = 0
  760 + }
  761 + resp.Data.Redbag = 0.0
  762 + resp.Data.Canfetch = 0
  763 +
  764 + } else {
  765 + resp.Data.Canfetch = 1
  766 + resp.Data.Catlv = uinfo.WaitFetchLv[0]
  767 +
  768 + cfg := jsonconf.GetCatConfig(uinfo.WaitFetchLv[0])
  769 + if cfg == nil {
  770 + logger.Error("HandlerQuertlvredbag getcatcfg failed lv=%v", uinfo.WaitFetchLv[0])
  771 + } else {
  772 + resp.Data.Redbag = cfg.Redpacket
  773 + }
  774 + }
  775 +
  776 + break
  777 + }
  778 +
  779 + //回包
  780 + respstr, _ := json.Marshal(&resp)
  781 + fmt.Fprint(w, string(respstr))
  782 +}
  783 +
629 784 func HandlerGethorsemessage(w http.ResponseWriter, data string, uuid int) {
630 785 SetHeader(w)
631 786 var resp GethorsemessageResp
... ... @@ -1272,6 +1427,7 @@ func HandlerGetUserData(w http.ResponseWriter, data string, uuid int) {
1272 1427  
1273 1428 //resp.Data.TimingReward = false
1274 1429 resp.Data.TimingRewardTimes = uinfo.LeftTimingRewardTimes
  1430 + resp.Data.Shakeleftcnt = uinfo.ShakeTime
1275 1431  
1276 1432 //保存此次计算时间
1277 1433 nowtimestr := strconv.FormatInt(nowtime, 10)
... ... @@ -2464,6 +2620,10 @@ func HandlerExchangePos(w http.ResponseWriter, data string, uuid int) {
2464 2620 //翻拍次数+
2465 2621 uinfo.FlopCardLefCnt++
2466 2622  
  2623 + //将等级红包加入待领取列表
  2624 + uinfo.WaitFetchLv = append(uinfo.WaitFetchLv, uinfo.Highestlv)
  2625 + sort.Ints(uinfo.WaitFetchLv)
  2626 +
2467 2627 nowt := int(time.Now().Unix())
2468 2628 uinfo.CurentLevelCostTime = (nowt - uinfo.CurentLevelSec) / 3600
2469 2629 uinfo.CurentLevelSec = nowt
... ...