From dd4d741eec41021349747d1b8cc2face1a2a27b4 Mon Sep 17 00:00:00 2001 From: 陆恒 Date: Mon, 22 Jun 2020 09:57:49 +0800 Subject: [PATCH] 提交 --- src/HttpServer/logic/datadef.go | 1 + src/HttpServer/logic/function.go | 6 ++++++ src/HttpServer/logic/logic.go | 29 ++++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/HttpServer/logic/datadef.go b/src/HttpServer/logic/datadef.go index f967dd9..2ef82d9 100644 --- a/src/HttpServer/logic/datadef.go +++ b/src/HttpServer/logic/datadef.go @@ -959,6 +959,7 @@ type UserData struct { FlyBoxNumTimes int //生意飞天宝箱次数 LeftOfflineTimes int //离线奖励剩余领取次数 EmptyBoxLeftTime int //空格宝箱生意领取次数 + WaitFetchList []LimitListDesc //待领取的分红猫列表 领取完删除 CatShopInfo CatShopData //猫咖门店数据 Taskinfo TaskData //任务数据 AchieveMent AchieveMentData //成就数据 diff --git a/src/HttpServer/logic/function.go b/src/HttpServer/logic/function.go index 4e88ee2..b3906aa 100644 --- a/src/HttpServer/logic/function.go +++ b/src/HttpServer/logic/function.go @@ -1022,6 +1022,9 @@ func (u *UserData) CalcHigestCatName() string { func (u *UserData) GetRedCatIdList() []LimitListDesc { var rtsl []LimitListDesc nowtime := int(time.Now().Unix()) + + rtsl = append(rtsl, u.WaitFetchList...) + for _, val := range u.PosInfo { if val.Cat > REDCATIDEXTRA && val.Cat < BOXGIFTEXTRA { //是红包猫并且是有时间的并且时间到了 @@ -1034,6 +1037,9 @@ func (u *UserData) GetRedCatIdList() []LimitListDesc { rtsl = append(rtsl, tmp) //需要删除 u.CleadPos(val.Position) + + //加入待领取列表 + u.WaitFetchList = append(u.WaitFetchList, tmp) } } diff --git a/src/HttpServer/logic/logic.go b/src/HttpServer/logic/logic.go index bfe20f0..25cb0bd 100644 --- a/src/HttpServer/logic/logic.go +++ b/src/HttpServer/logic/logic.go @@ -1735,6 +1735,22 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { break } + //从待领取列表删除 + idx := -1 + for i := 0; i < len(uinfo.WaitFetchList); i++ { + if uinfo.WaitFetchList[i].Cat == rdata.RedCatId { + idx = i + break + } + } + + if idx == -1 { + logger.Error("HandlerRecvRedCat idx failed=%v", rdata) + resp.Code = 1 + resp.Message = "没有可领取的分红猫" + break + } + //先判断位置 /*cpos := uinfo.GetCatPos(rdata.RedCatId) if cpos == -1 { @@ -1770,7 +1786,18 @@ func HandlerRecvRedCat(w http.ResponseWriter, data string, uuid int) { addredpack = addredpack * 2 } - uinfo.AddRedPackect(addredpack, 100) + _, err = uinfo.AddRedPackect(addredpack, 100) + if err != nil { + logger.Error("AddRedPackect failed") + resp.Code = 1 + resp.Message = "获取红包失败" + break + } + + if idx != -1 { + uinfo.WaitFetchList = append(uinfo.WaitFetchList[:idx], uinfo.WaitFetchList[idx+1:]...) + } + //删除待领取 //uinfo.CleadPos(cpos) uinfo.CalcGoldRate() -- libgit2 0.21.0