Commit 7a88e9835e791885195c516f8808b52afbe41e5f
1 parent
55c2be39
Exists in
master
and in
4 other branches
添加打印
Showing
2 changed files
with
65 additions
and
86 deletions
Show diff stats
src/HttpServer/logic/function.go
| @@ -322,6 +322,7 @@ func (uinfo *UserData) HandleGetTaskReward(req *GettaskrewardReq, resp *Gettaskr | @@ -322,6 +322,7 @@ func (uinfo *UserData) HandleGetTaskReward(req *GettaskrewardReq, resp *Gettaskr | ||
| 322 | } | 322 | } |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | + logger.Info("HandleGetTaskReward index=%v taskdesc=%v", index, taskdesc) | ||
| 325 | if isfind && taskdesc != nil && index != -1 { | 326 | if isfind && taskdesc != nil && index != -1 { |
| 326 | if taskdesc.Taskstatus != 2 { | 327 | if taskdesc.Taskstatus != 2 { |
| 327 | //状态不是可领取状态 无法领取 | 328 | //状态不是可领取状态 无法领取 |
src/HttpServer/logic/logic.go
| @@ -12,14 +12,13 @@ import ( | @@ -12,14 +12,13 @@ import ( | ||
| 12 | "time" | 12 | "time" |
| 13 | ) | 13 | ) |
| 14 | 14 | ||
| 15 | - | ||
| 16 | func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) { | 15 | func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) { |
| 17 | SetHeader(w) | 16 | SetHeader(w) |
| 18 | var resp QueryguaninfoResp | 17 | var resp QueryguaninfoResp |
| 19 | resp.Code = 0 | 18 | resp.Code = 0 |
| 20 | for { | 19 | for { |
| 21 | - uinfo,err := GetUserInfo(uuid) | ||
| 22 | - if err != nil || uinfo == nil{ | 20 | + uinfo, err := GetUserInfo(uuid) |
| 21 | + if err != nil || uinfo == nil { | ||
| 23 | logger.Error("redis failed err=%v", err) | 22 | logger.Error("redis failed err=%v", err) |
| 24 | resp.Message = "服务器错误" | 23 | resp.Message = "服务器错误" |
| 25 | resp.Code = ERROR_SRV_ERROR | 24 | resp.Code = ERROR_SRV_ERROR |
| @@ -28,14 +27,13 @@ func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) { | @@ -28,14 +27,13 @@ func HandlerQueryguaninfo(w http.ResponseWriter, data string, uuid int) { | ||
| 28 | 27 | ||
| 29 | //获取存钱罐等级配置 | 28 | //获取存钱罐等级配置 |
| 30 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) | 29 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) |
| 31 | - if mcfg==nil { | 30 | + if mcfg == nil { |
| 32 | logger.Error("GetMoneyBoxCfg failed err=%v", err) | 31 | logger.Error("GetMoneyBoxCfg failed err=%v", err) |
| 33 | resp.Message = "存钱罐金币不足" | 32 | resp.Message = "存钱罐金币不足" |
| 34 | resp.Code = ERROR_GETCONFIG_FAILED | 33 | resp.Code = ERROR_GETCONFIG_FAILED |
| 35 | break | 34 | break |
| 36 | } | 35 | } |
| 37 | 36 | ||
| 38 | - | ||
| 39 | resp.Data.Guangold = uinfo.GuanGold | 37 | resp.Data.Guangold = uinfo.GuanGold |
| 40 | resp.Data.Loginday = uinfo.ContinueLoginDay | 38 | resp.Data.Loginday = uinfo.ContinueLoginDay |
| 41 | resp.Data.Totalcnt = uinfo.CalcTotalCnt() | 39 | resp.Data.Totalcnt = uinfo.CalcTotalCnt() |
| @@ -58,8 +56,8 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | @@ -58,8 +56,8 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | ||
| 58 | resp.Code = 0 | 56 | resp.Code = 0 |
| 59 | 57 | ||
| 60 | for { | 58 | for { |
| 61 | - uinfo,err := GetUserInfo(uuid) | ||
| 62 | - if err != nil || uinfo == nil{ | 59 | + uinfo, err := GetUserInfo(uuid) |
| 60 | + if err != nil || uinfo == nil { | ||
| 63 | logger.Error("redis failed err=%v", err) | 61 | logger.Error("redis failed err=%v", err) |
| 64 | resp.Message = "服务器错误" | 62 | resp.Message = "服务器错误" |
| 65 | resp.Code = ERROR_SRV_ERROR | 63 | resp.Code = ERROR_SRV_ERROR |
| @@ -73,7 +71,7 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | @@ -73,7 +71,7 @@ func HandlerWatchads(w http.ResponseWriter, data string, uuid int) { | ||
| 73 | break | 71 | break |
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | - uinfo.WatchAddsTime -- | 74 | + uinfo.WatchAddsTime-- |
| 77 | err = SaveUserInfo(uinfo) | 75 | err = SaveUserInfo(uinfo) |
| 78 | if err != nil { | 76 | if err != nil { |
| 79 | logger.Error("redis failed err=%v", err) | 77 | logger.Error("redis failed err=%v", err) |
| @@ -105,24 +103,24 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -105,24 +103,24 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 105 | resp.Code = ERROR_JSONUNMASH_ERROR | 103 | resp.Code = ERROR_JSONUNMASH_ERROR |
| 106 | break | 104 | break |
| 107 | } | 105 | } |
| 108 | - uinfo,err := GetUserInfo(uuid) | ||
| 109 | - if err != nil || uinfo == nil{ | 106 | + uinfo, err := GetUserInfo(uuid) |
| 107 | + if err != nil || uinfo == nil { | ||
| 110 | logger.Error("redis failed err=%v", err) | 108 | logger.Error("redis failed err=%v", err) |
| 111 | resp.Message = "服务器错误" | 109 | resp.Message = "服务器错误" |
| 112 | resp.Code = ERROR_SRV_ERROR | 110 | resp.Code = ERROR_SRV_ERROR |
| 113 | break | 111 | break |
| 114 | } | 112 | } |
| 115 | 113 | ||
| 116 | - drawnum := int(rdata.Money*100) | 114 | + drawnum := int(rdata.Money * 100) |
| 117 | //需要判断一下金币是否足够 | 115 | //需要判断一下金币是否足够 |
| 118 | - if drawnum * 100 > uinfo.RealGold { | 116 | + if drawnum*100 > uinfo.RealGold { |
| 119 | logger.Error("gold nor enough failed err=%v", err) | 117 | logger.Error("gold nor enough failed err=%v", err) |
| 120 | resp.Message = "提现金币不足" | 118 | resp.Message = "提现金币不足" |
| 121 | resp.Code = ERROR_GETCASH_GOLDNOTENOUGH_FAILED | 119 | resp.Code = ERROR_GETCASH_GOLDNOTENOUGH_FAILED |
| 122 | break | 120 | break |
| 123 | } | 121 | } |
| 124 | 122 | ||
| 125 | - _,err = GetCashFromSDK(uuid,drawnum,rdata.Gameid,rdata.Channel,rdata.Openid,rdata.Nickname,rdata.Headurl) | 123 | + _, err = GetCashFromSDK(uuid, drawnum, rdata.Gameid, rdata.Channel, rdata.Openid, rdata.Nickname, rdata.Headurl) |
| 126 | if err != nil { | 124 | if err != nil { |
| 127 | logger.Error("GetCashFromSDK failed err=%v", err) | 125 | logger.Error("GetCashFromSDK failed err=%v", err) |
| 128 | resp.Message = "从后台提现失败了" | 126 | resp.Message = "从后台提现失败了" |
| @@ -130,7 +128,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -130,7 +128,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 130 | break | 128 | break |
| 131 | } | 129 | } |
| 132 | 130 | ||
| 133 | - index,info := uinfo.GetWithDrawData(rdata.Money) | 131 | + index, info := uinfo.GetWithDrawData(rdata.Money) |
| 134 | if index == -1 || info == nil { | 132 | if index == -1 || info == nil { |
| 135 | logger.Error("AddWithDrawList failed err=%v", err) | 133 | logger.Error("AddWithDrawList failed err=%v", err) |
| 136 | resp.Message = "网络错误" | 134 | resp.Message = "网络错误" |
| @@ -160,10 +158,10 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -160,10 +158,10 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 160 | } | 158 | } |
| 161 | 159 | ||
| 162 | //判断一下前置条件的下一档 | 160 | //判断一下前置条件的下一档 |
| 163 | - if index == len(uinfo.WithDraw.Cashdata) - 1 { | 161 | + if index == len(uinfo.WithDraw.Cashdata)-1 { |
| 164 | //最后一档了不用处理 | 162 | //最后一档了不用处理 |
| 165 | - }else { | ||
| 166 | - if index < len(uinfo.WithDraw.Cashdata) - 1{ | 163 | + } else { |
| 164 | + if index < len(uinfo.WithDraw.Cashdata)-1 { | ||
| 167 | uinfo.WithDraw.Cashdata[index+1].Preisfind = 1 | 165 | uinfo.WithDraw.Cashdata[index+1].Preisfind = 1 |
| 168 | } | 166 | } |
| 169 | } | 167 | } |
| @@ -172,7 +170,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -172,7 +170,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 172 | data := new(WithDrawRecord) | 170 | data := new(WithDrawRecord) |
| 173 | data.Withdrawmoney = rdata.Money | 171 | data.Withdrawmoney = rdata.Money |
| 174 | data.Withdrawtime = int(time.Now().Unix()) | 172 | data.Withdrawtime = int(time.Now().Unix()) |
| 175 | - err = AddWithDrawList(uuid,data) | 173 | + err = AddWithDrawList(uuid, data) |
| 176 | if err != nil { | 174 | if err != nil { |
| 177 | logger.Error("AddWithDrawList failed err=%v", err) | 175 | logger.Error("AddWithDrawList failed err=%v", err) |
| 178 | resp.Message = "网络错误" | 176 | resp.Message = "网络错误" |
| @@ -180,8 +178,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -180,8 +178,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 180 | break | 178 | break |
| 181 | } | 179 | } |
| 182 | 180 | ||
| 183 | - | ||
| 184 | - | ||
| 185 | if info.Isnew == 1 { | 181 | if info.Isnew == 1 { |
| 186 | uinfo.WithDraw.Cashdata[index].Isnew = 0 | 182 | uinfo.WithDraw.Cashdata[index].Isnew = 0 |
| 187 | } | 183 | } |
| @@ -191,7 +187,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -191,7 +187,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 191 | resp.Data.Walletgold = uinfo.RealGold | 187 | resp.Data.Walletgold = uinfo.RealGold |
| 192 | SaveUserInfo(uinfo) | 188 | SaveUserInfo(uinfo) |
| 193 | 189 | ||
| 194 | - | ||
| 195 | resp.Code = ERROR_OK | 190 | resp.Code = ERROR_OK |
| 196 | break | 191 | break |
| 197 | } | 192 | } |
| @@ -202,8 +197,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | @@ -202,8 +197,6 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { | ||
| 202 | 197 | ||
| 203 | } | 198 | } |
| 204 | 199 | ||
| 205 | - | ||
| 206 | - | ||
| 207 | func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | 200 | func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { |
| 208 | SetHeader(w) | 201 | SetHeader(w) |
| 209 | var resp GetnewlevelrewardResp | 202 | var resp GetnewlevelrewardResp |
| @@ -217,8 +210,8 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | @@ -217,8 +210,8 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | ||
| 217 | resp.Code = ERROR_JSONUNMASH_ERROR | 210 | resp.Code = ERROR_JSONUNMASH_ERROR |
| 218 | break | 211 | break |
| 219 | } | 212 | } |
| 220 | - uinfo,err := GetUserInfo(uuid) | ||
| 221 | - if err != nil || uinfo == nil{ | 213 | + uinfo, err := GetUserInfo(uuid) |
| 214 | + if err != nil || uinfo == nil { | ||
| 222 | logger.Error("redis failed err=%v", err) | 215 | logger.Error("redis failed err=%v", err) |
| 223 | resp.Message = "服务器错误" | 216 | resp.Message = "服务器错误" |
| 224 | resp.Code = ERROR_SRV_ERROR | 217 | resp.Code = ERROR_SRV_ERROR |
| @@ -241,7 +234,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | @@ -241,7 +234,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | ||
| 241 | break | 234 | break |
| 242 | } | 235 | } |
| 243 | 236 | ||
| 244 | - _,err = AddCoinToSdk(uuid,cfg.Cash,rdata.Gameid,rdata.Channel,100) | 237 | + _, err = AddCoinToSdk(uuid, cfg.Cash, rdata.Gameid, rdata.Channel, 100) |
| 245 | if err != nil { | 238 | if err != nil { |
| 246 | logger.Error("AddCoinToSdk failed err=%v", err) | 239 | logger.Error("AddCoinToSdk failed err=%v", err) |
| 247 | resp.Message = "网络错误" | 240 | resp.Message = "网络错误" |
| @@ -251,7 +244,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | @@ -251,7 +244,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | ||
| 251 | uinfo.RealGold += cfg.Cash | 244 | uinfo.RealGold += cfg.Cash |
| 252 | 245 | ||
| 253 | if rdata.Rewardtype == 2 { | 246 | if rdata.Rewardtype == 2 { |
| 254 | - _,err = AddCoinToSdk(uuid,cfg.Extracash,rdata.Gameid,rdata.Channel,100) | 247 | + _, err = AddCoinToSdk(uuid, cfg.Extracash, rdata.Gameid, rdata.Channel, 100) |
| 255 | if err != nil { | 248 | if err != nil { |
| 256 | logger.Error("AddCoinToSdk failed err=%v", err) | 249 | logger.Error("AddCoinToSdk failed err=%v", err) |
| 257 | resp.Message = "网络错误" | 250 | resp.Message = "网络错误" |
| @@ -261,12 +254,11 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | @@ -261,12 +254,11 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | ||
| 261 | uinfo.RealGold += cfg.Extracash | 254 | uinfo.RealGold += cfg.Extracash |
| 262 | } | 255 | } |
| 263 | 256 | ||
| 264 | - uinfo.LvRewardGet = 1 +rdata.Rewardtype | 257 | + uinfo.LvRewardGet = 1 + rdata.Rewardtype |
| 265 | 258 | ||
| 266 | //保存数据 | 259 | //保存数据 |
| 267 | SaveUserInfo(uinfo) | 260 | SaveUserInfo(uinfo) |
| 268 | 261 | ||
| 269 | - | ||
| 270 | resp.Code = ERROR_OK | 262 | resp.Code = ERROR_OK |
| 271 | break | 263 | break |
| 272 | } | 264 | } |
| @@ -277,7 +269,6 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | @@ -277,7 +269,6 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { | ||
| 277 | 269 | ||
| 278 | } | 270 | } |
| 279 | 271 | ||
| 280 | - | ||
| 281 | func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | 272 | func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { |
| 282 | SetHeader(w) | 273 | SetHeader(w) |
| 283 | var resp GettaskrewardResp | 274 | var resp GettaskrewardResp |
| @@ -291,8 +282,8 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | @@ -291,8 +282,8 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | ||
| 291 | resp.Code = ERROR_JSONUNMASH_ERROR | 282 | resp.Code = ERROR_JSONUNMASH_ERROR |
| 292 | break | 283 | break |
| 293 | } | 284 | } |
| 294 | - uinfo,err := GetUserInfo(uuid) | ||
| 295 | - if err != nil || uinfo == nil{ | 285 | + uinfo, err := GetUserInfo(uuid) |
| 286 | + if err != nil || uinfo == nil { | ||
| 296 | logger.Error("redis failed err=%v", err) | 287 | logger.Error("redis failed err=%v", err) |
| 297 | resp.Message = "服务器错误" | 288 | resp.Message = "服务器错误" |
| 298 | resp.Code = ERROR_SRV_ERROR | 289 | resp.Code = ERROR_SRV_ERROR |
| @@ -302,16 +293,16 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | @@ -302,16 +293,16 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | ||
| 302 | //需要先计算出任务或者成就 | 293 | //需要先计算出任务或者成就 |
| 303 | var tasklist *TaskList | 294 | var tasklist *TaskList |
| 304 | //先查询一下当前的任务数据 | 295 | //先查询一下当前的任务数据 |
| 305 | - tasklist,err = GetTaskInfo(uuid,rdata.Tasktype) | ||
| 306 | - if err != nil || tasklist==nil{ | 296 | + tasklist, err = GetTaskInfo(uuid, rdata.Tasktype) |
| 297 | + if err != nil || tasklist == nil { | ||
| 307 | logger.Error("GetTaskInfo failed err=%v", err) | 298 | logger.Error("GetTaskInfo failed err=%v", err) |
| 308 | resp.Message = "服务器错误" | 299 | resp.Message = "服务器错误" |
| 309 | resp.Code = ERROR_SRV_ERROR | 300 | resp.Code = ERROR_SRV_ERROR |
| 310 | break | 301 | break |
| 311 | } | 302 | } |
| 312 | 303 | ||
| 313 | - | ||
| 314 | - err = uinfo.HandleGetTaskReward(&rdata,&resp,tasklist) | 304 | + err = uinfo.HandleGetTaskReward(&rdata, &resp, tasklist) |
| 305 | + logger.Info("HandlerGettaskreward tasklist=%v", tasklist) | ||
| 315 | if err != nil { | 306 | if err != nil { |
| 316 | logger.Error("HandleGetTaskReward failed err=%v", err) | 307 | logger.Error("HandleGetTaskReward failed err=%v", err) |
| 317 | resp.Message = "服务器错误" | 308 | resp.Message = "服务器错误" |
| @@ -321,7 +312,7 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | @@ -321,7 +312,7 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | ||
| 321 | 312 | ||
| 322 | //保存数据 | 313 | //保存数据 |
| 323 | SaveUserInfo(uinfo) | 314 | SaveUserInfo(uinfo) |
| 324 | - SaveTaskInfo(uinfo.Userid,rdata.Tasktype,tasklist) | 315 | + SaveTaskInfo(uinfo.Userid, rdata.Tasktype, tasklist) |
| 325 | 316 | ||
| 326 | resp.Code = ERROR_OK | 317 | resp.Code = ERROR_OK |
| 327 | break | 318 | break |
| @@ -333,8 +324,6 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | @@ -333,8 +324,6 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { | ||
| 333 | 324 | ||
| 334 | } | 325 | } |
| 335 | 326 | ||
| 336 | - | ||
| 337 | - | ||
| 338 | func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | 327 | func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { |
| 339 | SetHeader(w) | 328 | SetHeader(w) |
| 340 | var resp QuerytaskinfoResp | 329 | var resp QuerytaskinfoResp |
| @@ -348,8 +337,8 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | @@ -348,8 +337,8 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 348 | resp.Code = ERROR_JSONUNMASH_ERROR | 337 | resp.Code = ERROR_JSONUNMASH_ERROR |
| 349 | break | 338 | break |
| 350 | } | 339 | } |
| 351 | - uinfo,err := GetUserInfo(uuid) | ||
| 352 | - if err != nil || uinfo == nil{ | 340 | + uinfo, err := GetUserInfo(uuid) |
| 341 | + if err != nil || uinfo == nil { | ||
| 353 | logger.Error("redis failed err=%v", err) | 342 | logger.Error("redis failed err=%v", err) |
| 354 | resp.Message = "服务器错误" | 343 | resp.Message = "服务器错误" |
| 355 | resp.Code = ERROR_SRV_ERROR | 344 | resp.Code = ERROR_SRV_ERROR |
| @@ -359,21 +348,19 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | @@ -359,21 +348,19 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 359 | //需要先计算出任务或者成就 | 348 | //需要先计算出任务或者成就 |
| 360 | var tasklist *TaskList | 349 | var tasklist *TaskList |
| 361 | //先查询一下当前的任务数据 | 350 | //先查询一下当前的任务数据 |
| 362 | - tasklist,err = GetTaskInfo(uuid,rdata.Tasktype) | ||
| 363 | - if err != nil || tasklist==nil{ | 351 | + tasklist, err = GetTaskInfo(uuid, rdata.Tasktype) |
| 352 | + if err != nil || tasklist == nil { | ||
| 364 | logger.Error("redis failed err=%v", err) | 353 | logger.Error("redis failed err=%v", err) |
| 365 | resp.Message = "服务器错误" | 354 | resp.Message = "服务器错误" |
| 366 | resp.Code = ERROR_SRV_ERROR | 355 | resp.Code = ERROR_SRV_ERROR |
| 367 | break | 356 | break |
| 368 | } | 357 | } |
| 369 | 358 | ||
| 370 | - | ||
| 371 | - | ||
| 372 | if rdata.Tasktype == 1 { | 359 | if rdata.Tasktype == 1 { |
| 373 | uinfo.CalcTaskList(tasklist) | 360 | uinfo.CalcTaskList(tasklist) |
| 374 | - }else if rdata.Tasktype == 2 { | 361 | + } else if rdata.Tasktype == 2 { |
| 375 | tasklist = uinfo.CalcAchieveList(tasklist) | 362 | tasklist = uinfo.CalcAchieveList(tasklist) |
| 376 | - }else { | 363 | + } else { |
| 377 | uinfo.CalcTaskList(tasklist) | 364 | uinfo.CalcTaskList(tasklist) |
| 378 | } | 365 | } |
| 379 | 366 | ||
| @@ -384,7 +371,7 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | @@ -384,7 +371,7 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 384 | break | 371 | break |
| 385 | } | 372 | } |
| 386 | 373 | ||
| 387 | - resp.Data.Taskdata = append(resp.Data.Taskdata,tasklist.Taskdata...) | 374 | + resp.Data.Taskdata = append(resp.Data.Taskdata, tasklist.Taskdata...) |
| 388 | 375 | ||
| 389 | resp.Code = ERROR_OK | 376 | resp.Code = ERROR_OK |
| 390 | break | 377 | break |
| @@ -410,8 +397,8 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { | @@ -410,8 +397,8 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { | ||
| 410 | resp.Code = ERROR_JSONUNMASH_ERROR | 397 | resp.Code = ERROR_JSONUNMASH_ERROR |
| 411 | break | 398 | break |
| 412 | } | 399 | } |
| 413 | - uinfo,err := GetUserInfo(uuid) | ||
| 414 | - if err != nil || uinfo == nil{ | 400 | + uinfo, err := GetUserInfo(uuid) |
| 401 | + if err != nil || uinfo == nil { | ||
| 415 | logger.Error("redis failed err=%v", err) | 402 | logger.Error("redis failed err=%v", err) |
| 416 | resp.Message = "服务器错误" | 403 | resp.Message = "服务器错误" |
| 417 | resp.Code = ERROR_SRV_ERROR | 404 | resp.Code = ERROR_SRV_ERROR |
| @@ -431,7 +418,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { | @@ -431,7 +418,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { | ||
| 431 | uinfo.Task.UseItemCnt += rdata.Value | 418 | uinfo.Task.UseItemCnt += rdata.Value |
| 432 | uinfo.Achieve.SumUseItemCnt += rdata.Value | 419 | uinfo.Achieve.SumUseItemCnt += rdata.Value |
| 433 | } | 420 | } |
| 434 | - logger.Info("HandlerUpdatetaskandachieve uinfo=%v rdata=%v",uinfo,rdata) | 421 | + logger.Info("HandlerUpdatetaskandachieve uinfo=%v rdata=%v", uinfo, rdata) |
| 435 | SaveUserInfo(uinfo) | 422 | SaveUserInfo(uinfo) |
| 436 | resp.Code = ERROR_OK | 423 | resp.Code = ERROR_OK |
| 437 | break | 424 | break |
| @@ -449,15 +436,15 @@ func HandlerOnlinentf(w http.ResponseWriter, data string, uuid int) { | @@ -449,15 +436,15 @@ func HandlerOnlinentf(w http.ResponseWriter, data string, uuid int) { | ||
| 449 | resp.Code = 0 | 436 | resp.Code = 0 |
| 450 | for { | 437 | for { |
| 451 | 438 | ||
| 452 | - uinfo,err := GetUserInfo(uuid) | ||
| 453 | - if err != nil || uinfo == nil{ | 439 | + uinfo, err := GetUserInfo(uuid) |
| 440 | + if err != nil || uinfo == nil { | ||
| 454 | logger.Error("redis failed err=%v", err) | 441 | logger.Error("redis failed err=%v", err) |
| 455 | resp.Message = "服务器错误" | 442 | resp.Message = "服务器错误" |
| 456 | resp.Code = ERROR_SRV_ERROR | 443 | resp.Code = ERROR_SRV_ERROR |
| 457 | break | 444 | break |
| 458 | } | 445 | } |
| 459 | 446 | ||
| 460 | - uinfo.Task.OnlineMin ++ | 447 | + uinfo.Task.OnlineMin++ |
| 461 | 448 | ||
| 462 | SaveUserInfo(uinfo) | 449 | SaveUserInfo(uinfo) |
| 463 | 450 | ||
| @@ -476,15 +463,15 @@ func HandlerGetcashrecord(w http.ResponseWriter, data string, uuid int) { | @@ -476,15 +463,15 @@ func HandlerGetcashrecord(w http.ResponseWriter, data string, uuid int) { | ||
| 476 | var resp GetcashrecordResp | 463 | var resp GetcashrecordResp |
| 477 | resp.Code = 0 | 464 | resp.Code = 0 |
| 478 | for { | 465 | for { |
| 479 | - list,err := GetWithDrawList(uuid) | ||
| 480 | - if err != nil || list == nil{ | 466 | + list, err := GetWithDrawList(uuid) |
| 467 | + if err != nil || list == nil { | ||
| 481 | logger.Error("HandlerGetcashrecord failed err=%v", err) | 468 | logger.Error("HandlerGetcashrecord failed err=%v", err) |
| 482 | resp.Message = "服务器错误" | 469 | resp.Message = "服务器错误" |
| 483 | resp.Code = ERROR_SRV_ERROR | 470 | resp.Code = ERROR_SRV_ERROR |
| 484 | break | 471 | break |
| 485 | } | 472 | } |
| 486 | 473 | ||
| 487 | - resp.Data.Withdata = append(resp.Data.Withdata,list.Withdata...) | 474 | + resp.Data.Withdata = append(resp.Data.Withdata, list.Withdata...) |
| 488 | 475 | ||
| 489 | resp.Code = ERROR_OK | 476 | resp.Code = ERROR_OK |
| 490 | break | 477 | break |
| @@ -501,8 +488,8 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -501,8 +488,8 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 501 | var resp QuerdrawinfoResp | 488 | var resp QuerdrawinfoResp |
| 502 | resp.Code = 0 | 489 | resp.Code = 0 |
| 503 | for { | 490 | for { |
| 504 | - uinfo,err := GetUserInfo(uuid) | ||
| 505 | - if err != nil || uinfo == nil{ | 491 | + uinfo, err := GetUserInfo(uuid) |
| 492 | + if err != nil || uinfo == nil { | ||
| 506 | logger.Error("redis failed err=%v", err) | 493 | logger.Error("redis failed err=%v", err) |
| 507 | resp.Message = "服务器错误" | 494 | resp.Message = "服务器错误" |
| 508 | resp.Code = ERROR_SRV_ERROR | 495 | resp.Code = ERROR_SRV_ERROR |
| @@ -510,7 +497,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -510,7 +497,7 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 510 | } | 497 | } |
| 511 | 498 | ||
| 512 | //返回 | 499 | //返回 |
| 513 | - resp.Data.Cashdata = append(resp.Data.Cashdata,uinfo.WithDraw.Cashdata...) | 500 | + resp.Data.Cashdata = append(resp.Data.Cashdata, uinfo.WithDraw.Cashdata...) |
| 514 | 501 | ||
| 515 | resp.Code = ERROR_OK | 502 | resp.Code = ERROR_OK |
| 516 | break | 503 | break |
| @@ -522,7 +509,6 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | @@ -522,7 +509,6 @@ func HandlerQuerdrawinfo(w http.ResponseWriter, data string, uuid int) { | ||
| 522 | 509 | ||
| 523 | } | 510 | } |
| 524 | 511 | ||
| 525 | - | ||
| 526 | func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | 512 | func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { |
| 527 | SetHeader(w) | 513 | SetHeader(w) |
| 528 | var resp DrawguangoldResp | 514 | var resp DrawguangoldResp |
| @@ -537,8 +523,8 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | @@ -537,8 +523,8 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 537 | break | 523 | break |
| 538 | } | 524 | } |
| 539 | 525 | ||
| 540 | - uinfo,err := GetUserInfo(uuid) | ||
| 541 | - if err != nil || uinfo == nil{ | 526 | + uinfo, err := GetUserInfo(uuid) |
| 527 | + if err != nil || uinfo == nil { | ||
| 542 | logger.Error("redis failed err=%v", err) | 528 | logger.Error("redis failed err=%v", err) |
| 543 | resp.Message = "服务器错误" | 529 | resp.Message = "服务器错误" |
| 544 | resp.Code = ERROR_SRV_ERROR | 530 | resp.Code = ERROR_SRV_ERROR |
| @@ -546,7 +532,7 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | @@ -546,7 +532,7 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 546 | } | 532 | } |
| 547 | //首先判断一下存钱罐的金币是否足够 | 533 | //首先判断一下存钱罐的金币是否足够 |
| 548 | if rdata.Goldnum > uinfo.GuanGold { | 534 | if rdata.Goldnum > uinfo.GuanGold { |
| 549 | - logger.Error("guangold not enough rdata.Goldnum=%v uinfo.GuanGold=%v",rdata.Goldnum,uinfo.GuanGold) | 535 | + logger.Error("guangold not enough rdata.Goldnum=%v uinfo.GuanGold=%v", rdata.Goldnum, uinfo.GuanGold) |
| 550 | resp.Message = "存钱罐金币不足" | 536 | resp.Message = "存钱罐金币不足" |
| 551 | resp.Code = ERROR_GUANGOLD_NOTENOUGH | 537 | resp.Code = ERROR_GUANGOLD_NOTENOUGH |
| 552 | break | 538 | break |
| @@ -561,11 +547,11 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | @@ -561,11 +547,11 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 561 | break | 547 | break |
| 562 | } | 548 | } |
| 563 | 549 | ||
| 564 | - uinfo.GetFromGuanCnt ++ | ||
| 565 | - uinfo.Achieve.SumGetGuan ++ | 550 | + uinfo.GetFromGuanCnt++ |
| 551 | + uinfo.Achieve.SumGetGuan++ | ||
| 566 | // | 552 | // |
| 567 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) | 553 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) |
| 568 | - if mcfg==nil { | 554 | + if mcfg == nil { |
| 569 | logger.Error("GetMoneyBoxCfg failed err=%v", err) | 555 | logger.Error("GetMoneyBoxCfg failed err=%v", err) |
| 570 | resp.Message = "获取配置失败" | 556 | resp.Message = "获取配置失败" |
| 571 | resp.Code = ERROR_GETCONFIG_FAILED | 557 | resp.Code = ERROR_GETCONFIG_FAILED |
| @@ -579,10 +565,8 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | @@ -579,10 +565,8 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 579 | break | 565 | break |
| 580 | } | 566 | } |
| 581 | 567 | ||
| 582 | - | ||
| 583 | - | ||
| 584 | //todo 此处需要调佣SDK接口通知金币变化 | 568 | //todo 此处需要调佣SDK接口通知金币变化 |
| 585 | - _,err = AddCoinToSdk(uuid,rdata.Goldnum,rdata.Gameid,rdata.Channel,100) | 569 | + _, err = AddCoinToSdk(uuid, rdata.Goldnum, rdata.Gameid, rdata.Channel, 100) |
| 586 | if err != nil { | 570 | if err != nil { |
| 587 | logger.Error("Drawgold failed err=%v", err) | 571 | logger.Error("Drawgold failed err=%v", err) |
| 588 | resp.Message = "从存钱罐提取金币失败了" | 572 | resp.Message = "从存钱罐提取金币失败了" |
| @@ -608,7 +592,6 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | @@ -608,7 +592,6 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 608 | 592 | ||
| 609 | } | 593 | } |
| 610 | 594 | ||
| 611 | - | ||
| 612 | func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | 595 | func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { |
| 613 | SetHeader(w) | 596 | SetHeader(w) |
| 614 | var resp GetguangoldResp | 597 | var resp GetguangoldResp |
| @@ -623,17 +606,16 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | @@ -623,17 +606,16 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 623 | break | 606 | break |
| 624 | } | 607 | } |
| 625 | 608 | ||
| 626 | - uinfo,err := GetUserInfo(uuid) | ||
| 627 | - if err != nil || uinfo == nil{ | 609 | + uinfo, err := GetUserInfo(uuid) |
| 610 | + if err != nil || uinfo == nil { | ||
| 628 | logger.Error("redis failed err=%v", err) | 611 | logger.Error("redis failed err=%v", err) |
| 629 | resp.Message = "服务器错误" | 612 | resp.Message = "服务器错误" |
| 630 | resp.Code = ERROR_SRV_ERROR | 613 | resp.Code = ERROR_SRV_ERROR |
| 631 | break | 614 | break |
| 632 | } | 615 | } |
| 633 | 616 | ||
| 634 | - | ||
| 635 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) | 617 | mcfg := jsonconf.GetMoneyBoxCfg(uinfo.Lv) |
| 636 | - if mcfg==nil { | 618 | + if mcfg == nil { |
| 637 | logger.Error("GetMoneyBoxCfg failed err=%v", err) | 619 | logger.Error("GetMoneyBoxCfg failed err=%v", err) |
| 638 | resp.Message = "获取配置失败" | 620 | resp.Message = "获取配置失败" |
| 639 | resp.Code = ERROR_GETCONFIG_FAILED | 621 | resp.Code = ERROR_GETCONFIG_FAILED |
| @@ -647,7 +629,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | @@ -647,7 +629,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 647 | 629 | ||
| 648 | resp.Data.Guangold = uinfo.GuanGold | 630 | resp.Data.Guangold = uinfo.GuanGold |
| 649 | //uinfo.Task.GetGuanGold += rdata.Goldnum | 631 | //uinfo.Task.GetGuanGold += rdata.Goldnum |
| 650 | - uinfo.Task.GetGuanGold ++ | 632 | + uinfo.Task.GetGuanGold++ |
| 651 | 633 | ||
| 652 | SaveUserInfo(uinfo) | 634 | SaveUserInfo(uinfo) |
| 653 | 635 | ||
| @@ -661,7 +643,6 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | @@ -661,7 +643,6 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { | ||
| 661 | 643 | ||
| 662 | } | 644 | } |
| 663 | 645 | ||
| 664 | - | ||
| 665 | func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { | 646 | func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { |
| 666 | SetHeader(w) | 647 | SetHeader(w) |
| 667 | var resp GetuserdataResp | 648 | var resp GetuserdataResp |
| @@ -676,17 +657,15 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { | @@ -676,17 +657,15 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { | ||
| 676 | break | 657 | break |
| 677 | } | 658 | } |
| 678 | 659 | ||
| 679 | - | ||
| 680 | - data,err := GetUserInfo(uuid) | ||
| 681 | - if err != nil || data == nil{ | 660 | + data, err := GetUserInfo(uuid) |
| 661 | + if err != nil || data == nil { | ||
| 682 | resp.Code = ERROR_SRV_ERROR | 662 | resp.Code = ERROR_SRV_ERROR |
| 683 | resp.Message = "ERROR_SRV_ERROR" | 663 | resp.Message = "ERROR_SRV_ERROR" |
| 684 | break | 664 | break |
| 685 | } | 665 | } |
| 686 | 666 | ||
| 687 | - | ||
| 688 | //此处处理一下从sdk拉取钱包金币数量 | 667 | //此处处理一下从sdk拉取钱包金币数量 |
| 689 | - gold,err := GetCoinFromSdk(uuid,rdata.Gameid,rdata.Channel) | 668 | + gold, err := GetCoinFromSdk(uuid, rdata.Gameid, rdata.Channel) |
| 690 | if err != nil { | 669 | if err != nil { |
| 691 | data.RealGold = gold | 670 | data.RealGold = gold |
| 692 | } | 671 | } |
| @@ -698,7 +677,6 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { | @@ -698,7 +677,6 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { | ||
| 698 | resp.Data.Userlv = data.Lv | 677 | resp.Data.Userlv = data.Lv |
| 699 | SaveUserInfo(data) | 678 | SaveUserInfo(data) |
| 700 | 679 | ||
| 701 | - | ||
| 702 | resp.Code = ERROR_OK | 680 | resp.Code = ERROR_OK |
| 703 | break | 681 | break |
| 704 | } | 682 | } |
| @@ -725,7 +703,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | @@ -725,7 +703,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | ||
| 725 | } | 703 | } |
| 726 | 704 | ||
| 727 | //先判断一下是否是新用户 | 705 | //先判断一下是否是新用户 |
| 728 | - isexist,err := redishandler.GetRedisClient().HExists(redis.USER_DATA_KEY, strconv.Itoa(uuid)) | 706 | + isexist, err := redishandler.GetRedisClient().HExists(redis.USER_DATA_KEY, strconv.Itoa(uuid)) |
| 729 | if err != nil { | 707 | if err != nil { |
| 730 | logger.Error("redis failed err=%v", err) | 708 | logger.Error("redis failed err=%v", err) |
| 731 | resp.Message = "服务器错误" | 709 | resp.Message = "服务器错误" |
| @@ -739,7 +717,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | @@ -739,7 +717,7 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | ||
| 739 | err = InitUserInfo(&rdata, &resp, uuid) | 717 | err = InitUserInfo(&rdata, &resp, uuid) |
| 740 | } else { | 718 | } else { |
| 741 | //已经登陆过了 需要获取玩家数据 | 719 | //已经登陆过了 需要获取玩家数据 |
| 742 | - err = GetUserData(uuid, &rdata,&resp) | 720 | + err = GetUserData(uuid, &rdata, &resp) |
| 743 | } | 721 | } |
| 744 | 722 | ||
| 745 | if err != nil { | 723 | if err != nil { |
| @@ -758,4 +736,4 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | @@ -758,4 +736,4 @@ func HandlerLogin(w http.ResponseWriter, data string, uuid int) { | ||
| 758 | fmt.Fprint(w, string(respstr)) | 736 | fmt.Fprint(w, string(respstr)) |
| 759 | 737 | ||
| 760 | logger.Info("###HandlerLogin###rdata:%v", string(respstr)) | 738 | logger.Info("###HandlerLogin###rdata:%v", string(respstr)) |
| 761 | -} | ||
| 762 | \ No newline at end of file | 739 | \ No newline at end of file |
| 740 | +} |