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,6 +14,8 @@ type UserLoginData struct { | ||
14 | Guanrednum int `json:"guanrednum"` | 14 | Guanrednum int `json:"guanrednum"` |
15 | Jirednum int `json:"jirednum"` | 15 | Jirednum int `json:"jirednum"` |
16 | Randnum int `json:"randnum"` | 16 | Randnum int `json:"randnum"` |
17 | + Speciallevel int `json:"speciallevel"` | ||
18 | + Speciallevelnum int `json:"speciallevelnum"` | ||
17 | } | 19 | } |
18 | 20 | ||
19 | type UserLoginResp struct { | 21 | type UserLoginResp struct { |
@@ -35,6 +37,8 @@ type GetuserdataData struct { | @@ -35,6 +37,8 @@ type GetuserdataData struct { | ||
35 | Guanrednum int `json:"guanrednum"` | 37 | Guanrednum int `json:"guanrednum"` |
36 | Jirednum int `json:"jirednum"` | 38 | Jirednum int `json:"jirednum"` |
37 | Randnum int `json:"randnum"` | 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,6 +118,7 @@ type FetchredbagData struct { | ||
114 | Guanrednum int `json:"guanrednum"` | 118 | Guanrednum int `json:"guanrednum"` |
115 | Jirednum int `json:"jirednum"` | 119 | Jirednum int `json:"jirednum"` |
116 | Randnum int `json:"randnum"` | 120 | Randnum int `json:"randnum"` |
121 | + Specialguannum int `json:"specialguannum"` | ||
117 | Getgold int `json:"getgold"` | 122 | Getgold int `json:"getgold"` |
118 | Walletgold int `json:"walletgold"` | 123 | Walletgold int `json:"walletgold"` |
119 | } | 124 | } |
@@ -195,9 +200,11 @@ type UserData struct { | @@ -195,9 +200,11 @@ type UserData struct { | ||
195 | UpLvCostTimeSec int //上一个等级升级的时间点时刻 | 200 | UpLvCostTimeSec int //上一个等级升级的时间点时刻 |
196 | PassLevel int //当前关卡 | 201 | PassLevel int //当前关卡 |
197 | BigLevel int //当前等级 | 202 | BigLevel int //当前等级 |
203 | + SpecialLevel int //特殊关卡 | ||
198 | GuanRedNum int //关卡红包领取进度 | 204 | GuanRedNum int //关卡红包领取进度 |
199 | JiRedNum int //等级红包领取进度 | 205 | JiRedNum int //等级红包领取进度 |
200 | RandNum int //随机红包剩余次数 | 206 | RandNum int //随机红包剩余次数 |
207 | + SpecialNum int //特殊关卡红包领取进度 | ||
201 | ReadNum int //玩家微转发阅读量 | 208 | ReadNum int //玩家微转发阅读量 |
202 | GetCashCnt int //当天提现次数 | 209 | GetCashCnt int //当天提现次数 |
203 | WithDraw WithDrawInfo //提现记录信息 | 210 | WithDraw WithDrawInfo //提现记录信息 |
src/HttpServer/logic/function.go
@@ -109,6 +109,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uuid int) { | @@ -109,6 +109,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uuid int) { | ||
109 | resp.Data.Guanrednum = data.GuanRedNum | 109 | resp.Data.Guanrednum = data.GuanRedNum |
110 | resp.Data.Jirednum = data.JiRedNum | 110 | resp.Data.Jirednum = data.JiRedNum |
111 | resp.Data.Randnum = data.RandNum | 111 | resp.Data.Randnum = data.RandNum |
112 | + resp.Data.Speciallevel = data.SpecialLevel | ||
113 | + resp.Data.Speciallevelnum = data.SpecialNum | ||
112 | SaveUserInfo(data, uniqueuuid) | 114 | SaveUserInfo(data, uniqueuuid) |
113 | 115 | ||
114 | resp.Code = 0 | 116 | resp.Code = 0 |
@@ -145,8 +147,10 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | @@ -145,8 +147,10 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | ||
145 | initdata.UpLvCostTime = 0 | 147 | initdata.UpLvCostTime = 0 |
146 | initdata.PassLevel = 0 | 148 | initdata.PassLevel = 0 |
147 | initdata.BigLevel = 1 | 149 | initdata.BigLevel = 1 |
150 | + initdata.SpecialLevel = 0 | ||
148 | initdata.GuanRedNum = 0 | 151 | initdata.GuanRedNum = 0 |
149 | initdata.JiRedNum = 0 | 152 | initdata.JiRedNum = 0 |
153 | + initdata.SpecialNum = 0 | ||
150 | initdata.RandNum = RANDNUMLIMIT | 154 | initdata.RandNum = RANDNUMLIMIT |
151 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) | 155 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) |
152 | 156 | ||
@@ -194,7 +198,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | @@ -194,7 +198,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | ||
194 | resp.Data.Guanrednum = initdata.GuanRedNum | 198 | resp.Data.Guanrednum = initdata.GuanRedNum |
195 | resp.Data.Jirednum = initdata.JiRedNum | 199 | resp.Data.Jirednum = initdata.JiRedNum |
196 | resp.Data.Randnum = initdata.RandNum | 200 | resp.Data.Randnum = initdata.RandNum |
197 | - | 201 | + resp.Data.Speciallevel = initdata.SpecialLevel |
202 | + resp.Data.Speciallevelnum = initdata.SpecialNum | ||
198 | 203 | ||
199 | err := SaveUserInfo(&initdata, uniqueuid) | 204 | err := SaveUserInfo(&initdata, uniqueuid) |
200 | logger.Info("InitUserInfoddddd uinfo=%+v", initdata) | 205 | logger.Info("InitUserInfoddddd uinfo=%+v", initdata) |
src/HttpServer/logic/httpserver.go
@@ -44,6 +44,7 @@ func startServerHttpServe() { | @@ -44,6 +44,7 @@ func startServerHttpServe() { | ||
44 | http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表 | 44 | http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表 |
45 | http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡 | 45 | http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡 |
46 | http.HandleFunc("/brainhole/uploadbiglevel", Uploadbiglevel) //上报当前等级 | 46 | http.HandleFunc("/brainhole/uploadbiglevel", Uploadbiglevel) //上报当前等级 |
47 | + http.HandleFunc("/brainhole/uploadspeciallevel", Uploadspeciallevel) //上报当前等级 | ||
47 | http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 | 48 | http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 |
48 | 49 | ||
49 | 50 | ||
@@ -116,6 +117,27 @@ func Fetchredbag(w http.ResponseWriter, r *http.Request) { | @@ -116,6 +117,27 @@ func Fetchredbag(w http.ResponseWriter, r *http.Request) { | ||
116 | HandlerFetchredbag(w, s, Uuid) | 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 | func Uploadbiglevel(w http.ResponseWriter, r *http.Request) { | 141 | func Uploadbiglevel(w http.ResponseWriter, r *http.Request) { |
120 | 142 | ||
121 | Uuid := 0 | 143 | Uuid := 0 |
src/HttpServer/logic/logic.go
@@ -288,7 +288,7 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | @@ -288,7 +288,7 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | ||
288 | resp.Data.Walletgold = realgold | 288 | resp.Data.Walletgold = realgold |
289 | 289 | ||
290 | uinfo.JiRedNum ++ | 290 | uinfo.JiRedNum ++ |
291 | - }else { | 291 | + }else if rdata.Rtype == 3{ |
292 | if uinfo.RandNum <= 0 { | 292 | if uinfo.RandNum <= 0 { |
293 | logger.Error("HandlerFetchredbag failed err=%v", err) | 293 | logger.Error("HandlerFetchredbag failed err=%v", err) |
294 | resp.Message = "没有可以领取的随机红包次数了!" | 294 | resp.Message = "没有可以领取的随机红包次数了!" |
@@ -309,14 +309,77 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | @@ -309,14 +309,77 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | ||
309 | resp.Data.Walletgold = realgold | 309 | resp.Data.Walletgold = realgold |
310 | 310 | ||
311 | uinfo.RandNum-- | 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 | SaveUserInfo(uinfo,uniqueuuid) | 337 | SaveUserInfo(uinfo,uniqueuuid) |
316 | 338 | ||
317 | resp.Data.Randnum = uinfo.RandNum | 339 | resp.Data.Randnum = uinfo.RandNum |
318 | resp.Data.Guanrednum = uinfo.GuanRedNum | 340 | resp.Data.Guanrednum = uinfo.GuanRedNum |
319 | resp.Data.Jirednum = uinfo.JiRedNum | 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 | resp.Code = 0 | 383 | resp.Code = 0 |
321 | break | 384 | break |
322 | } | 385 | } |
@@ -592,6 +655,8 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | @@ -592,6 +655,8 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | ||
592 | resp.Data.Guanrednum = data.GuanRedNum | 655 | resp.Data.Guanrednum = data.GuanRedNum |
593 | resp.Data.Jirednum = data.JiRedNum | 656 | resp.Data.Jirednum = data.JiRedNum |
594 | resp.Data.Randnum = data.RandNum | 657 | resp.Data.Randnum = data.RandNum |
658 | + resp.Data.Speciallevel = data.SpecialLevel | ||
659 | + resp.Data.Speciallevelnum = data.SpecialNum | ||
595 | 660 | ||
596 | return nil | 661 | return nil |
597 | } | 662 | } |
598 | \ No newline at end of file | 663 | \ No newline at end of file |