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