Commit 664229f02cb73bd38132281c48a9b2a5ed94306b
1 parent
a280539c
Exists in
master
提交
Showing
2 changed files
with
15 additions
and
8 deletions
Show diff stats
src/HttpServer/logic/function.go
... | ... | @@ -668,11 +668,11 @@ func (u *UserData) SetDuboCatPos(catlv int) { |
668 | 668 | } |
669 | 669 | |
670 | 670 | //设置红包猫 |
671 | -func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) { | |
671 | +func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) bool { | |
672 | 672 | pos := getCatPutPos(u, catlv) |
673 | 673 | if pos < 0 || pos >= len(u.PosInfo) { |
674 | 674 | logger.Error("CleadPos failed pos=%v,posinfo=%v", pos, u.PosInfo) |
675 | - return | |
675 | + return false | |
676 | 676 | } |
677 | 677 | |
678 | 678 | u.PosInfo[pos].Cat = catlv |
... | ... | @@ -680,6 +680,7 @@ func (u *UserData) SetRedCatPos(catlv, time int, redpack float32, starttime int) |
680 | 680 | u.PosInfo[pos].StartTime = starttime |
681 | 681 | u.PosInfo[pos].RedPacket = redpack |
682 | 682 | u.PosInfo[pos].Time = time |
683 | + return true | |
683 | 684 | } |
684 | 685 | |
685 | 686 | //计算购买后猫箱子的位置,将箱子放到对应位置 返回值表示位置 -1表示失败都满了 | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -2941,14 +2941,14 @@ func HandlerTakeCatoutfromWareHouse(w http.ResponseWriter, data string, uuid int |
2941 | 2941 | if err != nil { |
2942 | 2942 | logger.Error("HandlerTakeCatoutfromWareHouse json unmarshal failed=%v", err) |
2943 | 2943 | resp.Code = 1 |
2944 | - resp.Message = "json failed" | |
2944 | + resp.Message = "服务器错误" | |
2945 | 2945 | break |
2946 | 2946 | } |
2947 | 2947 | udatastr, err := redishandler.GetRedisClient().HGet(redis.USER_WAREHOUSE_INFO, strconv.Itoa(uuid)) |
2948 | 2948 | if err != nil { |
2949 | 2949 | logger.Info("HandlerTakeCatoutfromWareHouse failed err=%v", err) |
2950 | 2950 | resp.Code = 1 |
2951 | - resp.Message = "get redis failed" | |
2951 | + resp.Message = "服务器错误" | |
2952 | 2952 | break |
2953 | 2953 | } |
2954 | 2954 | udata := new(UserWareHouseData) |
... | ... | @@ -2956,7 +2956,7 @@ func HandlerTakeCatoutfromWareHouse(w http.ResponseWriter, data string, uuid int |
2956 | 2956 | if err != nil { |
2957 | 2957 | logger.Error("HandlerTakeCatoutfromWareHouse Unmarshal redis failed ") |
2958 | 2958 | resp.Code = 1 |
2959 | - resp.Message = "Unmarshal redis failed" | |
2959 | + resp.Message = "服务器错误" | |
2960 | 2960 | break |
2961 | 2961 | } |
2962 | 2962 | |
... | ... | @@ -2964,7 +2964,7 @@ func HandlerTakeCatoutfromWareHouse(w http.ResponseWriter, data string, uuid int |
2964 | 2964 | if err != nil || uinfo == nil { |
2965 | 2965 | logger.Error("HandlerPutCattoWareHouse getuserinfo failed=%v", err) |
2966 | 2966 | resp.Code = 1 |
2967 | - resp.Message = "get userinfo failed" | |
2967 | + resp.Message = "服务器错误" | |
2968 | 2968 | break |
2969 | 2969 | } |
2970 | 2970 | cid, _ := strconv.Atoi(rdata.CatId) |
... | ... | @@ -2972,12 +2972,18 @@ func HandlerTakeCatoutfromWareHouse(w http.ResponseWriter, data string, uuid int |
2972 | 2972 | if wpos == -1 { |
2973 | 2973 | logger.Error("HandlerTakeCatoutfromWareHouse wpos failed=%v", err) |
2974 | 2974 | resp.Code = 1 |
2975 | - resp.Message = "wpos" | |
2975 | + resp.Message = "没有正确的猫" | |
2976 | 2976 | break |
2977 | 2977 | } |
2978 | 2978 | winfo := udata.Info[wpos] |
2979 | 2979 | |
2980 | - uinfo.SetRedCatPos(winfo.Warelv, winfo.Time, winfo.RedPacket, winfo.StartTime) | |
2980 | + success := uinfo.SetRedCatPos(winfo.Warelv, winfo.Time, winfo.RedPacket, winfo.StartTime) | |
2981 | + if !success { | |
2982 | + logger.Error("HandlerTakeCatoutfromWareHouse wpos failed=%v", err) | |
2983 | + resp.Code = 1 | |
2984 | + resp.Message = "合成界面已满,请先整理置位" | |
2985 | + break | |
2986 | + } | |
2981 | 2987 | |
2982 | 2988 | udata.Info[wpos].Warelv = 0 |
2983 | 2989 | udata.Info[wpos].StartTime = 0 | ... | ... |