调整服务器时间戳接口

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

View File

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

View File

@ -3,6 +3,7 @@ package arena
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"time" "time"
@ -60,7 +61,7 @@ func (this *apiComp) Plot(session comm.IUserSession, req *pb.ArenaPlotReq) (code
if info.Ticket > 0 { if info.Ticket > 0 {
info.Ticket-- info.Ticket--
if info.Lastrtickettime == 0 { if info.Lastrtickettime == 0 {
info.Lastrtickettime = time.Now().Unix() info.Lastrtickettime = configure.Now().Unix()
} }
} else { } else {
code = pb.ErrorCode_ArenaTicketNotEnough 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 { if info.Npc[req.Pid] != nil {
ndata := info.Npc[req.Pid] 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 code = pb.ErrorCode_ArenaTicketNpcInCd
return return
} }

View File

@ -3,6 +3,7 @@ package arena
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"time" "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) { if len(npc.MonsterformatId) > int(info.Npc[req.Pid].Index+1) {
info.Npc[req.Pid].Index++ 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{}{ if err = this.module.modelArena.Change(info.Uid, map[string]interface{}{
"npc": info.Npc, "npc": info.Npc,
}); err != nil { }); err != nil {

View File

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

View File

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

View File

@ -3,9 +3,9 @@ package equipment
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"math/rand" "math/rand"
"time"
"google.golang.org/protobuf/proto" "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)) 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)) { for i, v := range r.Perm(len(equip.AdverbEntry)) {
adverbEntry[i] = &pb.EquipmentAttributeEntry{ adverbEntry[i] = &pb.EquipmentAttributeEntry{
Id: attrlibrarys[v].Key, Id: attrlibrarys[v].Key,

View File

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

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "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{ friend.Record = append(friend.Record, &pb.AssistRecord{
Uid: uid, Uid: uid,
AssistHeroId: friend.AssistHeroId, AssistHeroId: friend.AssistHeroId,
AssistTime: time.Now().Unix(), AssistTime: configure.Now().Unix(),
}) })
update := map[string]interface{}{ update := map[string]interface{}{
"assistScore": friend.AssistScore, "assistScore": friend.AssistScore,
"record": friend.Record, "record": friend.Record,
"updateTime": time.Now().Unix(), "updateTime": configure.Now().Unix(),
} }
return friend.Hero, this.modelFriend.Change(friendId, update) return friend.Hero, this.modelFriend.Change(friendId, update)
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/sys/redis" "go_dreamfactory/lego/sys/redis"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "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 { if len(value) == 0 {
return nil return nil
} }
value["mtime"] = time.Now().Unix() //修改时间 value["mtime"] = configure.Now().Unix() //修改时间
return this.Change(uid, value) return this.Change(uid, value)
} }

View File

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

View File

