This commit is contained in:
meixiongfeng 2023-09-25 17:19:47 +08:00
parent a81132f346
commit 663b010404
4 changed files with 18 additions and 13 deletions

View File

@ -3,6 +3,7 @@ package caravan
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" 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 buyValue = caravan.Items[k].Count * caravan.Items[k].Price
var price int32 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 { for _, v := range cityInfo.Special {
if v == k { if v == k {
bFound = true bFound = true

View File

@ -11,6 +11,7 @@ func (this *apiComp) RefreshCityCheck(session comm.IUserSession, req *pb.Caravan
return return
} }
// 此协议不用
// 刷新城市信息 // 刷新城市信息
func (this *apiComp) RefreshCity(session comm.IUserSession, req *pb.CaravanRefreshCityReq) (errdata *pb.ErrorData) { func (this *apiComp) RefreshCity(session comm.IUserSession, req *pb.CaravanRefreshCityReq) (errdata *pb.ErrorData) {
var ( var (

View File

@ -148,14 +148,10 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
goodinfo := &pb.GoodsInfo{ goodinfo := &pb.GoodsInfo{
Goods: map[int32]*pb.Goods{}, Goods: map[int32]*pb.Goods{},
} }
goods := &pb.Goods{}
var index int32 var index int32
for index = 0; index < p; index++ { for index = 0; index < p; index++ {
goods.CurPeriod = index + 1
goods := &pb.Goods{
Period: 0, // 变动周期
CurPeriod: index + 1, // 当前变动周期
Price: 0, // 当前价格
}
if len(c.Changeperiod) == 2 && goods.Period == 0 { if len(c.Changeperiod) == 2 && goods.Period == 0 {
goods.Period = comm.GetRandNum(c.Changeperiod[0], c.Changeperiod[1]) goods.Period = comm.GetRandNum(c.Changeperiod[0], c.Changeperiod[1])
goods.Weightpos = comm.GetRandW(c.PriceChangeWeight) 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) goods.Weightpos = comm.GetRandW(c.PriceChangeWeight)
} }
bUp := false bUp := false
//ipos := comm.GetRandW(c.PriceChangeWeight)
if goods.Weightpos == 0 { if goods.Weightpos == 0 {
if comm.GetRandW(c.PriceChangeWeightOne) == 0 { if comm.GetRandW(c.PriceChangeWeightOne) == 0 {
bUp = true bUp = true
@ -199,10 +193,7 @@ func (this *Caravan) InitCaravanItemData(uid string, data *pb.DBCaravan) {
goodinfo.Goods[index] = goods goodinfo.Goods[index] = goods
} }
data.Allgoods[c.Itemid] = goodinfo data.Allgoods[c.Itemid] = goodinfo
//data.Goods[c.Itemid] = goods
// data.Oldprice[c.Itemid] = c.Goodsprice
} }
//data.Itemtime = configure.Now().Unix() + int64(changeTime) // 设置货物变更时间
} }
// 初始化门票和虚拟币 // 初始化门票和虚拟币

View File

@ -13,6 +13,7 @@ import (
func IsToday(d int64) bool { func IsToday(d int64) bool {
tt := time.Unix(d, 0) tt := time.Unix(d, 0)
now := configure.Now() now := configure.Now()
return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day() return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day()
} }
func IsNextToday(d int64) bool { func IsNextToday(d int64) bool {