Commit 413dc8cd4783e569fb56aaae4607c3be5cc9edce

Authored by 陆恒
1 parent 1cd59cb5

修复bug

src/HttpServer/logic/datadef.go
@@ -301,7 +301,7 @@ type WithDrawDesc struct { @@ -301,7 +301,7 @@ type WithDrawDesc struct {
301 301
302 //玩家数据 302 //玩家数据
303 type UserData struct { 303 type UserData struct {
304 - Userid string //玩家id 304 + Userid int //玩家id
305 Lv int //玩家当前等级 305 Lv int //玩家当前等级
306 LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取 306 LvRewardGet int //当前等级奖励是否已经领取 1未领取 2普通领取 3双倍领取
307 Exp int //玩家当前经验值 307 Exp int //玩家当前经验值
src/HttpServer/logic/function.go
@@ -38,14 +38,14 @@ func SetHeader(w http.ResponseWriter) { @@ -38,14 +38,14 @@ func SetHeader(w http.ResponseWriter) {
38 w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid") 38 w.Header().Set("Access-Control-Allow-Headers", "Content-Type,Uuid")
39 } 39 }
40 40
41 -func SaveUserInfo(data *UserData) error { 41 +func SaveUserInfo(data *UserData, uniqueid string) error {
42 42
43 savestr, err := json.Marshal(data) 43 savestr, err := json.Marshal(data)
44 if err != nil { 44 if err != nil {
45 return err 45 return err
46 } 46 }
47 47
48 - err = redishandler.GetRedisClient().HSet(redis.USER_DATA_KEY, data.Userid, string(savestr)) 48 + err = redishandler.GetRedisClient().HSet(redis.USER_DATA_KEY, uniqueid, string(savestr))
49 49
50 return err 50 return err
51 } 51 }
@@ -92,7 +92,7 @@ func GetAchieveConfig(taskid int) *jsonconf.AchieveDesc { @@ -92,7 +92,7 @@ func GetAchieveConfig(taskid int) *jsonconf.AchieveDesc {
92 return nil 92 return nil
93 } 93 }
94 94
95 -func (uinfo *UserData) CalcTaskList(list *TaskList) { 95 +func (uinfo *UserData) CalcTaskList(list *TaskList, uniqueid string) {
96 96
97 for k, val := range list.Taskdata { 97 for k, val := range list.Taskdata {
98 //未完成的才做判断 98 //未完成的才做判断
@@ -150,7 +150,7 @@ func (uinfo *UserData) CalcTaskList(list *TaskList) { @@ -150,7 +150,7 @@ func (uinfo *UserData) CalcTaskList(list *TaskList) {
150 } 150 }
151 151
152 //需要保存到redis 152 //需要保存到redis
153 - SaveTaskInfo(uinfo.Userid, 1, list) 153 + SaveTaskInfo(uniqueid, 1, list)
154 154
155 //排序 155 //排序
156 sort.Sort(list) 156 sort.Sort(list)
@@ -177,7 +177,7 @@ func (uinfo *UserData) CalcAchieveProgress(ttype int) int { @@ -177,7 +177,7 @@ func (uinfo *UserData) CalcAchieveProgress(ttype int) int {
177 } 177 }
178 178
179 //成就返回的是新的成就列表 179 //成就返回的是新的成就列表
180 -func (uinfo *UserData) CalcAchieveList(list *TaskList) *TaskList { 180 +func (uinfo *UserData) CalcAchieveList(list *TaskList, uniqueid string) *TaskList {
181 newlist := new(TaskList) 181 newlist := new(TaskList)
182 curtype := -1 //记录当前类型 182 curtype := -1 //记录当前类型
183 183
@@ -268,7 +268,7 @@ func (uinfo *UserData) CalcAchieveList(list *TaskList) *TaskList { @@ -268,7 +268,7 @@ func (uinfo *UserData) CalcAchieveList(list *TaskList) *TaskList {
268 } 268 }
269 269
270 //保存旧的列表 270 //保存旧的列表
271 - SaveTaskInfo(uinfo.Userid, 2, list) 271 + SaveTaskInfo(uniqueid, 2, list)
272 272
273 //将返回的列表排序 273 //将返回的列表排序
274 sort.Sort(newlist) 274 sort.Sort(newlist)
@@ -456,7 +456,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s @@ -456,7 +456,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s
456 initdata.Lv = 1 456 initdata.Lv = 1
457 initdata.LvRewardGet = 1 457 initdata.LvRewardGet = 1
458 initdata.Exp = 0 458 initdata.Exp = 0
459 - initdata.Userid = uniqueuid //加上渠道的唯一id 459 + initdata.Userid = uuid
460 initdata.ContinueLoginDay = 1 460 initdata.ContinueLoginDay = 1
461 initdata.GetFromGuanCnt = 0 461 initdata.GetFromGuanCnt = 0
462 initdata.GuanGold = 0 462 initdata.GuanGold = 0
@@ -491,7 +491,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s @@ -491,7 +491,7 @@ func InitUserInfo(data *UserLoginReq, resp *UserLoginResp, uuid int, uniqueuid s
491 resp.Data.Walletgold = initdata.RealGold 491 resp.Data.Walletgold = initdata.RealGold
492 resp.Data.Userlv = initdata.Lv 492 resp.Data.Userlv = initdata.Lv
493 493
494 - err := SaveUserInfo(&initdata) 494 + err := SaveUserInfo(&initdata, uniqueuid)
495 if err != nil { 495 if err != nil {
496 logger.Error("InitUserInfo err=%v", err) 496 logger.Error("InitUserInfo err=%v", err)
497 return err 497 return err
@@ -694,8 +694,8 @@ func (u *UserData) HandlePassDay(uuid int, channel string) { @@ -694,8 +694,8 @@ func (u *UserData) HandlePassDay(uuid int, channel string) {
694 } 694 }
695 695
696 u.LastLoginTime = int(nowtime.Unix()) 696 u.LastLoginTime = int(nowtime.Unix())
697 -  
698 - SaveUserInfo(u) 697 + uniqueid := strconv.Itoa(uuid) + channel
  698 + SaveUserInfo(u, uniqueid)
699 } 699 }
700 700
701 func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginResp) error { 701 func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginResp) error {
@@ -732,7 +732,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR @@ -732,7 +732,7 @@ func GetUserData(uuid int, uniqueuid string, req *UserLoginReq, resp *UserLoginR
732 732
733 } 733 }
734 734
735 - SaveUserInfo(data) 735 + SaveUserInfo(data, uniqueuid)
736 736
737 resp.Data.Walletgold = data.RealGold 737 resp.Data.Walletgold = data.RealGold
738 resp.Data.Leftredbagcnt = data.WatchAddsTime 738 resp.Data.Leftredbagcnt = data.WatchAddsTime
src/HttpServer/logic/httpserver.go
@@ -225,7 +225,7 @@ func Testapi(w http.ResponseWriter, r *http.Request) { @@ -225,7 +225,7 @@ func Testapi(w http.ResponseWriter, r *http.Request) {
225 uinfo.SignRound++ 225 uinfo.SignRound++
226 } 226 }
227 } 227 }
228 - err = SaveUserInfo(uinfo) 228 + err = SaveUserInfo(uinfo, uniqueuuid)
229 if err != nil { 229 if err != nil {
230 logger.Error("SaveUserInfo err=%v", err) 230 logger.Error("SaveUserInfo err=%v", err)
231 } 231 }
src/HttpServer/logic/logic.go
@@ -216,7 +216,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) { @@ -216,7 +216,7 @@ func HandlerGetcash(w http.ResponseWriter, data string, uuid int) {
216 //uinfo.RealGold -= drawnum * 100 216 //uinfo.RealGold -= drawnum * 100
217 217
218 resp.Data.Walletgold = uinfo.RealGold 218 resp.Data.Walletgold = uinfo.RealGold
219 - SaveUserInfo(uinfo) 219 + SaveUserInfo(uinfo, uniqueuuid)
220 220
221 resp.Code = ERROR_OK 221 resp.Code = ERROR_OK
222 break 222 break
@@ -261,7 +261,7 @@ func HandlerQuerysigndata(w http.ResponseWriter, data string, uuid int) { @@ -261,7 +261,7 @@ func HandlerQuerysigndata(w http.ResponseWriter, data string, uuid int) {
261 261
262 logger.Info("HandlerQuerysigndata resp=%v", resp) 262 logger.Info("HandlerQuerysigndata resp=%v", resp)
263 263
264 - SaveUserInfo(uinfo) 264 + SaveUserInfo(uinfo, uniqueuuid)
265 resp.Code = ERROR_OK 265 resp.Code = ERROR_OK
266 break 266 break
267 } 267 }
@@ -336,7 +336,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) { @@ -336,7 +336,7 @@ func HandlerGetnewlevelreward(w http.ResponseWriter, data string, uuid int) {
336 resp.Data.Goldnum = uinfo.RealGold 336 resp.Data.Goldnum = uinfo.RealGold
337 logger.Info("HandlerGetnewlevelreward gold=%v", uinfo.RealGold) 337 logger.Info("HandlerGetnewlevelreward gold=%v", uinfo.RealGold)
338 //保存数据 338 //保存数据
339 - SaveUserInfo(uinfo) 339 + SaveUserInfo(uinfo, uniqueuuid)
340 340
341 resp.Code = ERROR_OK 341 resp.Code = ERROR_OK
342 break 342 break
@@ -415,7 +415,7 @@ func HandlerUsersign(w http.ResponseWriter, data string, uuid int) { @@ -415,7 +415,7 @@ func HandlerUsersign(w http.ResponseWriter, data string, uuid int) {
415 resp.Data.Goldnum = uinfo.RealGold 415 resp.Data.Goldnum = uinfo.RealGold
416 416
417 //保存数据 417 //保存数据
418 - err = SaveUserInfo(uinfo) 418 + err = SaveUserInfo(uinfo, uniqueuuid)
419 419
420 resp.Code = ERROR_OK 420 resp.Code = ERROR_OK
421 break 421 break
@@ -473,8 +473,8 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) { @@ -473,8 +473,8 @@ func HandlerGettaskreward(w http.ResponseWriter, data string, uuid int) {
473 } 473 }
474 474
475 //保存数据 475 //保存数据
476 - err = SaveUserInfo(uinfo)  
477 - err = SaveTaskInfo(uinfo.Userid, rdata.Tasktype, tasklist) 476 + err = SaveUserInfo(uinfo, uniqueuuid)
  477 + err = SaveTaskInfo(uniqueuuid, rdata.Tasktype, tasklist)
478 478
479 resp.Code = ERROR_OK 479 resp.Code = ERROR_OK
480 break 480 break
@@ -523,11 +523,11 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) { @@ -523,11 +523,11 @@ func HandlerQuerytaskinfo(w http.ResponseWriter, data string, uuid int) {
523 } 523 }
524 524
525 if rdata.Tasktype == 1 { 525 if rdata.Tasktype == 1 {
526 - uinfo.CalcTaskList(tasklist) 526 + uinfo.CalcTaskList(tasklist, uniqueuuid)
527 } else if rdata.Tasktype == 2 { 527 } else if rdata.Tasktype == 2 {
528 - tasklist = uinfo.CalcAchieveList(tasklist) 528 + tasklist = uinfo.CalcAchieveList(tasklist, uniqueuuid)
529 } else { 529 } else {
530 - uinfo.CalcTaskList(tasklist) 530 + uinfo.CalcTaskList(tasklist, uniqueuuid)
531 } 531 }
532 532
533 if tasklist == nil { 533 if tasklist == nil {
@@ -594,7 +594,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) { @@ -594,7 +594,7 @@ func HandlerUpdatetaskandachieve(w http.ResponseWriter, data string, uuid int) {
594 uinfo.Achieve.SumUseItemCnt += rdata.Value 594 uinfo.Achieve.SumUseItemCnt += rdata.Value
595 } 595 }
596 logger.Info("HandlerUpdatetaskandachieve uinfo=%v rdata=%v", uinfo, rdata) 596 logger.Info("HandlerUpdatetaskandachieve uinfo=%v rdata=%v", uinfo, rdata)
597 - SaveUserInfo(uinfo) 597 + SaveUserInfo(uinfo, uniqueuuid)
598 resp.Code = ERROR_OK 598 resp.Code = ERROR_OK
599 break 599 break
600 } 600 }
@@ -631,7 +631,7 @@ func HandlerOnlinentf(w http.ResponseWriter, data string, uuid int) { @@ -631,7 +631,7 @@ func HandlerOnlinentf(w http.ResponseWriter, data string, uuid int) {
631 631
632 uinfo.Task.OnlineMin++ 632 uinfo.Task.OnlineMin++
633 633
634 - SaveUserInfo(uinfo) 634 + SaveUserInfo(uinfo, uniqueuuid)
635 635
636 resp.Code = ERROR_OK 636 resp.Code = ERROR_OK
637 break 637 break
@@ -796,7 +796,7 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) { @@ -796,7 +796,7 @@ func HandlerDrawguangold(w http.ResponseWriter, data string, uuid int) {
796 resp.Data.Wallgold = uinfo.RealGold 796 resp.Data.Wallgold = uinfo.RealGold
797 resp.Data.Totalfetchcnt = uinfo.Achieve.SumGetGuan 797 resp.Data.Totalfetchcnt = uinfo.Achieve.SumGetGuan
798 798
799 - SaveUserInfo(uinfo) 799 + SaveUserInfo(uinfo, uniqueuuid)
800 800
801 resp.Code = ERROR_OK 801 resp.Code = ERROR_OK
802 break 802 break
@@ -849,7 +849,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) { @@ -849,7 +849,7 @@ func HandlerGetguangold(w http.ResponseWriter, data string, uuid int) {
849 //uinfo.Task.GetGuanGold += rdata.Goldnum 849 //uinfo.Task.GetGuanGold += rdata.Goldnum
850 uinfo.Task.GetGuanGold++ 850 uinfo.Task.GetGuanGold++
851 851
852 - SaveUserInfo(uinfo) 852 + SaveUserInfo(uinfo, uniqueuuid)
853 853
854 resp.Code = ERROR_OK 854 resp.Code = ERROR_OK
855 break 855 break
@@ -898,7 +898,7 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) { @@ -898,7 +898,7 @@ func HandlerGetuserdata(w http.ResponseWriter, data string, uuid int) {
898 resp.Data.Userexp = data.Exp 898 resp.Data.Userexp = data.Exp
899 resp.Data.Userlv = data.Lv 899 resp.Data.Userlv = data.Lv
900 resp.Data.Leftfreeredbag = data.LeftFreeRB 900 resp.Data.Leftfreeredbag = data.LeftFreeRB
901 - SaveUserInfo(data) 901 + SaveUserInfo(data, uniqueuuid)
902 902
903 resp.Code = ERROR_OK 903 resp.Code = ERROR_OK
904 break 904 break