From c26fcf44d7ad99f7b99cddd6743081e45fd25c17 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sun, 8 Oct 2023 16:14:34 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=95=86=E9=98=9F=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E8=B5=B0=E5=8A=BF=E5=9B=BE=20=E4=BB=B7=E6=A0=BC=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/module.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/caravan/module.go b/modules/caravan/module.go index 05998dd39..ca1305478 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -149,14 +149,21 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { goodinfo := &pb.GoodsInfo{ Goods: make(map[string]int32, 0), } - + var price int32 for _, c := range items { if _, ok := data.Period[c.Itemid]; !ok { data.Period[c.Itemid] = &pb.GoodPeriod{} } - var price int32 - price = c.Goodsprice + if _, ok := data.Allgoods[index-1]; ok { + if _, ok := data.Allgoods[index-1].Goods[c.Itemid]; ok { + price = data.Allgoods[index-1].Goods[c.Itemid] // 获取上一次价格 + } + } + + if price == 0 { // + price = c.Goodsprice // 获取默认值 + } data.Period[c.Itemid].CurPeriod += 1 if len(c.Changeperiod) == 2 && data.Period[c.Itemid].Period == 0 { data.Period[c.Itemid].Period = comm.GetRandNum(c.Changeperiod[0], c.Changeperiod[1]) @@ -182,6 +189,9 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { } } if len(c.FluctuationRange) == 2 { + if c.Itemid == "21000018" { + c.Itemid = "21000018" + } p := comm.GetRandNum(c.PriceChangeWeightThree[0], c.PriceChangeWeightThree[1]) if bUp { // 价格上涨 price = int32(math.Floor(float64(price) * (1.0 + float64(p)/1000.0))) From 1bdb587514131b6b84bfe4bc574b458be5dbd0aa Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sun, 8 Oct 2023 16:16:44 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=8D=B8=E8=BD=BD=E7=A7=B0=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/user/api_switchtitle.go | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/modules/user/api_switchtitle.go b/modules/user/api_switchtitle.go index 2c7b3e26b..37580cb67 100644 --- a/modules/user/api_switchtitle.go +++ b/modules/user/api_switchtitle.go @@ -8,12 +8,6 @@ import ( //参数校验 func (this *apiComp) SwitchTitleCheck(session comm.IUserSession, req *pb.UserSwitchTitleReq) (errdata *pb.ErrorData) { - if req.Title == "" { - errdata = &pb.ErrorData{ - Code: pb.ErrorCode_ReqParameterError, - Title: pb.ErrorCode_ReqParameterError.ToString(), - } - } return } @@ -38,13 +32,17 @@ func (this *apiComp) SwitchTitle(session comm.IUserSession, req *pb.UserSwitchTi } return } - - for _, v := range user.Titles { - if req.Title == v { - keep = true - break + if req.Title == "" { // 卸载称号 + keep = true + } else { + for _, v := range user.Titles { + if req.Title == v { + keep = true + break + } } } + if !keep { errdata = &pb.ErrorData{ Code: pb.ErrorCode_UserNoTitle, From d2ebddf88c9c6bd0e3c8a5db0afdf91038a5e3ec Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Sun, 8 Oct 2023 16:22:11 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/caravan/module.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/caravan/module.go b/modules/caravan/module.go index ca1305478..e6efb1352 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -149,9 +149,9 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { goodinfo := &pb.GoodsInfo{ Goods: make(map[string]int32, 0), } - var price int32 - for _, c := range items { + for _, c := range items { + var price int32 if _, ok := data.Period[c.Itemid]; !ok { data.Period[c.Itemid] = &pb.GoodPeriod{} } @@ -189,9 +189,7 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { } } if len(c.FluctuationRange) == 2 { - if c.Itemid == "21000018" { - c.Itemid = "21000018" - } + p := comm.GetRandNum(c.PriceChangeWeightThree[0], c.PriceChangeWeightThree[1]) if bUp { // 价格上涨 price = int32(math.Floor(float64(price) * (1.0 + float64(p)/1000.0)))