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)))