Commit 054a41f8eebf385818346f39cf9479ff88efb3f2

Authored by 陆恒
1 parent fa4b984f
Exists in master

提交

src/HttpServer/logic/datadef.go
@@ -79,6 +79,19 @@ type GetcashrecordResp struct { @@ -79,6 +79,19 @@ type GetcashrecordResp struct {
79 Data WithDrawList `json:"data"` 79 Data WithDrawList `json:"data"`
80 } 80 }
81 81
  82 +
  83 +
  84 +type UploadlevelReq struct {
  85 + Level int `json:"level"`
  86 + Gameid string `json:"gameid"`
  87 + Channel string `json:"channel"`
  88 +}
  89 +
  90 +type UploadlevelResp struct {
  91 + Code int `json:"code"`
  92 + Message string `json:"message"`
  93 +}
  94 +
82 //////////////////////////////////////////////////////////////////////////////////////// 95 ////////////////////////////////////////////////////////////////////////////////////////
83 96
84 type GetCashListResp struct { 97 type GetCashListResp struct {
@@ -146,6 +159,7 @@ type UserData struct { @@ -146,6 +159,7 @@ type UserData struct {
146 LeftFreeRB int //剩余免费红包次数 159 LeftFreeRB int //剩余免费红包次数
147 UpLvCostTime int //上一个等级升级时间 160 UpLvCostTime int //上一个等级升级时间
148 UpLvCostTimeSec int //上一个等级升级的时间点时刻 161 UpLvCostTimeSec int //上一个等级升级的时间点时刻
  162 + PassLevel int //当前关卡
149 ReadNum int //玩家微转发阅读量 163 ReadNum int //玩家微转发阅读量
150 GetCashCnt int //当天提现次数 164 GetCashCnt int //当天提现次数
151 WithDraw WithDrawInfo //提现记录信息 165 WithDraw WithDrawInfo //提现记录信息
src/HttpServer/logic/httpserver.go
@@ -41,6 +41,7 @@ func startServerHttpServe() { @@ -41,6 +41,7 @@ func startServerHttpServe() {
41 http.HandleFunc("/brainhole/querygetcashinfo", Querdrawinfo) //获取提现档位信息接口 41 http.HandleFunc("/brainhole/querygetcashinfo", Querdrawinfo) //获取提现档位信息接口
42 http.HandleFunc("/brainhole/getcash", Getcash) //提现 42 http.HandleFunc("/brainhole/getcash", Getcash) //提现
43 http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表 43 http.HandleFunc("/brainhole/getcashrecord", Getcashrecord) //提现记录列表
  44 + http.HandleFunc("/brainhole/uploadlevel", Uploadlevel) //上报当前关卡
44 45
45 46
46 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil) 47 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil)
@@ -90,6 +91,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) { @@ -90,6 +91,27 @@ func Getcash(w http.ResponseWriter, r *http.Request) {
90 HandlerGetcash(w, s, Uuid) 91 HandlerGetcash(w, s, Uuid)
91 } 92 }
92 93
  94 +func Uploadlevel(w http.ResponseWriter, r *http.Request) {
  95 +
  96 + Uuid := 0
  97 + if len(r.Header) > 0 {
  98 + Uuid, _ = strconv.Atoi(r.Header.Get("Uuid"))
  99 + }
  100 +
  101 + if Uuid == 0 {
  102 + SetHeader(w)
  103 + //logger.Error("Uuid is nil!")
  104 + return
  105 + }
  106 + result, _ := ioutil.ReadAll(r.Body)
  107 + r.Body.Close()
  108 +
  109 + s := string(result)
  110 + logger.Info("Uploadlevel , body:%v,uuid=%v", s, Uuid)
  111 +
  112 + HandlerUploadlevel(w, s, Uuid)
  113 +}
  114 +
93 func Getcashrecord(w http.ResponseWriter, r *http.Request) { 115 func Getcashrecord(w http.ResponseWriter, r *http.Request) {
94 116
95 Uuid := 0 117 Uuid := 0
src/HttpServer/logic/logic.go
@@ -192,6 +192,43 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { @@ -192,6 +192,43 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) {
192 192
193 } 193 }
194 194
  195 +func HandlerUploadlevel(w http.ResponseWriter, data string, uuid int) {
  196 + SetHeader(w)
  197 + var resp UploadlevelResp
  198 + resp.Code = 0
  199 + var rdata UploadlevelReq
  200 + err := json.Unmarshal([]byte(data), &rdata)
  201 + for {
  202 + if err != nil {
  203 + logger.Info("json decode HandlerUploadlevel data failed:%v,for:%v", err, data)
  204 + resp.Message = "json解析错误"
  205 + resp.Code = 1
  206 + break
  207 + }
  208 +
  209 + uniqueuuid := strconv.Itoa(uuid) + rdata.Channel
  210 + uinfo, err := GetUserInfo(uniqueuuid)
  211 + if err != nil || uinfo == nil {
  212 + logger.Error("redis failed err=%v", err)
  213 + resp.Message = "服务器错误"
  214 + resp.Code = 1
  215 + break
  216 + }
  217 +
  218 + uinfo.PassLevel = rdata.Level
  219 +
  220 + SaveUserInfo(uinfo,uniqueuuid)
  221 +
  222 + resp.Code = 0
  223 + break
  224 + }
  225 +
  226 + //回包
  227 + respstr, _ := json.Marshal(&resp)
  228 + fmt.Fprint(w, string(respstr))
  229 +
  230 +}
  231 +
195 func HandlerGetcashrecord(w http.ResponseWriter, data string, uuid int) { 232 func HandlerGetcashrecord(w http.ResponseWriter, data string, uuid int) {
196 SetHeader(w) 233 SetHeader(w)
197 var resp GetcashrecordResp 234 var resp GetcashrecordResp