调整服务器时间戳接口

This commit is contained in:
liwei1dao 2022-11-09 14:18:03 +08:00
parent 8ae9c6842f
commit a51c966aaf
65 changed files with 215 additions and 226 deletions

View File

@ -3,7 +3,7 @@ package arena
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto"
)
@ -54,7 +54,7 @@ func (this *apiComp) Challenge(session comm.IUserSession, req *pb.ArenaChallenge
if red.Ticket > 0 {
red.Ticket--
if red.Lastrtickettime == 0 {
red.Lastrtickettime = time.Now().Unix()
red.Lastrtickettime = configure.Now().Unix()
}
} else {
code = pb.ErrorCode_ArenaTicketNotEnough

View File

@ -3,8 +3,8 @@ package arena
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"google.golang.org/protobuf/proto"
)
@ -131,7 +131,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha
redrecord := &pb.DBArenaBattleRecord{
Bid: req.Report.Info.Id,
Time: time.Now().Unix(),
Time: configure.Now().Unix(),
Iswin: req.Iswin,
Isdefend: false,
Rivalid: bule.Uid,
@ -156,7 +156,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha
info.Record = append(info.Record, redrecord)
buleRecord := &pb.DBArenaBattleRecord{
Bid: req.Report.Info.Id,
Time: time.Now().Unix(),
Time: configure.Now().Unix(),
Iswin: !req.Iswin,
Isdefend: true,
Rivalid: red.Uid,
@ -196,7 +196,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha
redrecord := &pb.DBArenaBattleRecord{
Bid: req.Report.Info.Id,
Time: time.Now().Unix(),
Time: configure.Now().Unix(),
Iswin: req.Iswin,
Isdefend: false,
Rivalid: bule.Uid,

View File

@ -3,6 +3,7 @@ package arena
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -60,7 +61,7 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (code
if info.Ticket > 0 {
info.Ticket--
if info.Lastrtickettime == 0 {
info.Lastrtickettime = time.Now().Unix()
info.Lastrtickettime = configure.Now().Unix()
}
} else {
code = pb.ErrorCode_ArenaTicketNotEnough
@ -68,7 +69,7 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (code
}
if info.Npc[req.Pid] != nil {
ndata := info.Npc[req.Pid]
if !time.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
if !configure.Now().After(time.Unix(ndata.Cd, 0)) { //已经过了cd时间
code = pb.ErrorCode_ArenaTicketNpcInCd
return
}

View File

@ -3,6 +3,7 @@ package arena
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -53,7 +54,7 @@ func (this *apiComp) PlotReward(session comm.IUserSession, req *pb.ArenaPlotRewa
if len(npc.MonsterformatId) > int(info.Npc[req.Pid].Index+1) {
info.Npc[req.Pid].Index++
}
info.Npc[req.Pid].Cd = time.Now().Add(time.Minute * time.Duration(npc.ReviveCd)).Unix()
info.Npc[req.Pid].Cd = configure.Now().Add(time.Minute * time.Duration(npc.ReviveCd)).Unix()
if err = this.module.modelArena.Change(info.Uid, map[string]interface{}{
"npc": info.Npc,
}); err != nil {

View File

@ -9,6 +9,7 @@ import (
"go_dreamfactory/lego/utils/container/id"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"math"
@ -284,7 +285,7 @@ func (this *modelArena) matchePlayer(uid string, dan, num int32) (results []*pb.
//随机用户名
func (this *modelArena) randUserName() string {
var s = []byte("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*")
r := rand.New(rand.NewSource(time.Now().UnixNano() + rand.Int63n(10000)))
r := rand.New(rand.NewSource(configure.Now().UnixNano() + rand.Int63n(10000)))
result := []byte("DWA_")
for i, v := range r.Perm(len(s)) {
result = append(result, s[v])
@ -371,7 +372,7 @@ func (this *modelArena) recoverTicket(info *pb.DBArenaUser) {
)
global := this.module.configure.GetGlobalConf()
if info.Ticket < global.ArenaTicketMax && info.Lastrtickettime > 0 {
duration = time.Now().Sub(time.Unix(info.Lastrtickettime, 0))
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
if ticketNum > 0 {
info.Ticket += ticketNum

View File

@ -7,8 +7,8 @@ import (
"go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"github.com/go-redis/redis/v8"
)
@ -114,7 +114,7 @@ func (this *modelRank) raceSettlement() {
}
//发邮件
this.module.mail.SendNewMail(&pb.DBMailData{
CreateTime: uint64(time.Now().Unix()),
CreateTime: uint64(configure.Now().Unix()),
Items: Items,
}, uids...)
}

View File

@ -3,9 +3,9 @@ package equipment
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"math/rand"
"time"
"google.golang.org/protobuf/proto"
)
@ -55,7 +55,7 @@ func (this *apiComp) Wash(session comm.IUserSession, req *pb.EquipmentWashReq) (
}
adverbEntry = make([]*pb.EquipmentAttributeEntry, len(equip.AdverbEntry))
r := rand.New(rand.NewSource(time.Now().Unix()))
r := rand.New(rand.NewSource(configure.Now().Unix()))
for i, v := range r.Perm(len(equip.AdverbEntry)) {
adverbEntry[i] = &pb.EquipmentAttributeEntry{
Id: attrlibrarys[v].Key,

View File

@ -5,10 +5,10 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"math/rand"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -275,7 +275,7 @@ func (this *modelEquipmentComp) newEquipment(uid string, conf *cfg.GameEquipData
}
}
if satterNum > 0 && satterNum <= 4 {
r := rand.New(rand.NewSource(time.Now().Unix()))
r := rand.New(rand.NewSource(configure.Now().Unix()))
if conf.EquipId == 1 {
equipment.AdverbEntry = make([]*pb.EquipmentAttributeEntry, 0)
for _, v := range r.Perm(len(sattr))[:satterNum] {
@ -341,7 +341,7 @@ func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equ
}
}
if len(sattr) > 0 {
r := rand.New(rand.NewSource(time.Now().Unix()))
r := rand.New(rand.NewSource(configure.Now().Unix()))
index := r.Perm(len(sattr))[0]
if equip.EquipId == 1 {
equipment.AdverbEntry = append(equipment.AdverbEntry, &pb.EquipmentAttributeEntry{
@ -369,7 +369,7 @@ func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equ
}
if equip.EquipId == 1 {
var attrlibrary *cfg.GameEquipAttrlibraryData
r := rand.New(rand.NewSource(time.Now().Unix()))
r := rand.New(rand.NewSource(configure.Now().Unix()))
index := r.Perm(len(equipment.AdverbEntry))[0]
if attrlibrary, err = this.module.configure.GetEquipmentAttrlibraryConfigureByKey(equipment.AdverbEntry[index].Id); err != nil {
return
@ -380,7 +380,7 @@ func (this *modelEquipmentComp) upgradeEquipment(equipment *pb.DB_Equipment, equ
}
equipment.AdverbEntry[index].Lv++
} else {
r := rand.New(rand.NewSource(time.Now().Unix()))
r := rand.New(rand.NewSource(configure.Now().Unix()))
index := r.Perm(len(equipment.Adverbskill))[0]
equipment.Adverbskill[index].Lv++
}

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
@ -126,12 +126,12 @@ func (this *Friend) UseAssistHero(uid, friendId string) (*pb.DBHero, error) {
friend.Record = append(friend.Record, &pb.AssistRecord{
Uid: uid,
AssistHeroId: friend.AssistHeroId,
AssistTime: time.Now().Unix(),
AssistTime: configure.Now().Unix(),
})
update := map[string]interface{}{
"assistScore": friend.AssistScore,
"record": friend.Record,
"updateTime": time.Now().Unix(),
"updateTime": configure.Now().Unix(),
}
return friend.Hero, this.modelFriend.Change(friendId, update)
}

View File

@ -6,6 +6,7 @@ import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"strings"
"sync"
@ -141,7 +142,7 @@ func (this *Agent) decodeUserData(msg *pb.UserMessage) (code pb.ErrorCode, err e
log.Errorf("base64 decode err %v", err)
return pb.ErrorCode_DecodeError, nil
}
now := time.Now().Unix()
now := configure.Now().Unix()
jsonRet := gjson.Parse(string(dec))
timestamp := jsonRet.Get("timestamp").Int()
//秘钥30秒失效
@ -265,7 +266,7 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) (err error) {
servicePath = fmt.Sprintf("%s/%s", comm.Service_Worker, this.wId)
}
}
stime := time.Now()
stime := configure.Now()
if len(serviceTag) == 0 {
if err = this.gateway.Service().RpcCall(context.Background(), servicePath, string(comm.Rpc_GatewayRoute), req, reply); err != nil {
this.gateway.Error("[UserResponse]",

View File

@ -3,9 +3,9 @@ package gourmet
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -50,7 +50,7 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
szTime[k] = _time
}
if !utils.IsToday(_gourmet.Ctime) { // 跨天了
_gourmet.Ctime = time.Now().Unix()
_gourmet.Ctime = configure.Now().Unix()
_gourmet.OrderCostTime = 0
}
for _, order := range req.Order {
@ -105,7 +105,7 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
}
if _gourmet.CookingFood == nil {
if _gourmet.Ctime == 0 {
_gourmet.Ctime = time.Now().Unix()
_gourmet.Ctime = configure.Now().Unix()
}
for _, v := range _gourmet.Foods {
@ -115,8 +115,8 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.GourmetCreat
// 获取生产时间
_gourmet.CookingFood = &pb.Cooking{
FoodType: v.FoodType,
ETime: time.Now().Unix() + int64(szTime[v.FoodType]),
STime: time.Now().Unix(),
ETime: configure.Now().Unix() + int64(szTime[v.FoodType]),
STime: configure.Now().Unix(),
}
if v.FoodCount == 0 {
v.CookTime = 0

View File

@ -3,7 +3,7 @@ package gourmet
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto"
)
@ -27,7 +27,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.GourmetGetListRe
return
}
if _gourmet.Ctime == 0 {
_gourmet.Ctime = time.Now().Unix()
_gourmet.Ctime = configure.Now().Unix()
}
// 计算订单信息
this.module.modelGourmet.CalculationGourmet(session.GetUserId(), _gourmet)

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -94,7 +94,7 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
}
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime > 0 {
zeroTime = utils.GetZeroTime(gourmet.CookingFood.STime) // 获取订单开始时间当天的0点
costTime = int32(time.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
costTime = int32(configure.Now().Unix() - gourmet.CookingFood.ETime) // 当前过去的时间
if costTime < 0 { // 没有完成 不做处理
return
}
@ -118,11 +118,11 @@ 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())
zeroTime = utils.GetZeroTime(configure.Now().Unix())
}
gourmet.CookingFood = &pb.Cooking{}
gourmet.CookingFood.STime = time.Now().Unix()
gourmet.CookingFood.ETime = time.Now().Unix() + int64(szTime[order.FoodType])
gourmet.CookingFood.STime = configure.Now().Unix()
gourmet.CookingFood.ETime = configure.Now().Unix() + int64(szTime[order.FoodType])
} else {
gourmet.CookingFood.STime += int64(szTime[order.FoodType])
gourmet.CookingFood.ETime += int64(szTime[order.FoodType])
@ -143,12 +143,12 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
if curTime > costTime {
// 转时间戳
gourmet.CookingFood.FoodType = order.FoodType
gourmet.CookingFood.ETime = time.Now().Unix() + int64(curTime-costTime)
gourmet.CookingFood.ETime = configure.Now().Unix() + int64(curTime-costTime)
gourmet.CookingFood.STime = gourmet.CookingFood.ETime - int64(szTime[order.FoodType])
bCooking = true
// 记录下订单时间
gourmet.Ctime = time.Now().Unix()
gourmet.Ctime = configure.Now().Unix()
mapData["ctime"] = gourmet.Ctime
break
}
@ -168,11 +168,11 @@ func (this *modelGourmet) CalculationGourmet(uid string, gourmet *pb.DBGourmet)
}
}
if utils.GetZeroTime(gourmet.Ctime) <= time.Now().Unix() {
if utils.GetZeroTime(gourmet.Ctime) <= configure.Now().Unix() {
gourmet.OrderCostTime = 0
}
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间
if gourmet.CookingFood != nil && gourmet.CookingFood.ETime <= configure.Now().Unix() { // 当前时间超过正在做的时间
foodtype := gourmet.CookingFood.FoodType
skillLv := gourmet.Skill[foodtype] // 获取技能等级
_gourmetcfg := this.module.configure.GetGourmetConfigData(foodtype, skillLv) // 美食家配置表

View File

@ -59,7 +59,7 @@ func (this *TestService) InitSys() {
}
}
func GetMonthStartEnd() (int64, int64) {
t := time.Now()
t := configure.Now()
monthStartDay := t.AddDate(0, 0, -t.Day()+1)
monthStartTime := time.Date(monthStartDay.Year(), monthStartDay.Month(), monthStartDay.Day(), 0, 0, 0, 0, t.Location())
monthEndDay := monthStartTime.AddDate(0, 1, -1)

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
)
// 记录一些扩展数据 图鉴 改名次数等
@ -35,6 +35,6 @@ func (this *ModelRecord) ChangeHeroRecord(uid string, value map[string]interface
if len(value) == 0 {
return nil
}
value["mtime"] = time.Now().Unix() //修改时间
value["mtime"] = configure.Now().Unix() //修改时间
return this.Change(uid, value)
}

View File

@ -3,6 +3,7 @@ package horoscope
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -31,7 +32,7 @@ func (this *apiComp) Reset(session comm.IUserSession, req *pb.HoroscopeResetReq)
}
conf = this.module.configure.GetGlobalConf()
if info.Lastrest > 0 {
if time.Now().Sub(time.Unix(info.Lastrest, 0)).Seconds() < float64(conf.HoroscopeResetCd) {
if configure.Now().Sub(time.Unix(info.Lastrest, 0)).Seconds() < float64(conf.HoroscopeResetCd) {
code = pb.ErrorCode_HoroscopeRestCDNoEnd
return
}
@ -41,7 +42,7 @@ func (this *apiComp) Reset(session comm.IUserSession, req *pb.HoroscopeResetReq)
return
}
info.Nodes = make(map[int32]int32)
info.Lastrest = time.Now().Unix()
info.Lastrest = configure.Now().Unix()
if err = this.module.modelHoroscope.updateInfo(session, info); err != nil {
code = pb.ErrorCode_DBError
return

View File

@ -3,9 +3,9 @@ package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -38,7 +38,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HuntingBuyReq) (code
// 校验是不是今天
if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix()
list.CTime = configure.Now().Unix()
list.BuyCount = 0
list.ChallengeCount = 0

View File

@ -3,8 +3,8 @@ package hunting
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -30,7 +30,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.HuntingGetListRe
// 校验 是不是当天
if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix()
list.CTime = configure.Now().Unix()
list.BuyCount = 0
list.ChallengeCount = 0
mapData := make(map[string]interface{}, 0)

View File

@ -3,7 +3,7 @@ package items
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto"
)
@ -45,7 +45,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ItemsGetlistReq)
modifys = make([]*pb.DB_UserItemData, 0, len(items))
dels = make([]*pb.DB_UserItemData, 0, len(items))
grids = make([]*pb.DB_UserItemData, 0, len(items))
nt = time.Now().Unix()
nt = configure.Now().Unix()
for _, v := range items {
if v.ETime > 0 && v.ETime < nt { //已经过期
dels = append(dels, v)

View File

@ -6,6 +6,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time"
@ -119,7 +120,7 @@ func (this *ModelItemsComp) UpdateUserPack(uid string, itmes ...*pb.DB_UserItemD
model.ChangeList(uid, v.GridId, map[string]interface{}{
"amount": v.Amount,
"isNewItem": v.IsNewItem,
"lastopt": time.Now().Unix(),
"lastopt": configure.Now().Unix(),
})
}
}
@ -128,7 +129,7 @@ func (this *ModelItemsComp) UpdateUserPack(uid string, itmes ...*pb.DB_UserItemD
this.ChangeList(uid, v.GridId, map[string]interface{}{
"amount": v.Amount,
"isNewItem": v.IsNewItem,
"lastopt": time.Now().Unix(),
"lastopt": configure.Now().Unix(),
})
}
}
@ -400,11 +401,11 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
UId: uid,
ItemId: itemId,
Amount: uint32(leftnum),
CTime: time.Now().Unix(),
CTime: configure.Now().Unix(),
IsNewItem: isNew,
}
if conf.Time > 0 {
grid.ETime = time.Now().Add(time.Minute * time.Duration(conf.Time)).Unix()
grid.ETime = configure.Now().Add(time.Minute * time.Duration(conf.Time)).Unix()
}
items = append(items, grid)
add = append(add, grid)
@ -417,11 +418,11 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
UId: uid,
ItemId: itemId,
Amount: uint32(conf.UpperLimit),
CTime: time.Now().Unix(),
CTime: configure.Now().Unix(),
IsNewItem: isNew,
}
if conf.Time > 0 {
grid.ETime = time.Now().Add(time.Minute * time.Duration(conf.Time)).Unix()
grid.ETime = configure.Now().Add(time.Minute * time.Duration(conf.Time)).Unix()
}
items = append(items, grid)
add = append(add, grid)

View File

@ -10,8 +10,8 @@ func TestCreateEmail(t *testing.T) {
// UserId: "uid123",
// Title: "系统邮件",
// Contex: "恭喜获得专属礼包一份",
// CreateTime: uint64(time.Now().Unix()),
// DueTime: uint64(time.Now().Unix()) + 30*24*3600,
// CreateTime: uint64(configure.Now().Unix()),
// DueTime: uint64(configure.Now().Unix()) + 30*24*3600,
// Check: false,
// Reward: false,
// })

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"go_dreamfactory/utils"
"time"
@ -43,7 +44,7 @@ func (this *Mail) OnInstallComp() {
}
func (this *Mail) CreateNewMail(session comm.IUserSession, mail *pb.DBMailData) bool {
t := time.Now()
t := configure.Now()
defer func() {
log.Debugf("创建邮件 耗时:%v", time.Since(t))
}()

View File

@ -3,6 +3,7 @@ package martialhall
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -86,9 +87,9 @@ func (this *apiComp) Practice(session comm.IUserSession, req *pb.MartialhallPrac
}
pillar.State = pb.PillarState_Useing
pillar.Hero = req.Hero
pillar.Start = time.Now().Unix()
pillar.End = time.Now().Add(time.Minute * time.Duration(req.Time)).Unix()
pillar.Lastbill = time.Now().Unix()
pillar.Start = configure.Now().Unix()
pillar.End = configure.Now().Add(time.Minute * time.Duration(req.Time)).Unix()
pillar.Lastbill = configure.Now().Unix()
pillar.Reward = 0
this.module.modelMartialhall.Change(session.GetUserId(), map[string]interface{}{
filed: pillar,

View File

@ -2,6 +2,7 @@ package martialhall
import (
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
)
@ -12,8 +13,8 @@ func settlement(pillar *pb.DBPillar, mdata *cfg.GameKungfuMasterworkerData) {
return
}
pillar.Reward += int32(time.Unix(pillar.End, 0).Sub(time.Unix(pillar.Lastbill, 0)).Minutes() * float64(mdata.Exp))
pillar.Lastbill = time.Now().Unix()
if time.Now().After(time.Unix(pillar.End, 0)) {
pillar.Lastbill = configure.Now().Unix()
if configure.Now().After(time.Unix(pillar.End, 0)) {
pillar.State = pb.PillarState_Receive
}
}
@ -24,9 +25,9 @@ func check(pillar *pb.DBPillar, mdata *cfg.GameKungfuMasterworkerData) {
return
}
//达到修炼时间
if time.Now().After(time.Unix(pillar.End, 0)) {
if configure.Now().After(time.Unix(pillar.End, 0)) {
pillar.Reward += int32(time.Unix(pillar.End, 0).Sub(time.Unix(pillar.Lastbill, 0)).Minutes() * float64(mdata.Exp))
pillar.Lastbill = time.Now().Unix()
pillar.Lastbill = configure.Now().Unix()
pillar.State = pb.PillarState_Receive
}
}

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -29,9 +30,9 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.MoonfantasyGetLi
return
}
globalconf = this.module.configure.GetGlobalConf()
if time.Unix(umfantasy.LastTrigger, 0).Day() != time.Now().Day() {
if time.Unix(umfantasy.LastTrigger, 0).Day() != configure.Now().Day() {
umfantasy.TriggerNum = 0
umfantasy.LastTrigger = time.Now().Unix()
umfantasy.LastTrigger = configure.Now().Unix()
umfantasy.BuyNum = 0
if umfantasy.BattleNum < globalconf.DreamlandFightnum {
umfantasy.BattleNum = globalconf.DreamlandFightnum

View File

@ -8,6 +8,7 @@ import (
"go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -70,11 +71,11 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml
Id: primitive.NewObjectID().Hex(),
Uid: user.Uid,
Monster: boss.Bossid,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
Join: []*pb.UserInfo{user},
Numup: boss.Challengenum,
Unitmup: boss.Fightnum,
Expir: time.Now().Add(time.Second * time.Duration(boss.DreamlandLimit)).Unix(),
Expir: configure.Now().Add(time.Second * time.Duration(boss.DreamlandLimit)).Unix(),
Record: make(map[string]int32),
}
if err = this.AddList("", result.Id, result); err != nil {
@ -100,9 +101,9 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) {
return
}
if time.Unix(umfantasy.LastTrigger, 0).Day() != time.Now().Day() {
if time.Unix(umfantasy.LastTrigger, 0).Day() != configure.Now().Day() {
umfantasy.TriggerNum = 0
umfantasy.LastTrigger = time.Now().Unix()
umfantasy.LastTrigger = configure.Now().Unix()
umfantasy.BuyNum = 0
if umfantasy.BattleNum < globalconf.DreamlandFightnum {
umfantasy.BattleNum = globalconf.DreamlandFightnum
@ -198,7 +199,7 @@ func (this *modelDreamComp) delaynoticeWorld(mid string, chat *pb.DBChat) {
}
func (this *modelDreamComp) checkMFantasyExpiration(mf *pb.DBMoonFantasy) bool {
if time.Now().After(time.Unix(mf.Expir, 0)) { //已过期
if configure.Now().After(time.Unix(mf.Expir, 0)) { //已过期
this.DelListlds("", mf.Id)
return true
}

View File

@ -3,7 +3,7 @@ package notify
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto"
)
@ -35,7 +35,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.NotifyGetListReq
}
//修改最后公告读取时间
this.module.ModuleUser.ChangeUserExpand(session.GetUserId(), map[string]interface{}{
"lastreadnotiftime": time.Now().Unix(),
"lastreadnotiftime": configure.Now().Unix(),
})
session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify})
return

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"github.com/go-redis/redis/v8"
"go.mongodb.org/mongo-driver/bson"
@ -57,7 +57,7 @@ func (this *modelNotifyComp) GetFullNotify() (result []*pb.DBSystemNotify, err e
}
if len(notifys) > 0 {
n := 0
now := time.Now().Unix()
now := configure.Now().Unix()
result = make([]*pb.DBSystemNotify, len(notifys))
for _, v := range notifys {
if now >= v.Rtime {

View File

@ -11,9 +11,9 @@ import (
"go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db"
"sort"
"time"
"github.com/go-redis/redis/v8"
@ -174,7 +174,7 @@ func (this *ModelRank) ChangeFloorRankList(session comm.IUserSession, floor int3
key := fmt.Sprintf("%s-%d-rank", floorRankKey, floor)
lockkey := fmt.Sprintf("%s-%d-lock", floorRankKey, floor)
dbModel.Redis.Lock(lockkey, time.Now().Second()*5)
dbModel.Redis.Lock(lockkey, configure.Now().Second()*5)
defer dbModel.Redis.UnLock(lockkey)
if dbModel.Redis.RPush(key, curData); err != nil {
this.modulePagoda.Errorf("err:%v", err)

View File

@ -3,6 +3,7 @@ package pay
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -39,19 +40,19 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.PayInfoReq) (code p
info.Items[v.Id] = &pb.PayDailyItem{
Id: v.Id,
Buyunm: v.BuyNum,
Lastrefresh: time.Now().Unix(),
Lastrefresh: configure.Now().Unix(),
}
}
}
for _, v := range info.Items {
if time.Now().Sub(time.Unix(v.Lastrefresh, 0)).Hours() > 24 {
if configure.Now().Sub(time.Unix(v.Lastrefresh, 0)).Hours() > 24 {
if conf, err = this.module.configure.getPayPackageData(v.Id); err != nil {
code = pb.ErrorCode_ConfigNoFound
return
}
v.Buyunm = conf.BuyNum
v.Lastrefresh = time.Now().Unix()
v.Lastrefresh = configure.Now().Unix()
}
}
if err = this.module.modelDaily.updateUserDaily(info); err != nil {

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx"
@ -77,7 +77,7 @@ func (this *modelDailyComp) delivery(session comm.IUserSession, pid string) (cod
info.Items[conf.Id] = &pb.PayDailyItem{
Id: conf.Id,
Buyunm: conf.BuyNum,
Lastrefresh: time.Now().Unix(),
Lastrefresh: configure.Now().Unix(),
}
}
info.Items[conf.Id].Buyunm--

View File

@ -8,8 +8,8 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
)
/*
@ -104,7 +104,7 @@ func (this *Pay) Rpc_ModulePayDelivery(ctx context.Context, args *pb.PayDelivery
Orderid: args.Orderid,
Uid: args.Uid,
Productid: args.Productid,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
}); err != nil {
reply.Code = pb.ErrorCode_DBError
return

View File

@ -5,9 +5,9 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
)
@ -55,16 +55,16 @@ func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cid int32)
Uid: session.GetUserId(),
Cid: cid,
PrivilegeID: []int32{},
CTime: time.Now().Unix(),
CTime: configure.Now().Unix(),
ETime: 0,
RewardTime: time.Now().Unix(),
RewardTime: configure.Now().Unix(),
}
conf, err := this.configure.GetPrivilegeCard(cid)
if err != nil {
code = pb.ErrorCode_ConfigNoFound
return nil, code
}
data.ETime = time.Now().Unix() + int64(conf.AssertDay*24*3600) // 设置过期时间
data.ETime = configure.Now().Unix() + int64(conf.AssertDay*24*3600) // 设置过期时间
for _, v := range conf.PrivilegeId {
data.PrivilegeID = append(data.PrivilegeID, v)
}
@ -89,7 +89,7 @@ func (this *Privilege) RenewPrivilegeCard(session comm.IUserSession, cid int32)
code = pb.ErrorCode_ConfigNoFound
return nil, code
}
if conf.RenewDay >= int32(time.Now().Unix()-v.ETime)/(24*3600) {
if conf.RenewDay >= int32(configure.Now().Unix()-v.ETime)/(24*3600) {
v.ETime += int64(conf.AssertDay) * 24 * 3600
mapData := make(map[string]interface{}, 0)
mapData["eTime"] = v.ETime
@ -119,7 +119,7 @@ func (this *Privilege) CheckPrivilege(session comm.IUserSession) {
return
}
for _, v := range list {
if v.ETime > time.Now().Unix() {
if v.ETime > configure.Now().Unix() {
if err := this.modelPrivilege.DelListlds(session.GetUserId(), v.Id); err != nil {
this.Errorf("delete privilege failed:%v", err)
}

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -89,7 +89,7 @@ func (this *ModelRtaskRecord) initCondiData(uid string) error {
record.Vals[v.Id] = &pb.RtaskData{
Data: toMap(vals...),
Rtype: v.Type,
Timestamp: time.Now().Unix(),
Timestamp: configure.Now().Unix(),
}
}

View File

@ -5,8 +5,8 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/modules/task"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -33,7 +33,7 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond
data := &pb.RtaskData{
Rtype: cfg.Type,
Data: toMap(vals...),
Timestamp: time.Now().Unix(),
Timestamp: configure.Now().Unix(),
}
record.Vals = map[int32]*pb.RtaskData{
cfg.Id: data,
@ -57,7 +57,7 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond
data := &pb.RtaskData{
Rtype: cfg.Type,
Data: toMap(vals...),
Timestamp: time.Now().Unix(),
Timestamp: configure.Now().Unix(),
}
record.Vals[cfg.Id] = data
@ -74,7 +74,7 @@ func (this *ModelRtaskRecord) overrideUpdate(uid string, cfg *cfg.GameRdtaskCond
// 累计更新 - 招募等
func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData, vals ...int32) (err error) {
// t := time.Now()
// t := configure.Now()
// defer func() {
// log.Debugf("add update耗时:%v", time.Since(t))
// }()
@ -91,7 +91,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
data := &pb.RtaskData{
Data: toMap(vals...),
Rtype: cfg.Type,
Timestamp: time.Now().Unix(),
Timestamp: configure.Now().Unix(),
}
record.Vals = map[int32]*pb.RtaskData{
@ -107,7 +107,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
srcCount := v.Data[0]
newCount[0] = srcCount + vals[0]
v.Data = toMap(newCount...)
v.Timestamp = time.Now().Unix()
v.Timestamp = configure.Now().Unix()
update := map[string]interface{}{
"vals": record.Vals,
@ -117,7 +117,7 @@ func (this *ModelRtaskRecord) addUpdate(uid string, cfg *cfg.GameRdtaskCondiData
record.Vals[cfg.Id] = &pb.RtaskData{
Data: toMap(vals...),
Rtype: cfg.Type,
Timestamp: time.Now().Unix(),
Timestamp: configure.Now().Unix(),
}
update := map[string]interface{}{
"vals": record.Vals,

View File

@ -4,6 +4,7 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
@ -120,7 +121,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
}
sdata.Buy = make(map[int32]int32)
goods = transGoods(items, sdata)
sdata.LastRefreshTime = time.Now().Unix()
sdata.LastRefreshTime = configure.Now().Unix()
sdata.ManualRefreshNum++
sdata.Items = make([]int32, len(items))
sdata.Preview = make(map[int32]*pb.DB_Equipment)
@ -145,7 +146,7 @@ func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq)
items = append(items, randomGoods(_items))
}
sdata.Buy = make(map[int32]int32)
sdata.LastRefreshTime = time.Now().Unix()
sdata.LastRefreshTime = configure.Now().Unix()
sdata.Items = make([]int32, len(items))
sdata.Preview = make(map[int32]*pb.DB_Equipment)
for i, v := range items {

View File

@ -3,9 +3,9 @@ package smithy
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -44,14 +44,14 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
costTime += needTime * order.Count
}
if _smithy.Ctime == 0 {
_smithy.Ctime = time.Now().Unix()
_smithy.Ctime = configure.Now().Unix()
}
_smithy.Orders = append(_smithy.Orders, req.Order...) // 直接追加订单数据
//_smithy.OrderCostTime += costTime
if _smithy.Clang == nil || (_smithy.Clang != nil && _smithy.Clang.ETime == 0) {
if !utils.IsToday(_smithy.Ctime) {
_smithy.Ctime = time.Now().Unix()
_smithy.Ctime = configure.Now().Unix()
_smithy.OrderCostTime = 0
}
for _, v := range _smithy.Orders {
@ -60,8 +60,8 @@ func (this *apiComp) CreateOrder(session comm.IUserSession, req *pb.SmithyCreate
// 获取生产时间
_smithy.Clang = &pb.Clang{
DeskType: v.DeskType,
ETime: time.Now().Unix() + int64(needTime),
STime: time.Now().Unix(),
ETime: configure.Now().Unix() + int64(needTime),
STime: configure.Now().Unix(),
}
break
}

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -83,7 +83,7 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
}
if smithy.Clang != nil && smithy.Clang.ETime > 0 {
zeroTime = utils.GetZeroTime(smithy.Clang.STime) // 获取订单开始时间当天的0点
costTime = int32(time.Now().Unix() - smithy.Clang.ETime) // 当前过去的时间
costTime = int32(configure.Now().Unix() - smithy.Clang.ETime) // 当前过去的时间
if costTime < 0 { // 没有完成 不做处理
return
}
@ -108,11 +108,11 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
order.NeedTime = order.Count * szTime[order.DeskType]
if smithy.Clang == nil {
if zeroTime == 0 {
zeroTime = utils.GetZeroTime(time.Now().Unix())
zeroTime = utils.GetZeroTime(configure.Now().Unix())
}
smithy.Clang = &pb.Clang{}
smithy.Clang.STime = time.Now().Unix()
smithy.Clang.ETime = time.Now().Unix() + int64(szTime[order.DeskType])
smithy.Clang.STime = configure.Now().Unix()
smithy.Clang.ETime = configure.Now().Unix() + int64(szTime[order.DeskType])
} else {
smithy.Clang.STime += int64(szTime[order.DeskType])
smithy.Clang.ETime += int64(szTime[order.DeskType])
@ -133,12 +133,12 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
// 转时间戳
smithy.Clang.DeskType = order.DeskType
smithy.Clang.ETime = time.Now().Unix() + int64(curTime-costTime)
smithy.Clang.ETime = configure.Now().Unix() + int64(curTime-costTime)
smithy.Clang.STime = smithy.Clang.ETime - int64(szTime[order.DeskType])
bCooking = true
// 记录下订单时间
smithy.Ctime = time.Now().Unix()
smithy.Ctime = configure.Now().Unix()
break
}
@ -166,11 +166,11 @@ func (this *modelSmithy) CalculationSmithy(uid string, smithy *pb.DBSmithy) {
}
}
if utils.GetZeroTime(smithy.Ctime) <= time.Now().Unix() {
if utils.GetZeroTime(smithy.Ctime) <= configure.Now().Unix() {
smithy.OrderCostTime = 0
}
if smithy.Clang != nil && smithy.Clang.ETime <= time.Now().Unix() { // 当前时间超过正在做的时间
if smithy.Clang != nil && smithy.Clang.ETime <= configure.Now().Unix() { // 当前时间超过正在做的时间
desktype := smithy.Clang.DeskType
skillLv := smithy.Skill[desktype] // 获取技能等级
_smithycfg := this.module.configure.GetSmithyConfigData(desktype, skillLv)

View File

@ -5,8 +5,8 @@ import (
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"strings"
"time"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto"
@ -94,7 +94,7 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
sociaty.Members = append(sociaty.Members, &pb.SociatyMember{
Uid: user.Uid,
Job: pb.SociatyJob_PRESIDENT, //创建人是会长
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
})
if err := this.module.modelSociaty.create(sociaty); err != nil {
code = pb.ErrorCode_DBError

View File

@ -9,10 +9,10 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"sort"
"time"
"github.com/pkg/errors"
@ -64,7 +64,7 @@ func (this *ModelSociaty) create(sociaty *pb.DBSociaty) error {
}
_id := primitive.NewObjectID().Hex()
sociaty.Id = _id
sociaty.Ctime = time.Now().Unix()
sociaty.Ctime = configure.Now().Unix()
sociaty.Lv = 1 //默认1级
if sociaty.Icon == "" {
sociaty.Icon = "1000" //默认图标
@ -213,7 +213,7 @@ func (this *ModelSociaty) apply(uid string, sociaty *pb.DBSociaty) error {
if sociaty.IsApplyCheck { //需要审核
sociaty.ApplyRecord = append(sociaty.ApplyRecord, &pb.ApplyRecord{
Uid: uid,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
})
update := map[string]interface{}{
"applyRecord": sociaty.ApplyRecord,
@ -368,7 +368,7 @@ func (this *ModelSociaty) addMember(uid string, sociaty *pb.DBSociaty) error {
sociaty.Members = append(sociaty.Members, &pb.SociatyMember{
Uid: uid,
Job: pb.SociatyJob_MEMBER,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
})
update := map[string]interface{}{
"members": sociaty.Members,
@ -556,7 +556,7 @@ func (this *ModelSociaty) accuse(sociaty *pb.DBSociaty) error {
}
//会长离线时间
now := time.Now().Unix()
now := configure.Now().Unix()
left := now - user.Offlinetime
if left < int64(ggd.GuildInitiateImpeachmentTime*3600) || user.Offlinetime == 0 {
return errors.New("会长很称职,无需弹劾")
@ -578,7 +578,7 @@ func (this *ModelSociaty) extendJob(srcMasterId string, sociaty *pb.DBSociaty) e
return errors.New("config not found")
}
//终止弹劾
now := time.Now().Unix()
now := configure.Now().Unix()
if now < sociaty.AccuseTime {
update := map[string]interface{}{
"accuseTime": 0,

View File

@ -6,9 +6,9 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"sort"
"strings"
"time"
"go.mongodb.org/mongo-driver/mongo"
)
@ -114,7 +114,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
var list []*pb.SociatyLog
list = append(list, &pb.SociatyLog{
Content: content,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
})
err = this.Add(sociatyId, &pb.DBSociatyLog{
SociatyId: sociatyId,
@ -133,7 +133,7 @@ func (this *ModelSociatyLog) addLog(tag Tag, sociatyId string, params ...string)
}
log.List = append(log.List, &pb.SociatyLog{
Content: content,
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
})
update := map[string]interface{}{
"sociatyId": sociatyId,

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
)
type ModelSociatyTask struct {
@ -59,7 +59,7 @@ func (this *ModelSociatyTask) initSociatyTask(uid, sociatyId string) error {
}
}
sociatyTask.TaskList = taskList
sociatyTask.LastUpdateTime = time.Now().Unix()
sociatyTask.LastUpdateTime = configure.Now().Unix()
return this.moduleSociaty.modelSociatyTask.AddList(sociatyId, uid, sociatyTask)
}

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
)
var _ comm.ISociaty = (*Sociaty)(nil)
@ -58,7 +58,7 @@ func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
sociaty := this.modelSociaty.getSociaty(sociatyId)
if sociaty != nil {
if sociaty.AccuseTime > 0 {
now := time.Now().Unix()
now := configure.Now().Unix()
if now-sociaty.AccuseTime >= int64(3600*t) {
//TODO 选新会长

View File

@ -9,6 +9,7 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"time"
)
@ -61,7 +62,7 @@ func (this *ModuleTask) Start() (err error) {
//初始化日常、周常、成就
func (this *ModuleTask) InitTaskAll(uid string) {
t := time.Now()
t := configure.Now()
defer func() {
log.Debugf("初始化任务 耗时:%v", time.Since(t))
}()

View File

@ -8,7 +8,6 @@ import (
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
@ -86,7 +85,7 @@ func (this *ChatComp) chatNoticen(content string) func() {
msg := &pb.DBChat{
Channel: pb.ChatChannel_System,
Stag: this.service.GetTag(),
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
Content: content,
}
data, _ := anypb.New(&pb.ChatMessagePush{Chat: msg})

View File

@ -9,7 +9,6 @@ import (
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db"
"time"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase"
@ -104,7 +103,7 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData {
// // 赛季塔结束
func (this *SeasonPagoda) TimerSeasonOver() {
this.module.Debugf("TimerSeasonOver:%d", time.Now().Unix())
this.module.Debugf("TimerSeasonOver:%d", configure.Now().Unix())
if conn, err := db.Cross(); err == nil {
var (
@ -122,7 +121,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
//sz := this.GetSeasonReward()
// this.mail.SendNewMail(&pb.DBMailData{
// CreateTime: uint64(time.Now().Unix()),
// CreateTime: uint64(configure.Now().Unix()),
// Items: nil,
// }, _data3...)
}
@ -157,12 +156,12 @@ func (this *SeasonPagoda) TimerSeasonOver() {
}
}
//star := time.Now()
//star := configure.Now()
this.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
}
// 赛季塔开始
func (this *SeasonPagoda) TimerSeasonStar() {
this.module.Debugf("TimerSeasonStar:%d", time.Now().Unix())
this.module.Debugf("TimerSeasonStar:%d", configure.Now().Unix())
}

View File

@ -3,8 +3,8 @@ package troll
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"math"
"time"
"google.golang.org/protobuf/proto"
)
@ -86,7 +86,7 @@ func (this *apiComp) BuyOrSell(session comm.IUserSession, req *pb.TrollBuyOrSell
trolltrain.Price[k] = 0
}
trolltrain.Price[k] = goods.Goodsprice * goods.StarMoney / 1000
trolltrain.RefreshTime = time.Now().Unix()
trolltrain.RefreshTime = configure.Now().Unix()
//消耗的金币
gold -= trolltrain.Price[k] * trolltrain.Items[k]
} else {

View File

@ -4,9 +4,9 @@ import (
"crypto/rand"
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"math/big"
"time"
"google.golang.org/protobuf/proto"
)
@ -44,7 +44,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
}
// 跨天 则清除 每日交易次数
if !utils.IsToday(trolltrain.ResetTime) {
trolltrain.ResetTime = time.Now().Unix()
trolltrain.ResetTime = configure.Now().Unix()
update["resetTime"] = trolltrain.ResetTime
trolltrain.SellCount = 0
update["sellCount"] = trolltrain.SellCount // 重置每日交易次数
@ -64,7 +64,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
for _, v := range sz {
circletime += v
}
t := int32(time.Now().Unix() - trolltrain.RefreshTime) // 经过的时间
t := int32(configure.Now().Unix() - trolltrain.RefreshTime) // 经过的时间
if t < sz[trolltrain.TarinPos-1] {
session.SendMsg(string(this.module.GetType()), TrollGetListResp, &pb.TrollGetListResp{Data: trolltrain})
return
@ -74,7 +74,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
update["shop"] = trolltrain.Shop
circleCount = (int32(t) / circletime) // 经过的周期数
c := int32((time.Now().Unix() - trolltrain.Ctime)) / circletime
c := int32((configure.Now().Unix() - trolltrain.Ctime)) / circletime
if trolltrain.Circle != c {
trolltrain.SurpriseID = make(map[int32]int32, 0)
n, _ := rand.Int(rand.Reader, big.NewInt(int64(trainNum)))
@ -91,7 +91,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.TrollGetListReq)
for _, v := range sz {
if leftTime <= v {
trolltrain.RefreshTime = time.Now().Unix()
trolltrain.RefreshTime = configure.Now().Unix()
trolltrain.TarinPos += index
trolltrain.RangeId += index
trolltrain.RangeId = (trolltrain.RangeId % maxCoefficient) + 1

View File

@ -5,7 +5,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"go.mongodb.org/mongo-driver/bson/primitive"
)
@ -39,7 +39,7 @@ func (this *ModelRecord) AddTrollRecord(uid string, gold, pos int32) (err error)
Uid: uid,
Gold: gold,
Pos: pos,
Time: time.Now().Unix(),
Time: configure.Now().Unix(),
}
if err = this.AddList(uid, troll.Id, troll); err != nil {
this.module.Errorf("%v", err)

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -44,13 +44,13 @@ func (this *modelTroll) getTrollList(uid string) (result *pb.DBTrollTrain, err e
NpcReward: map[int32]int32{},
TotalEarn: 0,
SellCount: 0,
RefreshTime: time.Now().Unix(),
RefreshTime: configure.Now().Unix(),
AiCount: 0,
Shop: map[int32]int32{},
Ctime: time.Now().Unix(),
Ctime: configure.Now().Unix(),
Circle: 0,
SurpriseID: map[int32]int32{},
ResetTime: time.Now().Unix(),
ResetTime: configure.Now().Unix(),
}
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err {
// 创建一条数据

View File

@ -12,8 +12,8 @@ import (
"go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"math"
"time"
"github.com/go-redis/redis/v8"
)
@ -69,7 +69,7 @@ func (this *Troll) TrollAI(session comm.IUserSession, troll *pb.DBTrollTrain) (c
}
update = make(map[string]interface{})
sellPrice = make(map[int32]int32)
now := time.Now().Unix()
now := configure.Now().Unix()
trainNum := this.configure.GetTrollMaxTraintNum()
maxCoefficient := this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值
if maxCoefficient == 0 {

View File

@ -4,8 +4,8 @@ import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -34,7 +34,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
defer func() {
if user != nil && code == pb.ErrorCode_Success {
rsp.Data = user
rsp.TimeNow = time.Now().Unix() // 设置服务器时间
rsp.TimeNow = configure.Now().Unix() // 设置服务器时间
err = session.SendMsg(string(this.module.GetType()), UserSubTypeLogin, rsp)
if err != nil {
code = pb.ErrorCode_SystemError
@ -98,7 +98,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
//不是新账号
if !isNewUser {
lastLoginTime := user.Logintime
user.Logintime = time.Now().Unix()
user.Logintime = configure.Now().Unix()
user.Lastloginip = session.GetIP()
user.Offlinetime = 0
update := utils.StructToMap(user)
@ -153,8 +153,8 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (cod
Uid: user.Uid,
Title: "system mail",
Contex: "Congratulations on getting a login exclusive gift pack",
CreateTime: uint64(time.Now().Unix()),
DueTime: uint64(time.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
CreateTime: uint64(configure.Now().Unix()),
DueTime: uint64(configure.Now().Unix()) + 30*24*3600, // 30天需要走配置文件
Check: false,
Reward: false,
}

View File

@ -3,8 +3,8 @@ package user
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -27,7 +27,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
start, _ := utils.GetMonthStartEnd()
if sign.RTime < start { // 重置
sign.RTime = time.Now().Unix()
sign.RTime = configure.Now().Unix()
sign.SignTime = sign.RTime
sign.SignCount = 1
if newGroup := this.module.configure.GetSignResetConf(sign.Cid + 1); newGroup != -1 { // 获取当前的组id
@ -45,7 +45,7 @@ func (this *apiComp) Sign(session comm.IUserSession, req *pb.UserSignReq) (code
if !utils.IsToday(sign.SignTime) {
sign.SignCount += 1
update["signCount"] = sign.SignCount
sign.SignTime = time.Now().Unix()
sign.SignTime = configure.Now().Unix()
update["signTime"] = sign.SignTime
sign.RTime = sign.SignTime
update["rTime"] = sign.RTime

View File

@ -7,6 +7,7 @@ import (
"go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
@ -71,7 +72,7 @@ func (this *ModelSetting) checkInitCount(uid string) bool {
if ue != nil {
//验证时间
tt := time.Unix(ue.LastInitdataTime, 0)
if !time.Now().After(tt) {
if !configure.Now().After(tt) {
return false
}
//判断上次初始的时间

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
@ -63,7 +63,7 @@ func (this *ModelSign) updateSignData(uid string, sign *pb.DBSign) (err error) {
count := sign.SignCount
update := map[string]interface{}{
"signCount": count,
"signTime": time.Now().UTC(),
"signTime": configure.Now().UTC(),
}
this.ChangeUserSign(uid, update)
}
@ -81,7 +81,7 @@ func (this *ModelSign) checkResetSignData(session comm.IUserSession) (code pb.Er
if sign, err := this.module.modelSign.GetUserSign(session.GetUserId()); err == nil {
start, _ := utils.GetMonthStartEnd()
if sign.RTime < start { // 重置
sign.RTime = time.Now().Unix()
sign.RTime = configure.Now().Unix()
sign.SignTime = sign.RTime
sign.SignCount = 1
if newGroup := this.module.configure.GetSignResetConf(sign.Cid + 1); newGroup != -1 { // 获取当前的组id
@ -99,7 +99,7 @@ func (this *ModelSign) checkResetSignData(session comm.IUserSession) (code pb.Er
if !utils.IsToday(sign.SignTime) {
sign.SignCount += 1
update["signCount"] = sign.SignCount
sign.SignTime = time.Now().Unix()
sign.SignTime = configure.Now().Unix()
update["signTime"] = sign.SignTime
sign.RTime = sign.SignTime
update["rTime"] = sign.RTime

View File

@ -8,6 +8,7 @@ import (
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
@ -58,7 +59,7 @@ func (this *ModelUser) NickNameIsExist(name string) bool {
//创建初始用户
func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
now := time.Now().Unix()
now := configure.Now().Unix()
_id := primitive.NewObjectID().Hex()
user.Id = _id
user.Uid = fmt.Sprintf("%s_%s", user.Sid, _id)
@ -97,7 +98,7 @@ func (this *ModelUser) updateUserAttr(uid string, data map[string]interface{}) e
//是否今天首次登录
func (this *ModelUser) isLoginFirst(timestamp int64) bool {
now := time.Now()
now := configure.Now()
if timestamp == 0 || timestamp > now.Unix() {
this.module.Debugf("lastlogin time great now")
return false
@ -142,7 +143,7 @@ func (this *ModelUser) modifyName(uid string, newName string) (code pb.ErrorCode
}
func (this *ModelUser) updateOfflineTime(uid string) {
if err := this.updateUserAttr(uid, map[string]interface{}{"offlinetime": time.Now().Unix()}); err != nil {
if err := this.updateUserAttr(uid, map[string]interface{}{"offlinetime": configure.Now().Unix()}); err != nil {
this.module.Errorln(err)
}
}

View File

@ -3,9 +3,9 @@ package viking
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -38,7 +38,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
// 校验是不是今天
if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix()
list.CTime = configure.Now().Unix()
list.BuyCount = 0
list.ChallengeCount = 0
@ -55,9 +55,9 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
}
if list.LeftCount != conf.VikingNum {
if list.RecoveryTime == 0 {
list.RecoveryTime = time.Now().Unix()
list.RecoveryTime = configure.Now().Unix()
}
count := (time.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
if count > 1 {
list.LeftCount += int32(count)
}

View File

@ -3,8 +3,8 @@ package viking
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
"time"
"google.golang.org/protobuf/proto"
)
@ -92,7 +92,7 @@ func (this *apiComp) ChallengeOver(session comm.IUserSession, req *pb.VikingChal
conf := this.module.configure.GetGlobalConf()
if conf != nil {
if viking.LeftCount >= conf.VikingNum {
viking.RecoveryTime = time.Now().Unix()
viking.RecoveryTime = configure.Now().Unix()
}
}
viking.LeftCount--

View File

@ -3,8 +3,8 @@ package viking
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto"
)
@ -33,7 +33,7 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
// 校验 是不是当天
if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix()
list.CTime = configure.Now().Unix()
list.BuyCount = 0
list.ChallengeCount = 0
@ -50,9 +50,9 @@ func (this *apiComp) GetList(session comm.IUserSession, req *pb.VikingGetListReq
}
if list.LeftCount != conf.VikingNum {
if list.RecoveryTime == 0 {
list.RecoveryTime = time.Now().Unix()
list.RecoveryTime = configure.Now().Unix()
}
count := (time.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
count := (configure.Now().Unix() - list.RecoveryTime) / int64(conf.VikingExpeditionRecoveryTime*60)
if count > 1 {
list.LeftCount += int32(count)
}

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"time"
"go_dreamfactory/sys/configure"
uuid "github.com/satori/go.uuid"
"go.mongodb.org/mongo-driver/bson/primitive"
@ -26,7 +26,7 @@ func (this *modelUserComp) Init(service core.IService, module core.IModule, comp
}
func (this *modelUserComp) User_Create(user *pb.DBUser) (err error) {
now := time.Now().Unix()
now := configure.Now().Unix()
_id := primitive.NewObjectID().Hex()
user.Id = _id
user.Uid = fmt.Sprintf("%s_%s", user.Sid, _id)

View File

@ -3,7 +3,6 @@ package main
import (
"flag"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/modules/academy"
"go_dreamfactory/modules/arena"
"go_dreamfactory/modules/battle"
@ -37,7 +36,6 @@ import (
"go_dreamfactory/modules/user"
"go_dreamfactory/modules/viking"
"go_dreamfactory/modules/worldtask"
"go_dreamfactory/pb"
"go_dreamfactory/services"
"go_dreamfactory/sys/db"
"time"
@ -47,9 +45,6 @@ import (
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/timewheel"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
)
/*
@ -134,29 +129,4 @@ func (this *Service) InitSys() {
} else {
log.Infof("init sys.db success!")
}
conn, err := db.Local()
if err == nil {
model := db.NewDBModel(comm.TableServerData, 0, conn)
// rest, err1 := model.DB.Find(comm.TableServerData, bson.M{})
// server1 := &pb.DBServerData{}
// for rest.Next(context.TODO()) {
// rest.Decode(server1)
// fmt.Printf("%v", server1)
// break
// }
_len, err1 := model.DB.CountDocuments(comm.TableServerData, bson.M{})
if err1 == nil && _len == 0 {
fmt.Printf("%v,%v", _len, err1)
server := &pb.DBServerData{
Id: primitive.NewObjectID().Hex(),
ServerState: 1,
DisposableLoop: 1,
FixedLoop: 0,
SeasonType: 201,
OpenTime: time.Now().Unix(),
}
model.DB.InsertOne(comm.TableServerData, server)
}
}
}

View File

@ -58,5 +58,8 @@ func GetConfigure(name string) (v interface{}, err error) {
//当前时间
func Now() time.Time {
if defsys == nil {
return time.Now()
}
return defsys.Now()
}

View File

@ -2,9 +2,9 @@ package utils
import (
"fmt"
"go_dreamfactory/sys/configure"
"math/rand"
"strings"
"time"
"github.com/Pallinder/go-randomdata"
)
@ -12,7 +12,7 @@ import (
func GenValidateCode(width int) string {
numeric := [10]byte{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
r := len(numeric)
rand.Seed(time.Now().UnixNano())
rand.Seed(configure.Now().UnixNano())
var sb strings.Builder
for i := 0; i < width; i++ {

View File

@ -2,6 +2,7 @@ package utils
import (
"fmt"
"go_dreamfactory/sys/configure"
"math"
"time"
@ -11,14 +12,14 @@ import (
// 判断时间点处于今天
func IsToday(d int64) bool {
tt := time.Unix(d, 0)
now := time.Now()
now := configure.Now()
return tt.Year() == now.Year() && tt.Month() == now.Month() && tt.Day() == now.Day()
}
//判断是否大于1周
func IsAfterWeek(d int64) bool {
tt := time.Unix(d, 0)
nowt := time.Now()
nowt := configure.Now()
if !tt.Before(nowt) {
return false
}
@ -28,7 +29,7 @@ func IsAfterWeek(d int64) bool {
// 是否今日首次
func IsFirstTody(timestamp int64) bool {
now := time.Now()
now := configure.Now()
if timestamp == 0 || timestamp > now.Unix() {
return false
}
@ -51,7 +52,7 @@ func GetZeroTime(curTime int64) int64 {
func IsYestoday(timestamp int64) bool {
tt := time.Unix(timestamp, 0)
yesTime := time.Now().AddDate(0, 0, -1)
yesTime := configure.Now().AddDate(0, 0, -1)
return tt.Year() == yesTime.Year() && tt.Month() == yesTime.Month() && tt.Day() == yesTime.Day()
}
@ -70,7 +71,7 @@ func MatrixingHour(beginTime string) (t time.Time) {
serverStartTime, _ := myConfig.Parse(beginTime)
n := time.Now()
n := configure.Now()
timeSub := n.Sub(serverStartTime)
hourSub := timeSub.Hours() * 2
@ -84,7 +85,7 @@ func MatrixingHour(beginTime string) (t time.Time) {
}
func AddHour(hour int) time.Time {
return time.Now().Add(time.Duration(hour) * time.Hour)
return configure.Now().Add(time.Duration(hour) * time.Hour)
}
// CD
@ -92,12 +93,12 @@ func IsInCDHour(cdTime int64) bool {
if cdTime == 0 {
return false
}
return time.Now().Unix() < cdTime
return configure.Now().Unix() < cdTime
}
// 获取本月的开始和结束的时间戳
func GetMonthStartEnd() (int64, int64) {
t := time.Now()
t := configure.Now()
monthStartDay := t.AddDate(0, 0, -t.Day()+1)
monthStartTime := time.Date(monthStartDay.Year(), monthStartDay.Month(), monthStartDay.Day(), 0, 0, 0, 0, t.Location())
monthEndDay := monthStartTime.AddDate(0, 1, -1)

View File

@ -2,6 +2,7 @@ package utils_test
import (
"fmt"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"strconv"
"testing"
@ -14,7 +15,7 @@ import (
func TestIsToday(t *testing.T) {
// fmt.Println(utils.IsToday(0))
tt := time.Unix(1658139742, 0)
fmt.Println(time.Now().Before(tt))
fmt.Println(configure.Now().Before(tt))
}
func TestIsYestoday(t *testing.T) {