铁匠铺台子保底字段修改+ 单元测试

This commit is contained in:
meixiongfeng 2022-09-02 14:12:21 +08:00
parent fdcd7b05e1
commit 31258667c8
7 changed files with 169 additions and 106 deletions

View File

@ -71,9 +71,9 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
costTime int32
curTime int32
szTime map[int32]int32
zTime int64
nextDay bool
nextDayTime int32
zeroTime int64 // 订单开始的时间对应第二天0点时间
nextDay bool // 是否跨天了
nextDayTime int32 // 跨天累计时间
)
mapData := make(map[string]interface{}, 0)
szTime = make(map[int32]int32, 0)
@ -92,12 +92,8 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
}
szTime[k] = _time
}
if !utils.IsToday(gourmet.Ctime) {
gourmet.Ctime = time.Now().Unix()
zTime = utils.GetZeroTime()
}
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点
costTime = int32(time.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
if costTime < 0 { // 没有完成 不做处理
return
@ -121,14 +117,21 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
}
order.CookTime = order.FoodCount * szTime[order.FoodType]
if gourmet.CookingFood == nil {
if zeroTime == 0 {
zeroTime = utils.GetZeroTime(time.Now().Unix())
}
gourmet.CookingFood = &pb.Cooking{}
gourmet.CookingFood.STime = time.Now().Unix()
gourmet.CookingFood.ETime = time.Now().Unix()
}
gourmet.CookingFood.FoodType = order.FoodType
gourmet.CookingFood.ETime = time.Now().Unix() + int64(szTime[order.FoodType])
} else {
gourmet.CookingFood.STime += int64(szTime[order.FoodType])
gourmet.CookingFood.ETime += int64(szTime[order.FoodType])
if zTime > 0 && gourmet.CookingFood.STime > zTime {
}
gourmet.CookingFood.FoodType = order.FoodType
// 判断订单是否跨天
if gourmet.CookingFood.ETime >= zeroTime && !nextDay {
gourmet.Ctime = zeroTime // 设置
gourmet.OrderCostTime = 0
nextDay = true
}
@ -163,6 +166,11 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
gourmet.OrderCostTime += szTime[order.FoodType] * order.FoodCount
}
}
if utils.GetZeroTime(gourmet.Ctime) <= time.Now().Unix() {
gourmet.OrderCostTime = 0
}
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间
foodtype := gourmet.CookingFood.FoodType
skillLv := gourmet.Skill[foodtype] // 获取技能等级

View File

@ -56,11 +56,10 @@ func (this *TestService) InitSys() {
}
func TestMain(m *testing.M) {
hero := &pb.DBHero{}
hero.Block = false
hero.Lv = 12
new := CloneNewHero(hero)
fmt.Printf("%v", new)
currentTime := time.Unix(1637420154, 0)
startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location())
fmt.Print(startTime.Unix())
service = newService(
rpcx.SetConfPath("../../bin/conf/worker_1.yaml"),
)

View File

