This commit is contained in:
liwei1dao 2023-10-08 16:48:02 +08:00
commit 0692d9d7e2
2 changed files with 20 additions and 14 deletions

View File

@ -151,12 +151,19 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
}
for _, c := range items {
var price int32
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,7 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
}
}
if len(c.FluctuationRange) == 2 {
p := comm.GetRandNum(c.PriceChangeWeightThree[0], c.PriceChangeWeightThree[1])
if bUp { // 价格上涨
price = int32(math.Floor(float64(price) * (1.0 + float64(p)/1000.0)))

View File

@ -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
}
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,