Commit d728847de9e54f76d615f1eecddf7f802572ddc6
1 parent
db39a0aa
Exists in
master
提交
Showing
3 changed files
with
61 additions
and
24 deletions
Show diff stats
src/HttpServer/logic/datadef.go
... | ... | @@ -724,17 +724,22 @@ type adRateData struct { |
724 | 724 | EndTime int `json:"endTime"` |
725 | 725 | } |
726 | 726 | |
727 | +type LimitListDesc struct { | |
728 | + Cat int `json:"cat"` | |
729 | + Money float32 `json:"money"` | |
730 | +} | |
731 | + | |
727 | 732 | type GetMainPageInfoData struct { |
728 | - LimitCatList []int `json:"limitCatList"` | |
729 | - CatList []CatPosInfo `json:"catList"` | |
730 | - Coin DoBuyCatCoin `json:"coin"` | |
731 | - AdRate adRateData `json:"adRate"` | |
732 | - Level int `json:"level"` | |
733 | - TotalCashReward float32 `json:"totalCashReward"` | |
734 | - Guide bool `json:"guide"` | |
735 | - Redbagnum int `json:"redbagnum"` | |
736 | - Flyboxnum int `json:"flyboxnum"` | |
737 | - Leftredbagnum int `json:"leftredbagnum"` | |
733 | + LimitCatList []LimitListDesc `json:"limitCatList"` | |
734 | + CatList []CatPosInfo `json:"catList"` | |
735 | + Coin DoBuyCatCoin `json:"coin"` | |
736 | + AdRate adRateData `json:"adRate"` | |
737 | + Level int `json:"level"` | |
738 | + TotalCashReward float32 `json:"totalCashReward"` | |
739 | + Guide bool `json:"guide"` | |
740 | + Redbagnum int `json:"redbagnum"` | |
741 | + Flyboxnum int `json:"flyboxnum"` | |
742 | + Leftredbagnum int `json:"leftredbagnum"` | |
738 | 743 | } |
739 | 744 | |
740 | 745 | type GetMainPageInfoResp struct { | ... | ... |
src/HttpServer/logic/function.go
... | ... | @@ -1019,11 +1019,24 @@ func (u *UserData) CalcHigestCatName() string { |
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | //获取红包猫列表 |
1022 | -func (u *UserData) GetRedCatIdList() []int { | |
1023 | - var rtsl []int | |
1022 | +func (u *UserData) GetRedCatIdList() []LimitListDesc { | |
1023 | + var rtsl []LimitListDesc | |
1024 | + nowtime := int(time.Now().Unix()) | |
1024 | 1025 | for _, val := range u.PosInfo { |
1025 | - if val.Cat > 100 { | |
1026 | - rtsl = append(rtsl, val.Cat-100) | |
1026 | + if val.Cat > REDCATIDEXTRA && val.Cat < BOXGIFTEXTRA { | |
1027 | + //是红包猫并且是有时间的并且时间到了 | |
1028 | + if val.RedPacket != 0 { | |
1029 | + | |
1030 | + if nowtime > val.StartTime+val.Time { | |
1031 | + var tmp LimitListDesc | |
1032 | + tmp.Cat = val.Cat | |
1033 | + tmp.Money = val.RedPacket | |
1034 | + rtsl = append(rtsl, tmp) | |
1035 | + //需要删除 | |
1036 | + u.CleadPos(val.Position) | |
1037 | + } | |
1038 | + } | |
1039 | + | |
1027 | 1040 | } |
1028 | 1041 | } |
1029 | 1042 | |
... | ... | @@ -1039,16 +1052,27 @@ func (u *UserData) GetRedCatIdList() []int { |
1039 | 1052 | return rtsl |
1040 | 1053 | } |
1041 | 1054 | for _, val := range wdata.Info { |
1042 | - rtsl = append(rtsl, val.Warelv) | |
1055 | + if val.RedPacket != 0 { | |
1056 | + if nowtime > val.StartTime+val.Time { | |
1057 | + var tmp LimitListDesc | |
1058 | + tmp.Cat = val.Warelv | |
1059 | + tmp.Money = val.RedPacket | |
1060 | + rtsl = append(rtsl, tmp) | |
1061 | + } | |
1062 | + } | |
1063 | + | |
1043 | 1064 | } |
1044 | 1065 | |
1045 | - if len(rtsl) > 16 { | |
1046 | - sort.Ints(rtsl) | |
1047 | - return rtsl[:len(rtsl)-16] | |
1048 | - } else { | |
1049 | - return rtsl | |
1066 | + //需要删除掉已经到期的猫 | |
1067 | + for i := 0; i < len(wdata.Info); i++ { | |
1068 | + if nowtime > wdata.Info[i].StartTime+wdata.Info[i].Time { | |
1069 | + wdata.Info = append(wdata.Info[:i], wdata.Info[i+1:]...) | |
1070 | + i-- | |
1071 | + } | |
1050 | 1072 | } |
1051 | 1073 | |
1074 | + return rtsl | |
1075 | + | |
1052 | 1076 | } |
1053 | 1077 | |
1054 | 1078 | //尝试将合成界面的猫放入仓库 返回位置索引 -1表示仓库已满放入失败 | ... | ... |
src/HttpServer/logic/logic.go
... | ... | @@ -1387,6 +1387,7 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { |
1387 | 1387 | |
1388 | 1388 | redlist := uinfo.GetRedCatIdList() |
1389 | 1389 | resp.Data.LimitCatList = append(resp.Data.LimitCatList, redlist...) |
1390 | + uinfo.CalcGoldRate() | |
1390 | 1391 | |
1391 | 1392 | resp.Data.CatList = append(resp.Data.CatList, uinfo.PosInfo...) |
1392 | 1393 | resp.Data.Coin.UserId = uuid |
... | ... | @@ -1734,7 +1735,7 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { |
1734 | 1735 | } |
1735 | 1736 | |
1736 | 1737 | //先判断位置 |
1737 | - cpos := uinfo.GetCatPos(rdata.RedCatId) | |
1738 | + /*cpos := uinfo.GetCatPos(rdata.RedCatId) | |
1738 | 1739 | if cpos == -1 { |
1739 | 1740 | logger.Error("HandlerRecvRedCat nothave cat failed=%v", rdata.RedCatId) |
1740 | 1741 | resp.Code = 1 |
... | ... | @@ -1754,15 +1755,22 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { |
1754 | 1755 | break |
1755 | 1756 | } |
1756 | 1757 | } |
1757 | - | |
1758 | + */ | |
1758 | 1759 | //领取红包 |
1759 | - addredpack := v.RedPacket | |
1760 | + cfg := jsonconf.GetRedCatConfig(rdata.RedCatId) | |
1761 | + if cfg == nil { | |
1762 | + logger.Error("GetRedCatConfig failede") | |
1763 | + resp.Code = 1 | |
1764 | + resp.Message = "获取配置失败" | |
1765 | + break | |
1766 | + } | |
1767 | + addredpack := cfg.Money | |
1760 | 1768 | if rdata.Rtype == 1 { |
1761 | 1769 | addredpack = addredpack * 2 |
1762 | 1770 | } |
1763 | 1771 | |
1764 | 1772 | uinfo.AddRedPackect(addredpack, 100) |
1765 | - uinfo.CleadPos(cpos) | |
1773 | + //uinfo.CleadPos(cpos) | |
1766 | 1774 | |
1767 | 1775 | uinfo.CalcGoldRate() |
1768 | 1776 | //uinfo.TodayZhaocai += addredpack | ... | ... |