商队价格走势图 价格调整

This commit is contained in:
meixiongfeng 2023-10-08 16:14:34 +08:00
parent aa4bd8ad9b
commit c26fcf44d7

View File

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