订单消耗
This commit is contained in:
parent
702432b17a
commit
829edf4465
File diff suppressed because it is too large
Load Diff
@ -22,7 +22,7 @@ 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
|
||||
res []*cfg.Gameatn // 订单消耗
|
||||
costTime int32
|
||||
szTime map[int32]int32 // 记录每个类型的订单耗时 key 是技能组type value 订单耗时
|
||||
)
|
||||
@ -38,21 +38,19 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
// 记录每个食材耗时
|
||||
for k, v := range _gourmet.Skill {
|
||||
var _time int32
|
||||
// 计算出需要的时间
|
||||
_skillCfg := this.module.configure.GetGourmetConfigData(k, v)
|
||||
_time += _skillCfg.Needtime
|
||||
// 高效制作技能
|
||||
for k, v := range _gourmet.SpecialSkill {
|
||||
specalSkill := this.module.configure.GetGourmetConfigData(k, v)
|
||||
_time += specalSkill.Needtime
|
||||
}
|
||||
szTime[k] = _time
|
||||
szTime[k] = _skillCfg.Needtime
|
||||
}
|
||||
// 高效制作技能
|
||||
for k, v := range _gourmet.SpecialSkill {
|
||||
specalSkill := this.module.configure.GetGourmetConfigData(k, v)
|
||||
szTime[k] = specalSkill.Needtime
|
||||
}
|
||||
if !utils.IsToday(_gourmet.Ctime) { // 跨天了
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
_gourmet.OrderCostTime = 0
|
||||
}
|
||||
// 计算消耗
|
||||
for _, order := range req.Order {
|
||||
if order.FoodCount == 0 {
|
||||
continue
|
||||
@ -60,6 +58,10 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
if v, ok := szTime[order.FoodType]; ok {
|
||||
costTime += v * order.FoodCount
|
||||
}
|
||||
if v, ok := _gourmet.Skill[order.FoodType]; ok {
|
||||
conf := this.module.configure.GetGourmetConfigData(order.FoodType, v)
|
||||
res = append(res, conf.DeliciousConsume...)
|
||||
}
|
||||
}
|
||||
|
||||
// 校验时间
|
||||
@ -97,17 +99,12 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
}
|
||||
if v1, ok := szTime[v.FoodType]; ok {
|
||||
v.CookTime = v1 * v.FoodCount
|
||||
costTime += v.CookTime
|
||||
}
|
||||
}
|
||||
if _gourmet.CookingFood != nil && _gourmet.CookingFood.ETime == 0 {
|
||||
_gourmet.CookingFood = nil
|
||||
}
|
||||
if _gourmet.CookingFood == nil {
|
||||
if _gourmet.Ctime == 0 {
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
}
|
||||
|
||||
for _, v := range _gourmet.Foods {
|
||||
if v.FoodCount > 0 {
|
||||
v.FoodCount--
|
||||
@ -121,6 +118,9 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
if v.FoodCount == 0 {
|
||||
v.CookTime = 0
|
||||
}
|
||||
if _gourmet.Ctime == 0 {
|
||||
_gourmet.Ctime = configure.Now().Unix()
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -130,10 +130,6 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
||||
return
|
||||
}
|
||||
|
||||
if code = this.module.DispenseRes(session, res, true); code != pb.ErrorCode_Success { // 真正消耗
|
||||
return
|
||||
}
|
||||
|
||||
// 校验通过 写数据
|
||||
mapData := make(map[string]interface{}, 0)
|
||||
mapData["foods"] = _gourmet.Foods
|
||||
|
Loading…
Reference in New Issue
Block a user