Commit b18909c5bdf8154cf204e7dc89c102bbdf686e2d
1 parent
0e7f8d70
Exists in
master
提交
Showing
4 changed files
with
78 additions
and
0 deletions
Show diff stats
src/HttpServer/logic/datadef.go
| @@ -16,6 +16,7 @@ type UserLoginData struct { | @@ -16,6 +16,7 @@ type UserLoginData struct { | ||
| 16 | Randnum int `json:"randnum"` | 16 | Randnum int `json:"randnum"` |
| 17 | Speciallevel int `json:"speciallevel"` | 17 | Speciallevel int `json:"speciallevel"` |
| 18 | Specialguannum int `json:"specialguannum"` | 18 | Specialguannum int `json:"specialguannum"` |
| 19 | + Tili int `json:"tili"` | ||
| 19 | } | 20 | } |
| 20 | 21 | ||
| 21 | type UserLoginResp struct { | 22 | type UserLoginResp struct { |
| @@ -107,6 +108,17 @@ type UploadlevelResp struct { | @@ -107,6 +108,17 @@ type UploadlevelResp struct { | ||
| 107 | } | 108 | } |
| 108 | 109 | ||
| 109 | 110 | ||
| 111 | +type UploadtiliReq struct { | ||
| 112 | + Tili int `json:"tili"` | ||
| 113 | + Gameid string `json:"gameid"` | ||
| 114 | + Channel string `json:"channel"` | ||
| 115 | +} | ||
| 116 | + | ||
| 117 | +type UploadtiliResp struct { | ||
| 118 | + Code int `json:"code"` | ||
| 119 | + Message string `json:"message"` | ||
| 120 | +} | ||
| 121 | + | ||
| 110 | 122 | ||
| 111 | type FetchredbagReq struct { | 123 | type FetchredbagReq struct { |
| 112 | Rtype int `json:"rtype"` | 124 | Rtype int `json:"rtype"` |
| @@ -205,6 +217,7 @@ type UserData struct { | @@ -205,6 +217,7 @@ type UserData struct { | ||
| 205 | JiRedNum int //等级红包领取进度 | 217 | JiRedNum int //等级红包领取进度 |
| 206 | RandNum int //随机红包剩余次数 | 218 | RandNum int //随机红包剩余次数 |
| 207 | SpecialNum int //特殊关卡红包领取进度 | 219 | SpecialNum int //特殊关卡红包领取进度 |
| 220 | + Tili int //体力 | ||
| 208 | ReadNum int //玩家微转发阅读量 | 221 | ReadNum int //玩家微转发阅读量 |
| 209 | GetCashCnt int //当天提现次数 | 222 | GetCashCnt int //当天提现次数 |
| 210 | WithDraw WithDrawInfo //提现记录信息 | 223 | WithDraw WithDrawInfo //提现记录信息 |
src/HttpServer/logic/function.go
| @@ -152,6 +152,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | @@ -152,6 +152,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | ||
| 152 | initdata.JiRedNum = 0 | 152 | initdata.JiRedNum = 0 |
| 153 | initdata.SpecialNum = 0 | 153 | initdata.SpecialNum = 0 |
| 154 | initdata.RandNum = RANDNUMLIMIT | 154 | initdata.RandNum = RANDNUMLIMIT |
| 155 | + initdata.Tili = 10 | ||
| 155 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) | 156 | initdata.UpLvCostTimeSec = int(time.Now().Unix()) |
| 156 | 157 | ||
| 157 | //todo 等待提现配置表 | 158 | //todo 等待提现配置表 |
| @@ -200,6 +201,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | @@ -200,6 +201,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s | ||
| 200 | resp.Data.Randnum = initdata.RandNum | 201 | resp.Data.Randnum = initdata.RandNum |
| 201 | resp.Data.Speciallevel = initdata.SpecialLevel | 202 | resp.Data.Speciallevel = initdata.SpecialLevel |
| 202 | resp.Data.Specialguannum = initdata.SpecialNum | 203 | resp.Data.Specialguannum = initdata.SpecialNum |
| 204 | + resp.Data.Tili = initdata.Tili | ||
| 203 | 205 | ||
| 204 | err := SaveUserInfo(&initdata, uniqueuid) | 206 | err := SaveUserInfo(&initdata, uniqueuid) |
| 205 | logger.Info("InitUserInfoddddd uinfo=%+v", initdata) | 207 | logger.Info("InitUserInfoddddd uinfo=%+v", initdata) |
src/HttpServer/logic/httpserver.go
| @@ -45,6 +45,7 @@ func startServerHttpServe() { | @@ -45,6 +45,7 @@ func startServerHttpServe() { | ||
| 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/uploadspeciallevel", Uploadspeciallevel) //上报当前等级 |
| 48 | + http.HandleFunc("/brainhole/uploadtili", Uploadtili) //上报当前体力 | ||
| 48 | http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 | 49 | http.HandleFunc("/brainhole/fetchredbag", Fetchredbag) //领取红包 |
| 49 | 50 | ||
| 50 | 51 | ||
| @@ -96,6 +97,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) { | @@ -96,6 +97,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) { | ||
| 96 | HandlerGetcash(w, s, Uuid) | 97 | HandlerGetcash(w, s, Uuid) |
| 97 | } | 98 | } |
| 98 | 99 | ||
| 100 | +func Uploadtili(w http.ResponseWriter, r *http.Request) { | ||
| 101 | + | ||
| 102 | + Uuid := 0 | ||
| 103 | + if len(r.Header) > 0 { | ||
| 104 | + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid")) | ||
| 105 | + } | ||
| 106 | + | ||
| 107 | + if Uuid == 0 { | ||
| 108 | + SetHeader(w) | ||
| 109 | + //logger.Error("Uuid is nil!") | ||
| 110 | + return | ||
| 111 | + } | ||
| 112 | + result, _ := ioutil.ReadAll(r.Body) | ||
| 113 | + r.Body.Close() | ||
| 114 | + | ||
| 115 | + s := string(result) | ||
| 116 | + logger.Info("Uploadtili , body:%v,uuid=%v", s, Uuid) | ||
| 117 | + | ||
| 118 | + HandlerUploadtili(w, s, Uuid) | ||
| 119 | +} | ||
| 120 | + | ||
| 99 | func Fetchredbag(w http.ResponseWriter, r *http.Request) { | 121 | func Fetchredbag(w http.ResponseWriter, r *http.Request) { |
| 100 | 122 | ||
| 101 | Uuid := 0 | 123 | Uuid := 0 |
src/HttpServer/logic/logic.go
| @@ -209,6 +209,46 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -209,6 +209,46 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 209 | 209 | ||
| 210 | } | 210 | } |
| 211 | 211 | ||
| 212 | +func HandlerUploadtili(w http.ResponseWriter, data string, uuid int) { | ||
| 213 | + SetHeader(w) | ||
| 214 | + llock.Lock() | ||
| 215 | + defer llock.Unlock() | ||
| 216 | + var resp UploadtiliResp | ||
| 217 | + resp.Code = 0 | ||
| 218 | + var rdata UploadtiliReq | ||
| 219 | + err := json.Unmarshal([]byte(data), &rdata) | ||
| 220 | + for { | ||
| 221 | + if err != nil { | ||
| 222 | + logger.Info("json decode HandlerUploadspeciallevel data failed:%v,for:%v", err, data) | ||
| 223 | + resp.Message = "json解析错误" | ||
| 224 | + resp.Code = 1 | ||
| 225 | + break | ||
| 226 | + } | ||
| 227 | + | ||
| 228 | + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel | ||
| 229 | + uinfo, err := GetUserInfo(uniqueuuid) | ||
| 230 | + if err != nil || uinfo == nil { | ||
| 231 | + logger.Error("redis failed err=%v", err) | ||
| 232 | + resp.Message = "服务器错误" | ||
| 233 | + resp.Code = 1 | ||
| 234 | + break | ||
| 235 | + } | ||
| 236 | + | ||
| 237 | + uinfo.Tili = rdata.Tili | ||
| 238 | + | ||
| 239 | + | ||
| 240 | + SaveUserInfo(uinfo,uniqueuuid) | ||
| 241 | + | ||
| 242 | + resp.Code = 0 | ||
| 243 | + break | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + //回包 | ||
| 247 | + respstr, _ := json.Marshal(&resp) | ||
| 248 | + fmt.Fprint(w, string(respstr)) | ||
| 249 | + | ||
| 250 | +} | ||
| 251 | + | ||
| 212 | func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { | 252 | func HandlerFetchredbag(w http.ResponseWriter, data string, uuid int) { |
| 213 | SetHeader(w) | 253 | SetHeader(w) |
| 214 | llock.Lock() | 254 | llock.Lock() |
| @@ -669,6 +709,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | @@ -669,6 +709,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR | ||
| 669 | resp.Data.Randnum = data.RandNum | 709 | resp.Data.Randnum = data.RandNum |
| 670 | resp.Data.Speciallevel = data.SpecialLevel | 710 | resp.Data.Speciallevel = data.SpecialLevel |
| 671 | resp.Data.Specialguannum = data.SpecialNum | 711 | resp.Data.Specialguannum = data.SpecialNum |
| 712 | + resp.Data.Tili = data.Tili | ||
| 672 | 713 | ||
| 673 | return nil | 714 | return nil |
| 674 | } | 715 | } |
| 675 | \ No newline at end of file | 716 | \ No newline at end of file |