美食城优化
This commit is contained in:
parent
ceef317391
commit
b9b4cb0909
@ -5,7 +5,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -22,8 +21,8 @@ func (this *apiComp) CreateOrderCheck(session comm.IUserSession, req *pb.Gourmet
|
||||
///美食城创建订单
|
||||
func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreateOrderReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
res []*cfg.Gameatn // 订单消耗
|
||||
costTime int32
|
||||
res []*cfg.Gameatn // 订单消耗
|
||||
costTime int32 // 当前订单的总耗时
|
||||
szTime map[int32]int32 // 记录每个类型的订单耗时 key 是技能组type value 订单耗时
|
||||
privilegeAddItme int32 // 特权额外增加的时间
|
||||
)
|
||||
@ -48,10 +47,10 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
}
|
||||
|
||||
if !utils.IsToday(_gourmet.Ctime) { // 跨天了
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
_gourmet.OrderCostTime = 0
|
||||
}
|
||||
// if !utils.IsToday(_gourmet.Ctime) { // 跨天了
|
||||
// _gourmet.Ctime = configure.Now().Unix()
|
||||
// _gourmet.OrderCostTime = 0
|
||||
// }
|
||||
// 计算消耗
|
||||
for _, order := range req.Order {
|
||||
if order.FoodCount == 0 {
|
||||
@ -97,9 +96,6 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
// 重新计算时间
|
||||
for _, v := range _gourmet.Foods {
|
||||
if v.FoodCount == 0 {
|
||||
continue
|
||||
}
|
||||
if v1, ok := szTime[v.FoodType]; ok {
|
||||
v.CookTime = v1 * v.FoodCount
|
||||
}
|
||||
|
@ -67,8 +67,8 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i
|
||||
// 计算订单信息
|
||||
func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet) {
|
||||
var (
|
||||
szTime map[int32]int32
|
||||
zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了
|
||||
szTime map[int32]int32 // 食材耗时
|
||||
zeroTime int64 // 当前时间对应的0点时间戳,用来判断是否跨天了
|
||||
)
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
szTime = make(map[int32]int32, 0)
|
||||
@ -109,7 +109,13 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
gourmet.CookingFood = &pb.Cooking{}
|
||||
gourmet.CookingFood.STime = configure.Now().Unix()
|
||||
gourmet.CookingFood.ETime = configure.Now().Unix() + int64(szTime[order.FoodType])
|
||||
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if gourmet.CookingFood.STime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时
|
||||
gourmet.OrderCostTime = 0
|
||||
for _, order := range gourmet.Foods { // 重新计算订单时常
|
||||
gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
gourmet.CookingFood.STime += int64(szTime[order.FoodType])
|
||||
oldTime := gourmet.CookingFood.ETime
|
||||
@ -117,8 +123,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if oldTime < zeroTime && zeroTime <= gourmet.CookingFood.ETime { // 跨天清空订单耗时
|
||||
gourmet.OrderCostTime = 0
|
||||
// 重新计算订单时常
|
||||
for _, order := range gourmet.Foods {
|
||||
for _, order := range gourmet.Foods { // 重新计算订单时常
|
||||
gourmet.OrderCostTime += order.FoodCount * szTime[order.FoodType]
|
||||
}
|
||||
}
|
||||
@ -132,6 +137,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
||||
bRet = true
|
||||
gourmet.TotalTime += szTime[order.FoodType]
|
||||
mapData["totalTime"] = gourmet.TotalTime
|
||||
//break
|
||||
}
|
||||
}
|
||||
if !bRet { // 没有订单可以做
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"go_dreamfactory/utils"
|
||||
|
||||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
@ -46,10 +45,10 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
|
||||
if _smithy.Ctime == 0 {
|
||||
_smithy.Ctime = configure.Now().Unix()
|
||||
}
|
||||
if !utils.IsToday(_smithy.Ctime) {
|
||||
_smithy.Ctime = configure.Now().Unix()
|
||||
_smithy.OrderCostTime = 0
|
||||
}
|
||||
// if !utils.IsToday(_smithy.Ctime) {
|
||||
// _smithy.Ctime = configure.Now().Unix()
|
||||
// _smithy.OrderCostTime = 0
|
||||
// }
|
||||
_smithy.Orders = append(_smithy.Orders, req.Order...) // 直接追加订单数据
|
||||
if _smithy.Clang == nil || (_smithy.Clang != nil && _smithy.Clang.ETime == 0) {
|
||||
for _, v := range _smithy.Orders {
|
||||
|
@ -101,7 +101,12 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
smithy.Clang = &pb.Clang{}
|
||||
smithy.Clang.STime = configure.Now().Unix()
|
||||
smithy.Clang.ETime = configure.Now().Unix() + int64(szTime[order.DeskType])
|
||||
|
||||
if smithy.Clang.STime < zeroTime && zeroTime <= smithy.Clang.ETime { // 跨天清空订单耗时
|
||||
smithy.OrderCostTime = 0
|
||||
for _, order := range smithy.Orders { // 重新计算订单时常
|
||||
smithy.OrderCostTime += order.Count * szTime[order.DeskType]
|
||||
}
|
||||
}
|
||||
} else {
|
||||
smithy.Clang.STime += int64(szTime[order.DeskType])
|
||||
oldTime := smithy.Clang.ETime
|
||||
@ -109,8 +114,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
|
||||
// 如果此时跨天了 清除订单时常
|
||||
if oldTime < zeroTime && zeroTime <= smithy.Clang.ETime { // 跨天清空订单耗时
|
||||
smithy.OrderCostTime = 0
|
||||
// 重新计算订单时常
|
||||
for _, order := range smithy.Orders {
|
||||
for _, order := range smithy.Orders { // 重新计算订单时常
|
||||
smithy.OrderCostTime += order.Count * szTime[order.DeskType]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user