Commit 253dc21e76a7cea49121a30c71b8b54981409ea6
1 parent
bcaed39b
Exists in
master
提交新的进度
Showing
4 changed files
with
101 additions
and
2 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -14,6 +14,8 @@ type UserLoginData struct { |
14 | 14 | Guanrednum int `json:"guanrednum"` |
15 | 15 | Jirednum int `json:"jirednum"` |
16 | 16 | Randnum int `json:"randnum"` |
17 | + Speciallevel int `json:"speciallevel"` | |
18 | + Speciallevelnum int `json:"speciallevelnum"` | |
17 | 19 | } |
18 | 20 | |
19 | 21 | type UserLoginResp struct { |
... | ... | @@ -35,6 +37,8 @@ type GetuserdataData struct { |
35 | 37 | Guanrednum int `json:"guanrednum"` |
36 | 38 | Jirednum int `json:"jirednum"` |
37 | 39 | Randnum int `json:"randnum"` |
40 | + Speciallevel int `json:"speciallevel"` | |
41 | + Speciallevelnum int `json:"speciallevelnum"` | |
38 | 42 | |
39 | 43 | } |
40 | 44 | |
... | ... | @@ -114,6 +118,7 @@ type FetchredbagData struct { |
114 | 118 | Guanrednum int `json:"guanrednum"` |
115 | 119 | Jirednum int `json:"jirednum"` |
116 | 120 | Randnum int `json:"randnum"` |
121 | + Specialguannum int `json:"specialguannum"` | |
117 | 122 | Getgold int `json:"getgold"` |
118 | 123 | Walletgold int `json:"walletgold"` |
119 | 124 | } |
... | ... | @@ -195,9 +200,11 @@ type UserData struct { |
195 | 200 | UpLvCostTimeSec int //上一个等级升级的时间点时刻 |
196 | 201 | PassLevel int //当前关卡 |
197 | 202 | BigLevel int //当前等级 |
203 | + SpecialLevel int //特殊关卡 | |
198 | 204 | GuanRedNum int //关卡红包领取进度 |
199 | 205 | JiRedNum int //等级红包领取进度 |
200 | 206 | RandNum int //随机红包剩余次数 |
207 | + SpecialNum int //特殊关卡红包领取进度 | |
201 | 208 | ReadNum int //玩家微转发阅读量 |
202 | 209 | GetCashCnt int //当天提现次数 |
203 | 210 | WithDraw WithDrawInfo //提现记录信息 | ... | ... |
src/HttpServer/logic/function.go
... | ... | @@ -109,6 +109,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uuid int) { |
109 | 109 | resp.Data.Guanrednum = data.GuanRedNum |
110 | 110 | resp.Data.Jirednum = data.JiRedNum |
111 | 111 | resp.Data.Randnum = data.RandNum |
112 | + resp.Data.Speciallevel = data.SpecialLevel | |
113 | + resp.Data.Speciallevelnum = data.SpecialNum | |
112 | 114 | SaveUserInfo(data, uniqueuuid) |
113 | 115 | |
114 | 116 | resp.Code = 0 |
... | ... | @@ -145,8 +147,10 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s |
145 | 147 | initdata.UpLvCostTime = 0 |
146 | 148 | initdata.PassLevel = 0 |
147 | 149 | initdata.BigLevel = 1 |
150 | + initdata.SpecialLevel = 0 | |
148 | 151 | initdata.GuanRedNum = 0 |
149 | 152 | initdata.JiRedNum = 0 |
153 | + initdata.SpecialNum = 0 | |
150 | 154 | initdata.RandNum = RANDNUMLIMIT |
151 | 155 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) |
152 | 156 | |
... | ... | @@ -194,7 +198,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s |
194 | 198 | resp.Data.Guanrednum = initdata.GuanRedNum |
195 | 199 | resp.Data.Jirednum = initdata.JiRedNum |
196 | 200 | resp.Data.Randnum = initdata.RandNum |
197 | - | |
201 | + resp.Data.Speciallevel = initdata.SpecialLevel | |
202 | + resp.Data.Speciallevelnum = initdata.SpecialNum | |
198 | 203 | |
199 | 204 | err := SaveUserInfo(&initdata, uniqueuid) |
200 | 205 | logger.Info("InitUserInfoddddd uinfo=%+v", initdata) | ... | ... |
src/HttpServer/logic/httpserver.go
... | ... | @@ -44,6 +44,7 @@ func startServerHttpServe() { |
44 | 44 | http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表 |
45 | 45 | http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡 |
46 | 46 | http.HandleFunc("/brainhole/uploadbiglevel", Uploadbiglevel) //上报当前等级 |
47 | + http.HandleFunc("/brainhole/uploadspeciallevel", Uploadspeciallevel) //上报当前等级 | |
47 | 48 | http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 |
48 | 49 | |
49 | 50 | |
... | ... | @@ -116,6 +117,27 @@ func Fetchredbag(w http.ResponseWriter, r *http.Request) { |
116 | 117 | HandlerFetchredbag(w, s, Uuid) |
117 | 118 | } |
118 | 119 | |
120 | +func Uploadspeciallevel(w http.ResponseWriter, r *http.Request) { | |
121 | + | |
122 | + Uuid := 0 | |
123 | + if len(r.Header) > 0 { | |
124 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | |
125 | + } | |
126 | + | |
127 | + if Uuid == 0 { | |
128 | + SetHeader(w) | |
129 | + //logger.Error("Uuid is nil!") | |
130 | + return | |
131 | + } | |
132 | + result, _ := ioutil.ReadAll(r.Body) | |
133 | + r.Body.Close() | |
134 | + | |
135 | + s := string(result) | |
136 | + logger.Info("Uploadspeciallevel , body:%v,uuid=%v", s, Uuid) | |
137 | + | |
138 | + HandlerUploadspeciallevel(w, s, Uuid) | |
139 | +} | |
140 | + | |
119 | 141 | func Uploadbiglevel(w http.ResponseWriter, r *http.Request) { |
120 | 142 | |
121 | 143 | Uuid := 0 | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -288,7 +288,7 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { |
288 | 288 | resp.Data.Walletgold = realgold |
289 | 289 | |
290 | 290 | uinfo.JiRedNum ++ |
291 | - }else { | |
291 | + }else if rdata.Rtype == 3{ | |
292 | 292 | if uinfo.RandNum <= 0 { |
293 | 293 | logger.Error("HandlerFetchredbag failed err=%v", err) |
294 | 294 | resp.Message = "没有可以领取的随机红包次数了!" |
... | ... | @@ -309,14 +309,77 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { |
309 | 309 | resp.Data.Walletgold = realgold |
310 | 310 | |
311 | 311 | uinfo.RandNum-- |
312 | + }else { | |
313 | + if uinfo.SpecialLevel <= uinfo.SpecialNum { | |
314 | + logger.Error("HandlerFetchredbag failed err=%v", err) | |
315 | + resp.Message = "没有可以领取的随机红包次数了!" | |
316 | + resp.Code = 1 | |
317 | + break | |
318 | + } | |
319 | + | |
320 | + getnum := rand.Intn(300) + 300 | |
321 | + realgold, err := AddCoinToSdk(uuid, getnum, rdata.Gameid, rdata.Channel, 108) | |
322 | + if err !=nil { | |
323 | + logger.Error("HandlerFetchredbag failed err=%v", err) | |
324 | + resp.Message = "服务器错误!" | |
325 | + resp.Code = 1 | |
326 | + break | |
327 | + } | |
328 | + | |
329 | + resp.Data.Getgold = getnum | |
330 | + resp.Data.Walletgold = realgold | |
331 | + | |
332 | + uinfo.SpecialNum++ | |
312 | 333 | } |
313 | 334 | |
314 | 335 | |
336 | + | |
315 | 337 | SaveUserInfo(uinfo,uniqueuuid) |
316 | 338 | |
317 | 339 | resp.Data.Randnum = uinfo.RandNum |
318 | 340 | resp.Data.Guanrednum = uinfo.GuanRedNum |
319 | 341 | resp.Data.Jirednum = uinfo.JiRedNum |
342 | + resp.Data.Specialguannum = uinfo.SpecialNum | |
343 | + resp.Code = 0 | |
344 | + break | |
345 | + } | |
346 | + | |
347 | + //回包 | |
348 | + respstr, _ := json.Marshal(&resp) | |
349 | + fmt.Fprint(w, string(respstr)) | |
350 | + | |
351 | +} | |
352 | + | |
353 | +func HandlerUploadspeciallevel(w http.ResponseWriter, data string, uuid int) { | |
354 | + SetHeader(w) | |
355 | + var resp UploadlevelResp | |
356 | + resp.Code = 0 | |
357 | + var rdata UploadlevelReq | |
358 | + err := json.Unmarshal([]byte(data), &rdata) | |
359 | + for { | |
360 | + if err != nil { | |
361 | + logger.Info("json decode HandlerUploadspeciallevel data failed:%v,for:%v", err, data) | |
362 | + resp.Message = "json解析错误" | |
363 | + resp.Code = 1 | |
364 | + break | |
365 | + } | |
366 | + | |
367 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | |
368 | + uinfo, err := GetUserInfo(uniqueuuid) | |
369 | + if err != nil || uinfo == nil { | |
370 | + logger.Error("redis failed err=%v", err) | |
371 | + resp.Message = "服务器错误" | |
372 | + resp.Code = 1 | |
373 | + break | |
374 | + } | |
375 | + | |
376 | + if rdata.Level > uinfo.SpecialLevel { | |
377 | + uinfo.SpecialLevel = rdata.Level | |
378 | + } | |
379 | + | |
380 | + | |
381 | + SaveUserInfo(uinfo,uniqueuuid) | |
382 | + | |
320 | 383 | resp.Code = 0 |
321 | 384 | break |
322 | 385 | } |
... | ... | @@ -592,6 +655,8 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR |
592 | 655 | resp.Data.Guanrednum = data.GuanRedNum |
593 | 656 | resp.Data.Jirednum = data.JiRedNum |
594 | 657 | resp.Data.Randnum = data.RandNum |
658 | + resp.Data.Speciallevel = data.SpecialLevel | |
659 | + resp.Data.Speciallevelnum = data.SpecialNum | |
595 | 660 | |
596 | 661 | return nil |
597 | 662 | } |
598 | 663 | \ No newline at end of file | ... | ... |