From 253dc21e76a7cea49121a30c71b8b54981409ea6 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Sat, 25 Jul 2020 15:28:04 +0800 Subject: [PATCH] 提交新的进度 --- src/HttpServer/logic/datadef.go | 7 +++++++ src/HttpServer/logic/function.go | 7 ++++++- src/HttpServer/logic/httpserver.go | 22 ++++++++++++++++++++++ src/HttpServer/logic/logic.go | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 101 insertions(+), 2 deletions(-) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index d47d6e3..c376233 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -14,6 +14,8 @@ type UserLoginData struct { Guanrednum int `json:"guanrednum"` Jirednum int `json:"jirednum"` Randnum int `json:"randnum"` + Speciallevel int `json:"speciallevel"` + Speciallevelnum int `json:"speciallevelnum"` } type UserLoginResp struct { @@ -35,6 +37,8 @@ type GetuserdataData struct { Guanrednum int `json:"guanrednum"` Jirednum int `json:"jirednum"` Randnum int `json:"randnum"` + Speciallevel int `json:"speciallevel"` + Speciallevelnum int `json:"speciallevelnum"` } @@ -114,6 +118,7 @@ type FetchredbagData struct { Guanrednum int `json:"guanrednum"` Jirednum int `json:"jirednum"` Randnum int `json:"randnum"` + Specialguannum int `json:"specialguannum"` Getgold int `json:"getgold"` Walletgold int `json:"walletgold"` } @@ -195,9 +200,11 @@ type UserData struct { UpLvCostTimeSec int //上一个等级升级的时间点时刻 PassLevel int //当前关卡 BigLevel int //当前等级 + SpecialLevel int //特殊关卡 GuanRedNum int //关卡红包领取进度 JiRedNum int //等级红包领取进度 RandNum int //随机红包剩余次数 + SpecialNum int //特殊关卡红包领取进度 ReadNum int //玩家微转发阅读量 GetCashCnt int //当天提现次数 WithDraw WithDrawInfo //提现记录信息 diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index b07147a..fedda13 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -109,6 +109,8 @@ func HandlerSyncuserdata(w http.ResponseWriter, data string, uuid int) { resp.Data.Guanrednum = data.GuanRedNum resp.Data.Jirednum = data.JiRedNum resp.Data.Randnum = data.RandNum + resp.Data.Speciallevel = data.SpecialLevel + resp.Data.Speciallevelnum = data.SpecialNum SaveUserInfo(data, uniqueuuid) resp.Code = 0 @@ -145,8 +147,10 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s initdata.UpLvCostTime = 0 initdata.PassLevel = 0 initdata.BigLevel = 1 + initdata.SpecialLevel = 0 initdata.GuanRedNum = 0 initdata.JiRedNum = 0 + initdata.SpecialNum = 0 initdata.RandNum = RANDNUMLIMIT initdata.UpLvCostTimeSec = int(time.Now().Unix()) @@ -194,7 +198,8 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s resp.Data.Guanrednum = initdata.GuanRedNum resp.Data.Jirednum = initdata.JiRedNum resp.Data.Randnum = initdata.RandNum - + resp.Data.Speciallevel = initdata.SpecialLevel + resp.Data.Speciallevelnum = initdata.SpecialNum err := SaveUserInfo(&initdata, uniqueuid) logger.Info("InitUserInfoddddd uinfo=%+v", initdata) diff --git a/src/HttpServer/logic/httpserver.go b/src/HttpServer/logic/httpserver.go index d9281e9..50862ce 100644 --- a/src/HttpServer/logic/httpserver.go +++ b/src/HttpServer/logic/httpserver.go @@ -44,6 +44,7 @@ func startServerHttpServe() { http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表 http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡 http.HandleFunc("/brainhole/uploadbiglevel", Uploadbiglevel) //上报当前等级 + http.HandleFunc("/brainhole/uploadspeciallevel", Uploadspeciallevel) //上报当前等级 http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 @@ -116,6 +117,27 @@ func Fetchredbag(w http.ResponseWriter, r *http.Request) { HandlerFetchredbag(w, s, Uuid) } +func Uploadspeciallevel(w http.ResponseWriter, r *http.Request) { + + Uuid := 0 + if len(r.Header) > 0 { + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) + } + + if Uuid == 0 { + SetHeader(w) + //logger.Error("Uuid is nil!") + return + } + result, _ := ioutil.ReadAll(r.Body) + r.Body.Close() + + s := string(result) + logger.Info("Uploadspeciallevel , body:%v,uuid=%v", s, Uuid) + + HandlerUploadspeciallevel(w, s, Uuid) +} + func Uploadbiglevel(w http.ResponseWriter, r *http.Request) { Uuid := 0 diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 231de04..b924304 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -288,7 +288,7 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { resp.Data.Walletgold = realgold uinfo.JiRedNum ++ - }else { + }else if rdata.Rtype == 3{ if uinfo.RandNum <= 0 { logger.Error("HandlerFetchredbag failed err=%v", err) resp.Message = "没有可以领取的随机红包次数了!" @@ -309,14 +309,77 @@ func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { resp.Data.Walletgold = realgold uinfo.RandNum-- + }else { + if uinfo.SpecialLevel <= uinfo.SpecialNum { + logger.Error("HandlerFetchredbag failed err=%v", err) + resp.Message = "没有可以领取的随机红包次数了!" + resp.Code = 1 + break + } + + getnum := rand.Intn(300) + 300 + realgold, err := AddCoinToSdk(uuid, getnum, rdata.Gameid, rdata.Channel, 108) + if err !=nil { + logger.Error("HandlerFetchredbag failed err=%v", err) + resp.Message = "服务器错误!" + resp.Code = 1 + break + } + + resp.Data.Getgold = getnum + resp.Data.Walletgold = realgold + + uinfo.SpecialNum++ } + SaveUserInfo(uinfo,uniqueuuid) resp.Data.Randnum = uinfo.RandNum resp.Data.Guanrednum = uinfo.GuanRedNum resp.Data.Jirednum = uinfo.JiRedNum + resp.Data.Specialguannum = uinfo.SpecialNum + resp.Code = 0 + break + } + + //回包 + respstr, _ := json.Marshal(&resp) + fmt.Fprint(w, string(respstr)) + +} + +func HandlerUploadspeciallevel(w http.ResponseWriter, data string, uuid int) { + SetHeader(w) + var resp UploadlevelResp + resp.Code = 0 + var rdata UploadlevelReq + err := json.Unmarshal([]byte(data), &rdata) + for { + if err != nil { + logger.Info("json decode HandlerUploadspeciallevel data failed:%v,for:%v", err, data) + resp.Message = "json解析错误" + resp.Code = 1 + break + } + + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel + uinfo, err := GetUserInfo(uniqueuuid) + if err != nil || uinfo == nil { + logger.Error("redis failed err=%v", err) + resp.Message = "服务器错误" + resp.Code = 1 + break + } + + if rdata.Level > uinfo.SpecialLevel { + uinfo.SpecialLevel = rdata.Level + } + + + SaveUserInfo(uinfo,uniqueuuid) + resp.Code = 0 break } @@ -592,6 +655,8 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR resp.Data.Guanrednum = data.GuanRedNum resp.Data.Jirednum = data.JiRedNum resp.Data.Randnum = data.RandNum + resp.Data.Speciallevel = data.SpecialLevel + resp.Data.Speciallevelnum = data.SpecialNum return nil } \ No newline at end of file -- libgit2 0.21.0