diff --git a/modules/caravan/api_buyorsell.go b/modules/caravan/api_buyorsell.go index da44e7e74..f9f20a894 100644 --- a/modules/caravan/api_buyorsell.go +++ b/modules/caravan/api_buyorsell.go @@ -3,6 +3,7 @@ package caravan import ( "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/sys/configure" cfg "go_dreamfactory/sys/configure/structs" ) @@ -157,8 +158,19 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.CaravanBuyOrSe // 计算均价 buyValue = caravan.Items[k].Count * caravan.Items[k].Price var price int32 - //price = caravan.Goods[k].Price - price = caravan.Allgoods[k].Goods[0].Price + // 获取当前节点数据 + if len(caravan.Allgoods[k].Goods) == 0 { + errdata = &pb.ErrorData{ + Code: pb.ErrorCode_TrollCityUnSellItem, + Title: pb.ErrorCode_TrollCityUnSellItem.ToString(), + } + return + } + key := configure.Now().Hour() / (24 / len(caravan.Allgoods[k].Goods)) + if _, ok := caravan.Allgoods[k].Goods[int32(key)]; !ok { + key = 0 + } + price = caravan.Allgoods[k].Goods[int32(key)].Price for _, v := range cityInfo.Special { if v == k { bFound = true diff --git a/modules/caravan/api_refreshcity.go b/modules/caravan/api_refreshcity.go index 3ea0f091c..75dd73067 100644 --- a/modules/caravan/api_refreshcity.go +++ b/modules/caravan/api_refreshcity.go @@ -11,6 +11,7 @@ func (this *apiComp) RefreshCityCheck(session comm.IUserSession, req *pb.Caravan return } +// 此协议不用 // 刷新城市信息 func (this *apiComp) RefreshCity(session comm.IUserSession, req *pb.CaravanRefreshCityReq) (errdata *pb.ErrorData) { var ( diff --git a/modules/caravan/module.go b/modules/caravan/module.go index 856245344..9a32dd2d6 100644 --- a/modules/caravan/module.go +++ b/modules/caravan/module.go @@ -148,14 +148,10 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { goodinfo := &pb.GoodsInfo{ Goods: map[int32]*pb.Goods{}, } + goods := &pb.Goods{} var index int32 for index = 0; index < p; index++ { - - goods := &pb.Goods{ - Period: 0, // 变动周期 - CurPeriod: index + 1, // 当前变动周期 - Price: 0, // 当前价格 - } + goods.CurPeriod = index + 1 if len(c.Changeperiod) == 2 && goods.Period == 0 { goods.Period = comm.GetRandNum(c.Changeperiod[0], c.Changeperiod[1]) goods.Weightpos = comm.GetRandW(c.PriceChangeWeight) @@ -166,8 +162,6 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { goods.Weightpos = comm.GetRandW(c.PriceChangeWeight) } bUp := false - - //ipos := comm.GetRandW(c.PriceChangeWeight) if goods.Weightpos == 0 { if comm.GetRandW(c.PriceChangeWeightOne) == 0 { bUp = true @@ -199,10 +193,7 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) { goodinfo.Goods[index] = goods } data.Allgoods[c.Itemid] = goodinfo - //data.Goods[c.Itemid] = goods - // data.Oldprice[c.Itemid] = c.Goodsprice } - //data.Itemtime = configure.Now().Unix() + int64(changeTime) // 设置货物变更时间 } // 初始化门票和虚拟币 diff --git a/utils/time.go b/utils/time.go index 56cc73040..5ad1c0fe7 100644 --- a/utils/time.go +++ b/utils/time.go @@ -13,6 +13,7 @@ import ( func IsToday(d int64) bool { tt := time.Unix(d, 0) now := configure.Now() + return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day() } func IsNextToday(d int64) bool {