Commit 14d97d3a9db46c4ee164a38d1efa8d835a45d0ef

Authored by 陆恒
1 parent 6aa15284

提交修复bug

src/HttpServer/logic/datadef.go
... ... @@ -62,6 +62,8 @@ type GetguangoldResp struct {
62 62  
63 63 type DrawguangoldReq struct {
64 64 Goldnum int `json:"goldnum"`
  65 + Gameid string `json:"gameid"`
  66 + Channel string `json:"channel"`
65 67 }
66 68  
67 69 type DrawguangoldData struct {
... ...
src/HttpServer/logic/errordef.go
... ... @@ -9,4 +9,5 @@ const (
9 9 ERROR_GETCONFIG_FAILED =4 //获取配置失败
10 10 ERROR_GUANGOLD_NOTENOUGH =5 //存钱罐金币不足
11 11 ERROR_DRAWGUAN_FAILED =6 //从存钱罐提取金币不满足限制
  12 + ERROR_DRAWGOLD_FAILED =7 //从存钱罐提取金币失败了
12 13 )
13 14 \ No newline at end of file
... ...
src/HttpServer/logic/function.go
1 1 package logic
2 2  
3 3 import (
  4 + "HttpServer/jsonconf"
4 5 "HttpServer/redishandler"
5 6 "common/redis"
6 7 "encoding/json"
... ... @@ -66,7 +67,21 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int) error{
66 67  
67 68 //计算当日可提取次数
68 69 func (u *UserData) CalcTotalCnt() int {
69   - return 0
  70 + maxtime := 0
  71 + usertime := 0
  72 + for _,val := range jsonconf.GetJsonConf().MoneyBoxTimeConfig {
  73 + if maxtime < val.Times {
  74 + maxtime = val.Times
  75 + }
  76 + if val.Login == u.ContinueLoginDay {
  77 + usertime = val.Times
  78 + }
  79 + }
  80 +
  81 + if usertime == 0 {
  82 + usertime = maxtime
  83 + }
  84 + return usertime
70 85 }
71 86  
72 87 func (u *UserData) HandlePassDay() {
... ... @@ -128,4 +143,9 @@ func GetUserData(uuid int, resp *UserLoginResp) error{
128 143 resp.Data.Guangold = data.GuanGold
129 144  
130 145 return nil
  146 +}
  147 +
  148 +func AddCoinToSdk(uuid int,goldnum int,gameid string,channel string,atype int) (int,error) {
  149 +
  150 + return 0,nil
131 151 }
132 152 \ No newline at end of file
... ...
src/HttpServer/logic/httpserver.go
... ... @@ -40,7 +40,7 @@ func startServerHttpServe() {
40 40  
41 41 http.HandleFunc("/eliminatestar/login", UserLogin) //登录
42 42 http.HandleFunc("/eliminatestar/watchads", Watchads) //观看激励视频
43   - http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //观看激励视频
  43 + http.HandleFunc("/eliminatestar/queryguaninfo", Queryguaninfo) //获取存钱罐数据
44 44 http.HandleFunc("/eliminatestar/getguangold", Getguangold) //获取金币到存钱罐
45 45 http.HandleFunc("/eliminatestar/drawguangold", Drawguangold) //提取存钱罐的金币到个人钱包
46 46 err := http.ListenAndServe(conf.GetServerHttpAddrConf(), nil)
... ...
src/HttpServer/logic/logic.go
... ... @@ -20,7 +20,7 @@ func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) {
20 20 uinfo,err := GetUserInfo(uuid)
21 21 if err != nil || uinfo == nil{
22 22 logger.Error("redis failed err=%v", err)
23   - resp.Message = "ERROR_SRV_ERROR"
  23 + resp.Message = "服务器错误"
24 24 resp.Code = ERROR_SRV_ERROR
25 25 break
26 26 }
... ... @@ -29,7 +29,7 @@ func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) {
29 29 mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv)
30 30 if mcfg==nil {
31 31 logger.Error("GetMoneyBoxCfg failed err=%v", err)
32   - resp.Message = "ERROR_GETCONFIG_FAILED"
  32 + resp.Message = "存钱罐金币不足"
33 33 resp.Code = ERROR_GETCONFIG_FAILED
34 34 break
35 35 }
... ... @@ -60,14 +60,14 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) {
60 60 uinfo,err := GetUserInfo(uuid)
61 61 if err != nil || uinfo == nil{
62 62 logger.Error("redis failed err=%v", err)
63   - resp.Message = "ERROR_SRV_ERROR"
  63 + resp.Message = "服务器错误"
64 64 resp.Code = ERROR_SRV_ERROR
65 65 break
66 66 }
67 67  
68 68 if uinfo.WatchAddsTime == 0 {
69 69 logger.Error("WatchAddsTime zero")
70   - resp.Message = "WatchAddsTime zero"
  70 + resp.Message = "看视频次数已经耗尽"
71 71 resp.Code = ERROR_WATCHADS_ZEOR
72 72 break
73 73 }
... ... @@ -76,7 +76,7 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) {
76 76 err = SaveUserInfo(uinfo)
77 77 if err != nil {
78 78 logger.Error("redis failed err=%v", err)
79   - resp.Message = "ERROR_SRV_ERROR"
  79 + resp.Message = "服务器错误"
80 80 resp.Code = ERROR_SRV_ERROR
81 81 break
82 82 }
... ... @@ -102,7 +102,7 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) {
102 102 for {
103 103 if err != nil {
104 104 logger.Info("json decode HandlerDrawguangold data failed:%v,for:%v", err, data)
105   - resp.Message = "json unmarshal failed"
  105 + resp.Message = "json解析错误"
106 106 resp.Code = ERROR_JSONUNMASH_ERROR
107 107 break
108 108 }
... ... @@ -110,14 +110,14 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) {
110 110 uinfo,err := GetUserInfo(uuid)
111 111 if err != nil || uinfo == nil{
112 112 logger.Error("redis failed err=%v", err)
113   - resp.Message = "ERROR_SRV_ERROR"
  113 + resp.Message = "服务器错误"
114 114 resp.Code = ERROR_SRV_ERROR
115 115 break
116 116 }
117 117 //首先判断一下存钱罐的金币是否足够
118   - if rdata.Goldnum < uinfo.GuanGold {
119   - logger.Error("guangold not enough ")
120   - resp.Message = "ERROR_SRV_ERROR"
  118 + if rdata.Goldnum > uinfo.GuanGold {
  119 + logger.Error("guangold not enough rdata.Goldnum=%v uinfo.GuanGold=%v",rdata.Goldnum,uinfo.GuanGold)
  120 + resp.Message = "存钱罐金币不足"
121 121 resp.Code = ERROR_GUANGOLD_NOTENOUGH
122 122 break
123 123 }
... ... @@ -136,23 +136,31 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) {
136 136 mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv)
137 137 if mcfg==nil {
138 138 logger.Error("GetMoneyBoxCfg failed err=%v", err)
139   - resp.Message = "ERROR_GETCONFIG_FAILED"
  139 + resp.Message = "获取配置失败"
140 140 resp.Code = ERROR_GETCONFIG_FAILED
141 141 break
142 142 }
143 143  
144 144 if rdata.Goldnum < mcfg.Min || rdata.Goldnum > mcfg.Max {
145 145 logger.Error("GetMoneyBoxCfg failed err=%v", err)
146   - resp.Message = "ERROR_DRAWGUAN_FAILED"
  146 + resp.Message = "从存钱罐提取金币不满足限制"
147 147 resp.Code = ERROR_DRAWGUAN_FAILED
148 148 break
149 149 }
150 150  
151   - uinfo.GuanGold = uinfo.GuanGold - rdata.Goldnum
152   - uinfo.RealGold += rdata.Goldnum
  151 +
153 152  
154 153 //todo 此处需要调佣SDK接口通知金币变化
  154 + realnum,err := AddCoinToSdk(uuid,rdata.Goldnum,rdata.Gameid,rdata.Channel,100)
  155 + if err != nil {
  156 + logger.Error("Drawgold failed err=%v", err)
  157 + resp.Message = "从存钱罐提取金币失败了"
  158 + resp.Code = ERROR_DRAWGOLD_FAILED
  159 + break
  160 + }
155 161  
  162 + uinfo.GuanGold = uinfo.GuanGold - rdata.Goldnum
  163 + uinfo.RealGold = realnum
156 164  
157 165 resp.Data.Guangold = uinfo.GuanGold
158 166 resp.Data.Wallgold = uinfo.RealGold
... ... @@ -179,7 +187,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) {
179 187 for {
180 188 if err != nil {
181 189 logger.Info("json decode HandlerGetguangold data failed:%v,for:%v", err, data)
182   - resp.Message = "json unmarshal failed"
  190 + resp.Message = "json解析错误"
183 191 resp.Code = ERROR_JSONUNMASH_ERROR
184 192 break
185 193 }
... ... @@ -187,7 +195,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) {
187 195 uinfo,err := GetUserInfo(uuid)
188 196 if err != nil || uinfo == nil{
189 197 logger.Error("redis failed err=%v", err)
190   - resp.Message = "ERROR_SRV_ERROR"
  198 + resp.Message = "服务器错误"
191 199 resp.Code = ERROR_SRV_ERROR
192 200 break
193 201 }
... ... @@ -196,7 +204,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) {
196 204 mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv)
197 205 if mcfg==nil {
198 206 logger.Error("GetMoneyBoxCfg failed err=%v", err)
199   - resp.Message = "ERROR_GETCONFIG_FAILED"
  207 + resp.Message = "获取配置失败"
200 208 resp.Code = ERROR_GETCONFIG_FAILED
201 209 break
202 210 }
... ... @@ -229,7 +237,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) {
229 237 for {
230 238 if err != nil {
231 239 logger.Info("json decode HandlerLogin data failed:%v,for:%v", err, data)
232   - resp.Message = "json unmarshal failed"
  240 + resp.Message = "json解析错误"
233 241 resp.Code = ERROR_JSONUNMASH_ERROR
234 242 break
235 243 }
... ... @@ -238,7 +246,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) {
238 246 isexist,err := redishandler.GetRedisClient().HExists(redis.USER_DATA_KEY, strconv.Itoa(uuid))
239 247 if err != nil {
240 248 logger.Error("redis failed err=%v", err)
241   - resp.Message = "ERROR_SRV_ERROR"
  249 + resp.Message = "服务器错误"
242 250 resp.Code = ERROR_SRV_ERROR
243 251 break
244 252 }
... ... @@ -254,7 +262,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) {
254 262  
255 263 if err != nil {
256 264 logger.Error("redis failed err=%v", err)
257   - resp.Message = "ERROR_SRV_ERROR"
  265 + resp.Message = "服务器错误"
258 266 resp.Code = ERROR_SRV_ERROR
259 267 break
260 268 }
... ...