订单跨天情况
This commit is contained in:
parent
117019a57d
commit
aaeb434528
@ -4,6 +4,7 @@ import (
|
|||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -65,6 +66,13 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
|
|||||||
}
|
}
|
||||||
|
|
||||||
if _gourmet.CookingFood == nil || (_gourmet.CookingFood != nil && _gourmet.CookingFood.ETime == 0) {
|
if _gourmet.CookingFood == nil || (_gourmet.CookingFood != nil && _gourmet.CookingFood.ETime == 0) {
|
||||||
|
if _gourmet.Ctime == 0 {
|
||||||
|
_gourmet.Ctime = time.Now().Unix()
|
||||||
|
}
|
||||||
|
if !utils.IsToday(_gourmet.Ctime) {
|
||||||
|
_gourmet.Ctime = time.Now().Unix()
|
||||||
|
_gourmet.OrderCostTime = 0
|
||||||
|
}
|
||||||
for _, v := range _gourmet.Foods {
|
for _, v := range _gourmet.Foods {
|
||||||
if v.FoodCount > 0 {
|
if v.FoodCount > 0 {
|
||||||
v.FoodCount--
|
v.FoodCount--
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
|
"go_dreamfactory/utils"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
@ -60,8 +61,8 @@ func (this *modelGourmet) modifyGourmetDataByObjId(uid string, data map[string]i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// todo 调用drop 表 获取掉落信息
|
// todo 调用drop 表 获取掉落信息
|
||||||
func (this *modelGourmet) GetDropReward(count, dropId int32) (res []*cfg.Gameatn) {
|
func (this *modelGourmet) GetDropReward(count, dropId int32, Items []*pb.UserAssets) {
|
||||||
|
res := make([]*cfg.Gameatn, 0)
|
||||||
for i := 0; i < int(count); i++ {
|
for i := 0; i < int(count); i++ {
|
||||||
data := this.module.configure.GetDropData(dropId)
|
data := this.module.configure.GetDropData(dropId)
|
||||||
szW := make([]int32, 0)
|
szW := make([]int32, 0)
|
||||||
@ -71,6 +72,22 @@ func (this *modelGourmet) GetDropReward(count, dropId int32) (res []*cfg.Gameatn
|
|||||||
index := comm.GetRandW(szW)
|
index := comm.GetRandW(szW)
|
||||||
res = append(res, data[index].Prize...)
|
res = append(res, data[index].Prize...)
|
||||||
}
|
}
|
||||||
|
for _, v := range res {
|
||||||
|
bFind := false
|
||||||
|
for _, v1 := range Items {
|
||||||
|
if v.A == v1.A && v.T == v1.T {
|
||||||
|
v1.N += v.N
|
||||||
|
bFind = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !bFind {
|
||||||
|
Items = append(Items, &pb.UserAssets{
|
||||||
|
A: v.A,
|
||||||
|
T: v.T,
|
||||||
|
N: v.N,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -105,26 +122,21 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
|
|||||||
_gourmetcfg := this.module.configure.GetGourmetConfigData(foodtype, skillLv) // 美食家配置表
|
_gourmetcfg := this.module.configure.GetGourmetConfigData(foodtype, skillLv) // 美食家配置表
|
||||||
for i := 0; i < int(order.FoodCount); i++ {
|
for i := 0; i < int(order.FoodCount); i++ {
|
||||||
curTime += _skillCfg.Needtime
|
curTime += _skillCfg.Needtime
|
||||||
|
// 判断是不是第二天
|
||||||
|
if gourmet.CookingFood.ETime == 0 {
|
||||||
|
gourmet.CookingFood.ETime = time.Now().Unix()
|
||||||
|
}
|
||||||
|
if !utils.IsToday(gourmet.CookingFood.ETime + int64(curTime)) { // 判断是不是今天
|
||||||
|
// 跨天了
|
||||||
|
gourmet.CookingFood.ETime = gourmet.CookingFood.ETime + int64(curTime) // 设置下单的时间
|
||||||
|
gourmet.Ctime = gourmet.CookingFood.ETime // 设置创建订单时间
|
||||||
|
gourmet.OrderCostTime = 0 // 清空当天的订单时长
|
||||||
|
}
|
||||||
order.FoodCount--
|
order.FoodCount--
|
||||||
res := this.GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup)
|
this.GetDropReward(_gourmetcfg.Using, _gourmetcfg.Propsgroup, gourmet.Items) // 获取掉落奖励
|
||||||
for _, v := range res {
|
|
||||||
bFind := false
|
|
||||||
for _, v1 := range gourmet.Items {
|
|
||||||
if v.A == v1.A && v.T == v1.T {
|
|
||||||
v1.N += v.N
|
|
||||||
bFind = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !bFind {
|
|
||||||
gourmet.Items = append(gourmet.Items, &pb.UserAssets{
|
|
||||||
A: v.A,
|
|
||||||
T: v.T,
|
|
||||||
N: v.N,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if curTime > costTime {
|
if curTime > costTime {
|
||||||
|
gourmet.OrderCostTime += int32(curTime - costTime)
|
||||||
// 转时间戳
|
// 转时间戳
|
||||||
eTimd := time.Now().Unix() + int64(curTime-costTime)
|
eTimd := time.Now().Unix() + int64(curTime-costTime)
|
||||||
gourmet.CookingFood.FoodType = order.FoodType
|
gourmet.CookingFood.FoodType = order.FoodType
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
模块名:Gourmet
|
||||||
|
描述:美食家模块
|
||||||
|
开发:梅雄风
|
||||||
|
*/
|
||||||
package gourmet
|
package gourmet
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
Loading…
Reference in New Issue
Block a user