@ -3,9 +3,9 @@ package hunting
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto" "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) { if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix() list.CTime = configure.Now().Unix()
list.BuyCount = 0 list.BuyCount = 0
list.ChallengeCount = 0 list.ChallengeCount = 0

View File

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

View File

@ -3,7 +3,7 @@ package items
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto" "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)) modifys = make([]*pb.DB_UserItemData, 0, len(items))
dels = make([]*pb.DB_UserItemData, 0, len(items)) dels = make([]*pb.DB_UserItemData, 0, len(items))
grids = 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 { for _, v := range items {
if v.ETime > 0 && v.ETime < nt { //已经过期 if v.ETime > 0 && v.ETime < nt { //已经过期
dels = append(dels, v) dels = append(dels, v)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ import (
"go_dreamfactory/lego/sys/timewheel" "go_dreamfactory/lego/sys/timewheel"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"time" "time"
@ -70,11 +71,11 @@ func (this *modelDreamComp) addDreamData(user *pb.UserInfo, boss *cfg.GameDreaml
Id: primitive.NewObjectID().Hex(), Id: primitive.NewObjectID().Hex(),
Uid: user.Uid, Uid: user.Uid,
Monster: boss.Bossid, Monster: boss.Bossid,
Ctime: time.Now().Unix(), Ctime: configure.Now().Unix(),
Join: []*pb.UserInfo{user}, Join: []*pb.UserInfo{user},
Numup: boss.Challengenum, Numup: boss.Challengenum,
Unitmup: boss.Fightnum, 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), Record: make(map[string]int32),
} }
if err = this.AddList("", result.Id, result); err != nil { if err = this.AddList("", result.Id, result); err != nil {
@ -100,9 +101,9 @@ func (this *modelDreamComp) trigger(session comm.IUserSession) {
return 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.TriggerNum = 0
umfantasy.LastTrigger = time.Now().Unix() umfantasy.LastTrigger = configure.Now().Unix()
umfantasy.BuyNum = 0 umfantasy.BuyNum = 0
if umfantasy.BattleNum < globalconf.DreamlandFightnum { if umfantasy.BattleNum < globalconf.DreamlandFightnum {
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 { 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) this.DelListlds("", mf.Id)
return true return true
} }

View File

@ -3,7 +3,7 @@ package notify
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "go_dreamfactory/sys/configure"
"google.golang.org/protobuf/proto" "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{}{ 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}) session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify})
return return

View File

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

View File

@ -11,9 +11,9 @@ import (
"go_dreamfactory/lego/sys/redis/pipe" "go_dreamfactory/lego/sys/redis/pipe"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"sort" "sort"
"time"
"github.com/go-redis/redis/v8" "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) key := fmt.Sprintf("%s-%d-rank", floorRankKey, floor)
lockkey := fmt.Sprintf("%s-%d-lock", 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) defer dbModel.Redis.UnLock(lockkey)
if dbModel.Redis.RPush(key, curData); err != nil { if dbModel.Redis.RPush(key, curData); err != nil {
this.modulePagoda.Errorf("err:%v", err) this.modulePagoda.Errorf("err:%v", err)

View File

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

View File

@ -6,8 +6,8 @@ import (
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"time"
"go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/x/bsonx" "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{ info.Items[conf.Id] = &pb.PayDailyItem{
Id: conf.Id, Id: conf.Id,
Buyunm: conf.BuyNum, Buyunm: conf.BuyNum,
Lastrefresh: time.Now().Unix(), Lastrefresh: configure.Now().Unix(),
} }
} }
info.Items[conf.Id].Buyunm-- info.Items[conf.Id].Buyunm--

View File

@ -8,8 +8,8 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" 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, Orderid: args.Orderid,
Uid: args.Uid, Uid: args.Uid,
Productid: args.Productid, Productid: args.Productid,
Ctime: time.Now().Unix(), Ctime: configure.Now().Unix(),
}); err != nil { }); err != nil {
reply.Code = pb.ErrorCode_DBError reply.Code = pb.ErrorCode_DBError
return return

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,8 +5,8 @@ import (
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"strings" "strings"
"time"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"google.golang.org/protobuf/proto" "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{ sociaty.Members = append(sociaty.Members, &pb.SociatyMember{
Uid: user.Uid, Uid: user.Uid,
Job: pb.SociatyJob_PRESIDENT, //创建人是会长 Job: pb.SociatyJob_PRESIDENT, //创建人是会长
Ctime: time.Now().Unix(), Ctime: configure.Now().Unix(),
}) })
if err := this.module.modelSociaty.create(sociaty); err != nil { if err := this.module.modelSociaty.create(sociaty); err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,6 @@ import (
"go_dreamfactory/sys/configure" "go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"time"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/core/cbase" "go_dreamfactory/lego/core/cbase"
@ -104,7 +103,7 @@ func (this *SeasonPagoda) GetSeasonLoop(id int32) *cfg.GameSeasonLoopData {
// // 赛季塔结束 // // 赛季塔结束
func (this *SeasonPagoda) TimerSeasonOver() { 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 { if conn, err := db.Cross(); err == nil {
var ( var (
@ -122,7 +121,7 @@ func (this *SeasonPagoda) TimerSeasonOver() {
//sz := this.GetSeasonReward() //sz := this.GetSeasonReward()
// this.mail.SendNewMail(&pb.DBMailData{ // this.mail.SendNewMail(&pb.DBMailData{
// CreateTime: uint64(time.Now().Unix()), // CreateTime: uint64(configure.Now().Unix()),
// Items: nil, // Items: nil,
// }, _data3...) // }, _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.DB.DeleteMany(comm.TableSeasonPagoda, bson.M{}, options.Delete())
//this.module.Debugf("=====%d,", time.Since(star).Milliseconds()) //this.module.Debugf("=====%d,", time.Since(star).Milliseconds())
} }
// 赛季塔开始 // 赛季塔开始
func (this *SeasonPagoda) TimerSeasonStar() { 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 ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"math" "math"
"time"
"google.golang.org/protobuf/proto" "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] = 0
} }
trolltrain.Price[k] = goods.Goodsprice * goods.StarMoney / 1000 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] gold -= trolltrain.Price[k] * trolltrain.Items[k]
} else { } else {

View File

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

View File

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

View File

@ -6,7 +6,7 @@ import (
"go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/mgo"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"time" "go_dreamfactory/sys/configure"
"go.mongodb.org/mongo-driver/bson/primitive" "go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo" "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{}, NpcReward: map[int32]int32{},
TotalEarn: 0, TotalEarn: 0,
SellCount: 0, SellCount: 0,
RefreshTime: time.Now().Unix(), RefreshTime: configure.Now().Unix(),
AiCount: 0, AiCount: 0,
Shop: map[int32]int32{}, Shop: map[int32]int32{},
Ctime: time.Now().Unix(), Ctime: configure.Now().Unix(),
Circle: 0, Circle: 0,
SurpriseID: map[int32]int32{}, SurpriseID: map[int32]int32{},
ResetTime: time.Now().Unix(), ResetTime: configure.Now().Unix(),
} }
if err = this.Get(uid, result); err != nil && mgo.MongodbNil == err { 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/lego/sys/redis/pipe"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"math" "math"
"time"
"github.com/go-redis/redis/v8" "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{}) update = make(map[string]interface{})
sellPrice = make(map[int32]int32) sellPrice = make(map[int32]int32)
now := time.Now().Unix() now := configure.Now().Unix()
trainNum := this.configure.GetTrollMaxTraintNum() trainNum := this.configure.GetTrollMaxTraintNum()
maxCoefficient := this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值 maxCoefficient := this.configure.GetTrollMaxCoefficientNux() // 增长幅度的最大值
if maxCoefficient == 0 { if maxCoefficient == 0 {

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ import (
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time" "time"
@ -58,7 +59,7 @@ func (this *ModelUser) NickNameIsExist(name string) bool {
//创建初始用户 //创建初始用户
func (this *ModelUser) User_Create(user *pb.DBUser) (err error) { func (this *ModelUser) User_Create(user *pb.DBUser) (err error) {
now := time.Now().Unix() now := configure.Now().Unix()
_id := primitive.NewObjectID().Hex() _id := primitive.NewObjectID().Hex()
user.Id = _id user.Id = _id
user.Uid = fmt.Sprintf("%s_%s", user.Sid, _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 { func (this *ModelUser) isLoginFirst(timestamp int64) bool {
now := time.Now() now := configure.Now()
if timestamp == 0 || timestamp > now.Unix() { if timestamp == 0 || timestamp > now.Unix() {
this.module.Debugf("lastlogin time great now") this.module.Debugf("lastlogin time great now")
return false return false
@ -142,7 +143,7 @@ func (this *ModelUser) modifyName(uid string, newName string) (code pb.ErrorCode
} }
func (this *ModelUser) updateOfflineTime(uid string) { 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) this.module.Errorln(err)
} }
} }

View File

@ -3,9 +3,9 @@ package viking
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs" cfg "go_dreamfactory/sys/configure/structs"
"go_dreamfactory/utils" "go_dreamfactory/utils"
"time"
"google.golang.org/protobuf/proto" "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) { if !utils.IsToday(list.CTime) {
list.CTime = time.Now().Unix() list.CTime = configure.Now().Unix()
list.BuyCount = 0 list.BuyCount = 0
list.ChallengeCount = 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.LeftCount != conf.VikingNum {
if list.RecoveryTime == 0 { 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 { if count > 1 {
list.LeftCount += int32(count) list.LeftCount += int32(count)
} }

View File

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

View File

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

View File

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

View File

@ -3,7 +3,6 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"go_dreamfactory/comm"
"go_dreamfactory/modules/academy" "go_dreamfactory/modules/academy"
"go_dreamfactory/modules/arena" "go_dreamfactory/modules/arena"
"go_dreamfactory/modules/battle" "go_dreamfactory/modules/battle"
@ -37,7 +36,6 @@ import (
"go_dreamfactory/modules/user" "go_dreamfactory/modules/user"
"go_dreamfactory/modules/viking" "go_dreamfactory/modules/viking"
"go_dreamfactory/modules/worldtask" "go_dreamfactory/modules/worldtask"
"go_dreamfactory/pb"
"go_dreamfactory/services" "go_dreamfactory/services"
"go_dreamfactory/sys/db" "go_dreamfactory/sys/db"
"time" "time"
@ -47,9 +45,6 @@ import (
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/log"
"go_dreamfactory/lego/sys/timewheel" "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 { } else {
log.Infof("init sys.db success!") 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 { func Now() time.Time {
if defsys == nil {
return time.Now()
}
return defsys.Now() return defsys.Now()
} }

View File

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

View File

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

View File

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