优化
This commit is contained in:
parent
a81132f346
commit
663b010404
@ -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
|
||||
|
@ -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 (
|
||||
|
@ -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) // 设置货物变更时间
|
||||
}
|
||||
|
||||
// 初始化门票和虚拟币
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user