服务器信息新增变更时间字段,到变更时间自动改变服务器状态为爆满,是否新服为旧服

master
czx 2023-09-28 15:36:42 +08:00
parent b1f2798eed
commit 4bb652ee13
4 changed files with 51 additions and 20 deletions

View File

@ -739,6 +739,7 @@ func (action *Action) ServerInfo(r *ghttp.Request) {
dayMap.Set("subChannel", serverInfo.SubChannel)
dayMap.Set("state", serverInfo.State)
dayMap.Set("plat", serverInfo.Plat)
dayMap.Set("changeTime", serverInfo.ChangeTime)
dayMap.Set("openTime", serverInfo.OpenTime)
dayMap.Set("openType", serverInfo.OpenType)
dayMap.Set("isNew", serverInfo.IsNew)
@ -773,6 +774,7 @@ func (action *Action) SaveServer(r *ghttp.Request) {
state := r.Form.Get("state")
plat := r.Form.Get("plat")
openTime := r.Form.Get("openTime")
changeTimeStr := r.Form.Get("changeTime")
openType := r.Form.Get("openType")
isNew := r.Form.Get("isNew")
isBanreg := r.Form.Get("isBanreg")
@ -793,6 +795,9 @@ func (action *Action) SaveServer(r *ghttp.Request) {
serverInfo.SubChannel = subChannel
serverInfo.State = state
serverInfo.Plat = plat
if changeTimeStr != "" {
serverInfo.ChangeTime = gconv.Int64(changeTimeStr)
}
serverInfo.OpenTime = openTime
serverInfo.OpenType = openType
serverInfo.IsNew = isNew
@ -858,6 +863,7 @@ func (action *Action) GetServerDetail(r *ghttp.Request) {
dayMap.Set("subChannel", serverInfo.SubChannel)
dayMap.Set("state", serverInfo.State)
dayMap.Set("plat", serverInfo.Plat)
dayMap.Set("changeTime", serverInfo.ChangeTime)
dayMap.Set("openTime", serverInfo.OpenTime)
dayMap.Set("openType", serverInfo.OpenType)
dayMap.Set("isNew", serverInfo.IsNew)

View File

@ -529,6 +529,7 @@ func (m *Mgo) UpdateServer(id int, value interface{}) *mongo.UpdateResult {
{"port", gconv.String(serverInfo["Port"])},
{"plat", gconv.String(serverInfo["Plat"])},
{"state", gconv.String(serverInfo["State"])},
{"change_time", serverInfo["ChangeTime"]},
{"open_time", gconv.String(serverInfo["OpenTime"])},
{"open_type", gconv.String(serverInfo["OpenType"])},
{"is_banreg", gconv.String(serverInfo["IsBanreg"])},

View File

@ -6,31 +6,32 @@ import (
)
type ServerInfo struct {
Id int `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Ip string `bson:"ip" json:"ip"`
Port string `bson:"port" json:"port"`
ServerId string `bson:"server_id" json:"serverid"`
Channel string `bson:"channel" json:"channel"`
SubChannel string `bson:"sub_channel" json:"subchannel"`
State string `bson:"state" json:"state"`
Plat string `bson:"plat" json:"plat"`
OpenTime string `bson:"open_time" json:"opentime"`
OpenType string `bson:"open_type" json:"opentype"`
IsNew string `bson:"is_new" json:"isnew"`
IsBanreg string `bson:"is_banreg" json:"isbanreg"`
IsWhite string `bson:"isWhite" json:"iswhite"`
Id int `bson:"_id" json:"id"`
Name string `bson:"name" json:"name"`
Ip string `bson:"ip" json:"ip"`
Port string `bson:"port" json:"port"`
ServerId string `bson:"server_id" json:"serverid"`
Channel string `bson:"channel" json:"channel"`
SubChannel string `bson:"sub_channel" json:"subchannel"`
State string `bson:"state" json:"state"`
Plat string `bson:"plat" json:"plat"`
ChangeTime int64 `bson:"change_time" json:"changeTime"`
OpenTime string `bson:"open_time" json:"opentime"`
OpenType string `bson:"open_type" json:"opentype"`
IsNew string `bson:"is_new" json:"isnew"`
IsBanreg string `bson:"is_banreg" json:"isbanreg"`
IsWhite string `bson:"isWhite" json:"iswhite"`
ServerVersion string `bson:"server_version" json:"serverversion"`
GMIp string `bson:"gm_ip" json:"gmip"`
GMPort string `bson:"gm_port" json:"gmport"`
Timezone string `bson:"time_zone" json:"timezone"` // 时区
Currency string `bson:"currency" json:"currency"` // 币种
Exportdata string `bson:"exportdata" json:"exportdata"` // 是否导出数据
GMIp string `bson:"gm_ip" json:"gmip"`
GMPort string `bson:"gm_port" json:"gmport"`
Timezone string `bson:"time_zone" json:"timezone"` // 时区
Currency string `bson:"currency" json:"currency"` // 币种
Exportdata string `bson:"exportdata" json:"exportdata"` // 是否导出数据
}
var (
// Table is the table name of account.
TableServer = "server_info"
TableServer = "server_info"
ServerTablbeName = g.Config().GetString("db.core")
// Model is the model object of account.
ModelServer = dao.NewMgo(ServerTablbeName, TableServer)

View File

@ -52,6 +52,8 @@ func init() {
gcron.AddSingleton("0 0,30 * * * ?", StatisticalRecharge)
gcron.AddSingleton("0 0,30 * * * ?", StatisticalRecharge_Server)
gcron.AddSingleton("0 * * * * ?", changeServerState)
// 判断是否需要导出表格
if "1" == g.Config().GetString("game.export") {
// 按天执行 0 10 0 * * *
@ -971,3 +973,24 @@ func initServerPayInfo() {
}
}
func changeServerState() {
now := time.Now().Unix() * 1000
bs := bson.D{
{"is_new", "1"},
{"change_time", bson.D{{"$lte", now}}},
}
serverInfoList := gameinfo.ModelServer.FindAllBson(bs)
for serverInfoList.Next(context.TODO()) {
var serverInfo gameinfo.ServerInfo
err := serverInfoList.Decode(&serverInfo)
if err != nil {
//log.Fatal(err)
log.Println(err)
continue
}
serverInfo.IsNew = "0"
serverInfo.State = "4"
gameinfo.ModelServer.UpdateServer(serverInfo.Id, serverInfo)
}
}