@ -56,8 +56,17 @@ func (this *apiComp) DeskSkillLv(session comm.IUserSession, req *pb.SmithyDeskSk
if n.Int64() < int64(curSkillCfg.Probability) { // 可以升级
// 技能升级成功
_smithy.Skill[req.DeskType] += 1
_smithy.DeskFloor[req.DeskType] = 0
this.module.modelSmithy.CalculationDeskSkillLv(session.GetUserId(), _smithy)
} else {
_smithy.DeskFloor[req.DeskType] += 1
if _smithy.DeskFloor[req.DeskType] >= curSkillCfg.Floors { // 触发保底
_smithy.Skill[req.DeskType] += 1
_smithy.DeskFloor[req.DeskType] = 0
this.module.modelSmithy.CalculationDeskSkillLv(session.GetUserId(), _smithy)
}
}
} else {
code = pb.ErrorCode_GourmetSkillMaxLv

View File

@ -16,7 +16,7 @@ func (this *apiComp) StoveSkillLvCheck(session comm.IUserSession, req *pb.Smithy
}
func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStoveSkillLvReq) (code pb.ErrorCode, dat proto.Message) {
var bLevelUp bool
code = this.StoveSkillLvCheck(session, req)
if code != pb.ErrorCode_Success {
return // 参数校验失败直接返回
@ -46,11 +46,18 @@ func (this *apiComp) StoveSkillLv(session comm.IUserSession, req *pb.SmithyStove
n, _ := rand.Int(rand.Reader, big.NewInt(100))
if n.Int64() < int64(curLvData.Probability) { // 可以升级
// 技能升级成功
bLevelUp = true
} else { // 升级失败了 记录
_smithy.StoveFloor += 1
if curLvData.Floors >= _smithy.StoveFloor { // 触发保底
bLevelUp = true
}
}
if bLevelUp {
_smithy.StoveFloor = 0 // 清理保底数据
_smithy.StoveLv += 1
this.module.modelSmithy.CalculationStoveSkillLv(session.GetUserId(), _smithy, _smithy.StoveLv)
}
session.SendMsg(string(this.module.GetType()), SmithyDeskSkillLvResp, &pb.SmithyDeskSkillLvResp{Data: _smithy})
return
}

View File

@ -40,9 +40,11 @@ func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err err
result.Uid = uid
result.Skill = make(map[int32]int32, 0)
result.StoveLv = 1 // storv 等级默认1级
result.DeskFloor = make(map[int32]int32, 0)
mapType := this.module.configure.GetSmithyTypeConfigData() // 找类型
for key := range mapType {
result.Skill[key] = 1
result.DeskFloor[key] = 0
}
if err = this.Add(uid, result); err != nil {
@ -59,96 +61,125 @@ func (this *modelSmithy) getSmithyList(uid string) (result *pb.DBSmithy, err err
func (this *modelSmithy) modifySmithyDataByObjId(uid string, data map[string]interface{}) error {
return this.Change(uid, data)
}
// 计算订单信息
func (this *modelSmithy) CalculationSmithy(uid string, Smithy *pb.DBSmithy) {
func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
var (
bCooking bool
costTime int32
curTime int32
szTime map[int32]int32 // k 台子类型 v订单耗时
zeroTime int64 // 订单开始的时间对应第二天0点时间
nextDay bool // 是否跨天了
nextDayTime int32 // 跨天累计时间
)
mapData := make(map[string]interface{}, 0)
if Smithy.Clang != nil && Smithy.Clang.ETime > 0 {
costTime = int32(time.Now().Unix() - Smithy.Clang.ETime) // 当前过去的时间
szTime = make(map[int32]int32, 0)
defer this.module.ModifySmithyData(uid, mapData)
// 记录每个食材耗时
for k, v := range smithy.Skill {
// 计算出需要的时间
_skillCfg := this.module.configure.GetSmithyStoveConfigData(v) // 技能配置表
szTime[k] = _skillCfg.Time
}
if smithy.Clang != nil && smithy.Clang.ETime > 0 {
zeroTime = utils.GetZeroTime(smithy.Clang.STime) // 获取订单开始时间当天的0点
costTime = int32(time.Now().Unix() - smithy.Clang.ETime) // 当前过去的时间
if costTime < 0 { // 没有完成 不做处理
return
}
}
if Smithy.Clang == nil {
Smithy.Clang = &pb.Clang{}
}
for _, order := range Smithy.Orders {
for _, order := range smithy.Orders {
if order.Count == 0 {
continue
}
foodtype := order.DeskType
// 获取技能等级
skillLv := Smithy.Skill[foodtype]
desktype := order.DeskType
skillLv := smithy.Skill[desktype] // 获取技能等级
// 计算出需要的时间
_skillCfg := this.module.configure.GetSmithyStoveConfigData(skillLv) // 技能配置表
_Smithycfg := this.module.configure.GetSmithyConfigData(foodtype, skillLv) // 美食家配置表
for i := 0; i < int(order.Count); i++ {
curTime += _skillCfg.Time
// 判断是不是第二天
if Smithy.Clang.ETime == 0 {
Smithy.Clang.ETime = time.Now().Unix()
}
if !utils.IsToday(Smithy.Clang.ETime + int64(curTime)) { // 判断是不是今天
// 跨天了
Smithy.Clang.ETime = Smithy.Clang.ETime + int64(curTime) // 设置下单的时间
Smithy.Clang.STime = Smithy.Clang.ETime - int64(curTime) // 设置下单的时间
Smithy.Ctime = Smithy.Clang.ETime // 设置创建订单时间
Smithy.OrderCostTime = 0 // 清空当天的订单时长
}
_smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv) // 美食家配置表
iCount := int(order.Count)
for i := 0; i < iCount; i++ {
curTime += szTime[order.DeskType]
order.Count--
if order.Count == 0 {
order.NeedTime = 0
}
order.NeedTime = order.Count * szTime[order.DeskType]
if smithy.Clang == nil {
if zeroTime == 0 {
zeroTime = utils.GetZeroTime(time.Now().Unix())
}
smithy.Clang = &pb.Clang{}
smithy.Clang.STime = time.Now().Unix()
smithy.Clang.ETime = time.Now().Unix() + int64(szTime[order.DeskType])
} else {
smithy.Clang.STime += int64(szTime[order.DeskType])
smithy.Clang.ETime += int64(szTime[order.DeskType])
}
smithy.Clang.DeskType = order.DeskType
Smithy.Items = this.module.configure.GetMultipleDropReward(1, _Smithycfg.Drop, Smithy.Items) // 获取掉落奖励
mapData["items"] = Smithy.Items
// 判断订单是否跨天
if smithy.Clang.ETime >= zeroTime && !nextDay {
smithy.Ctime = zeroTime // 设置
smithy.OrderCostTime = 0
nextDay = true
}
if nextDay {
nextDayTime += szTime[order.DeskType]
}
if curTime > costTime {
Smithy.OrderCostTime += int32(curTime - costTime)
// 转时间戳
eTimd := time.Now().Unix() + int64(curTime-costTime)
Smithy.Clang.DeskType = order.DeskType
Smithy.Clang.ETime = eTimd
Smithy.Clang.STime = time.Now().Unix() - int64(curTime-costTime)
smithy.Clang.DeskType = order.DeskType
smithy.Clang.ETime = time.Now().Unix() + int64(curTime-costTime)
smithy.Clang.STime = smithy.Clang.ETime - int64(szTime[order.DeskType])
bCooking = true
// 记录下订单时间
Smithy.Ctime = time.Now().Unix()
mapData["ctime"] = Smithy.Ctime
smithy.Ctime = time.Now().Unix()
mapData["ctime"] = smithy.Ctime
break
}
Smithy.OrderCostTime += curTime
smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items) // 获取掉落奖励
}
if bCooking { // 分配了正在製作的食物
break
}
}
if !bCooking { // 经过计算没有烹饪食物的时候
Smithy.Clang = nil
if nextDay {
smithy.OrderCostTime += nextDayTime
for _, order := range smithy.Orders {
if order.Count == 0 {
continue
}
sz := make([]*pb.OrderClang, 0)
for _, v := range Smithy.Orders {
if v.Count != 0 {
sz = append(sz, v)
smithy.OrderCostTime += szTime[order.DeskType] * order.Count
}
}
Smithy.Orders = sz
if utils.GetZeroTime(smithy.Ctime) <= time.Now().Unix() {
smithy.OrderCostTime = 0
}
if smithy.Clang != nil && smithy.Clang.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间
desktype := smithy.Clang.DeskType
skillLv := smithy.Skill[desktype] // 获取技能等级
_smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv)
smithy.Items = this.module.configure.GetMultipleDropReward(_smithycfg.Using, _smithycfg.Drop, smithy.Items)
smithy.Clang = nil
}
// 保存信息
mapData["orders"] = Smithy.Orders
mapData["orderCostTime"] = Smithy.OrderCostTime
mapData["clang"] = Smithy.Clang // 正在做的
this.module.ModifySmithyData(uid, mapData)
mapData["items"] = smithy.Items
mapData["orders"] = smithy.Orders
mapData["orderCostTime"] = smithy.OrderCostTime
mapData["clang"] = smithy.Clang // 正在做的
}
// 技能升级 重计算时间消耗
func (this *modelSmithy) CalculationDeskSkillLv(uid string, Smithy *pb.DBSmithy) {
mapData := make(map[string]interface{}, 0)
mapData["skill"] = Smithy.Skill
mapData["deskFloor"] = Smithy.DeskFloor
this.module.ModifySmithyData(uid, mapData)
}
@ -167,5 +198,6 @@ func (this *modelSmithy) CalculationStoveSkillLv(uid string, Smithy *pb.DBSmithy
}
}
mapData["stoveLv"] = Smithy.StoveLv
mapData["deskFloor"] = Smithy.DeskFloor
this.module.ModifySmithyData(uid, mapData)
}

View File

@ -161,7 +161,7 @@ type DBSmithy struct {
StoveLv int32 `protobuf:"varint,7,opt,name=stoveLv,proto3" json:"stoveLv" bson:"stoveLv"` //炉子等级
OrderCostTime int32 `protobuf:"varint,8,opt,name=orderCostTime,proto3" json:"orderCostTime" bson:"orderCostTime"` //订单消耗的时常
Ctime int64 `protobuf:"varint,9,opt,name=ctime,proto3" json:"ctime"` // 订单创建时间
DeskFloor int32 `protobuf:"varint,10,opt,name=deskFloor,proto3" json:"deskFloor"` //@go_tags(`bson:"deskFloor"`)台子保底
DeskFloor map[int32]int32 `protobuf:"bytes,10,rep,name=deskFloor,proto3" json:"deskFloor" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //@go_tags(`bson:"deskFloor"`)台子保底
StoveFloor int32 `protobuf:"varint,11,opt,name=stoveFloor,proto3" json:"stoveFloor" bson:"stoveFloor"` //炉子保底
}
@ -260,11 +260,11 @@ func (x *DBSmithy) GetCtime() int64 {
return 0
}
func (x *DBSmithy) GetDeskFloor() int32 {
func (x *DBSmithy) GetDeskFloor() map[int32]int32 {
if x != nil {
return x.DeskFloor
}
return 0
return nil
}
func (x *DBSmithy) GetStoveFloor() int32 {
@ -290,7 +290,7 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{
0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x65, 0x65, 0x64, 0x54, 0x69, 0x6d,
0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x6e, 0x65, 0x65, 0x64, 0x54, 0x69, 0x6d,
0x65, 0x22, 0x8c, 0x03, 0x0a, 0x08, 0x44, 0x42, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x12, 0x0e,
0x65, 0x22, 0xe4, 0x03, 0x0a, 0x08, 0x44, 0x42, 0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x12, 0x0e,
0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x10,
0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64,
0x12, 0x1c, 0x0a, 0x05, 0x63, 0x6c, 0x61, 0x6e, 0x67, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32,
@ -307,15 +307,21 @@ var file_smithy_smithy_db_proto_rawDesc = []byte{
0x6f, 0x72, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20,
0x01, 0x28, 0x05, 0x52, 0x0d, 0x6f, 0x72, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x73, 0x74, 0x54, 0x69,
0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28,
0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x73, 0x6b,
0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x65, 0x73,
0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46,
0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76,
0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28,
0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18,
0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01,
0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x03, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x36, 0x0a, 0x09, 0x64, 0x65, 0x73, 0x6b,
0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0a, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x44, 0x42,
0x53, 0x6d, 0x69, 0x74, 0x68, 0x79, 0x2e, 0x44, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x09, 0x64, 0x65, 0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x18, 0x0b,
0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x74, 0x6f, 0x76, 0x65, 0x46, 0x6c, 0x6f, 0x6f, 0x72,
0x1a, 0x38, 0x0a, 0x0a, 0x53, 0x6b, 0x69, 0x6c, 0x6c, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e, 0x44, 0x65,
0x73, 0x6b, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03,
0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14,
0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76,
0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -330,24 +336,26 @@ func file_smithy_smithy_db_proto_rawDescGZIP() []byte {
return file_smithy_smithy_db_proto_rawDescData
}
var file_smithy_smithy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
var file_smithy_smithy_db_proto_msgTypes = make([]protoimpl.MessageInfo, 5)
var file_smithy_smithy_db_proto_goTypes = []interface{}{
(*Clang)(nil), // 0: Clang
(*OrderClang)(nil), // 1: OrderClang
(*DBSmithy)(nil), // 2: DBSmithy
nil, // 3: DBSmithy.SkillEntry
(*UserAssets)(nil), // 4: UserAssets
nil, // 4: DBSmithy.DeskFloorEntry
(*UserAssets)(nil), // 5: UserAssets
}
var file_smithy_smithy_db_proto_depIdxs = []int32{
0, // 0: DBSmithy.clang:type_name -> Clang
1, // 1: DBSmithy.orders:type_name -> OrderClang
4, // 2: DBSmithy.items:type_name -> UserAssets
5, // 2: DBSmithy.items:type_name -> UserAssets
3, // 3: DBSmithy.skill:type_name -> DBSmithy.SkillEntry
4, // [4:4] is the sub-list for method output_type
4, // [4:4] is the sub-list for method input_type
4, // [4:4] is the sub-list for extension type_name
4, // [4:4] is the sub-list for extension extendee
0, // [0:4] is the sub-list for field type_name
4, // 4: DBSmithy.deskFloor:type_name -> DBSmithy.DeskFloorEntry
5, // [5:5] is the sub-list for method output_type
5, // [5:5] is the sub-list for method input_type
5, // [5:5] is the sub-list for extension type_name
5, // [5:5] is the sub-list for extension extendee
0, // [0:5] is the sub-list for field type_name
}
func init() { file_smithy_smithy_db_proto_init() }
@ -400,7 +408,7 @@ func file_smithy_smithy_db_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_smithy_smithy_db_proto_rawDesc,
NumEnums: 0,
NumMessages: 4,
NumMessages: 5,
NumExtensions: 0,
NumServices: 0,
},

View File

@ -1,6 +1,8 @@
package utils
import "time"
import (
"time"
)
// 判断时间点处于今天
func IsToday(d int64) bool {
@ -19,12 +21,10 @@ func IsAfterWeek(d int64) bool {
return now.Sub(tt) >= time.Hour*24*7
}
// 获取0点时间戳
func GetZeroTime() int64 {
currentTime := time.Now()
// 获取当前时间戳下一天0点时间戳
func GetZeroTime(curTime int64) int64 {
currentTime := time.Unix(curTime, 0)
startTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), 0, 0, 0, 0, currentTime.Location())
return startTime.Unix()
return startTime.Unix() + 86400 //3600*24
}