diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index f8e381d..f967dd9 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -724,17 +724,22 @@ type adRateData struct { EndTime int `json:"endTime"` } +type LimitListDesc struct { + Cat int `json:"cat"` + Money float32 `json:"money"` +} + type GetMainPageInfoData struct { - LimitCatList []int `json:"limitCatList"` - CatList []CatPosInfo `json:"catList"` - Coin DoBuyCatCoin `json:"coin"` - AdRate adRateData `json:"adRate"` - Level int `json:"level"` - TotalCashReward float32 `json:"totalCashReward"` - Guide bool `json:"guide"` - Redbagnum int `json:"redbagnum"` - Flyboxnum int `json:"flyboxnum"` - Leftredbagnum int `json:"leftredbagnum"` + LimitCatList []LimitListDesc `json:"limitCatList"` + CatList []CatPosInfo `json:"catList"` + Coin DoBuyCatCoin `json:"coin"` + AdRate adRateData `json:"adRate"` + Level int `json:"level"` + TotalCashReward float32 `json:"totalCashReward"` + Guide bool `json:"guide"` + Redbagnum int `json:"redbagnum"` + Flyboxnum int `json:"flyboxnum"` + Leftredbagnum int `json:"leftredbagnum"` } type GetMainPageInfoResp struct { diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index fa72302..c8f869b 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -1019,11 +1019,24 @@ func (u *UserData) CalcHigestCatName() string { } //获取红包猫列表 -func (u *UserData) GetRedCatIdList() []int { - var rtsl []int +func (u *UserData) GetRedCatIdList() []LimitListDesc { + var rtsl []LimitListDesc + nowtime := int(time.Now().Unix()) for _, val := range u.PosInfo { - if val.Cat > 100 { - rtsl = append(rtsl, val.Cat-100) + if val.Cat > REDCATIDEXTRA && val.Cat < BOXGIFTEXTRA { + //是红包猫并且是有时间的并且时间到了 + if val.RedPacket != 0 { + + if nowtime > val.StartTime+val.Time { + var tmp LimitListDesc + tmp.Cat = val.Cat + tmp.Money = val.RedPacket + rtsl = append(rtsl, tmp) + //需要删除 + u.CleadPos(val.Position) + } + } + } } @@ -1039,16 +1052,27 @@ func (u *UserData) GetRedCatIdList() []int { return rtsl } for _, val := range wdata.Info { - rtsl = append(rtsl, val.Warelv) + if val.RedPacket != 0 { + if nowtime > val.StartTime+val.Time { + var tmp LimitListDesc + tmp.Cat = val.Warelv + tmp.Money = val.RedPacket + rtsl = append(rtsl, tmp) + } + } + } - if len(rtsl) > 16 { - sort.Ints(rtsl) - return rtsl[:len(rtsl)-16] - } else { - return rtsl + //需要删除掉已经到期的猫 + for i := 0; i < len(wdata.Info); i++ { + if nowtime > wdata.Info[i].StartTime+wdata.Info[i].Time { + wdata.Info = append(wdata.Info[:i], wdata.Info[i+1:]...) + i-- + } } + return rtsl + } //尝试将合成界面的猫放入仓库 返回位置索引 -1表示仓库已满放入失败 diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index 8961d0e..d42cc1a 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -1387,6 +1387,7 @@ func HandlerGetMainPageInfo(w http.ResponseWriter, data string, uuid int) { redlist := uinfo.GetRedCatIdList() resp.Data.LimitCatList = append(resp.Data.LimitCatList, redlist...) + uinfo.CalcGoldRate() resp.Data.CatList = append(resp.Data.CatList, uinfo.PosInfo...) resp.Data.Coin.UserId = uuid @@ -1734,7 +1735,7 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { } //先判断位置 - cpos := uinfo.GetCatPos(rdata.RedCatId) + /*cpos := uinfo.GetCatPos(rdata.RedCatId) if cpos == -1 { logger.Error("HandlerRecvRedCat nothave cat failed=%v", rdata.RedCatId) resp.Code = 1 @@ -1754,15 +1755,22 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { break } } - + */ //领取红包 - addredpack := v.RedPacket + cfg := jsonconf.GetRedCatConfig(rdata.RedCatId) + if cfg == nil { + logger.Error("GetRedCatConfig failede") + resp.Code = 1 + resp.Message = "获取配置失败" + break + } + addredpack := cfg.Money if rdata.Rtype == 1 { addredpack = addredpack * 2 } uinfo.AddRedPackect(addredpack, 100) - uinfo.CleadPos(cpos) + //uinfo.CleadPos(cpos) uinfo.CalcGoldRate() //uinfo.TodayZhaocai += addredpack -- libgit2 0.21.0