This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"blazing/modules/config/model"
|
||||
"fmt"
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@@ -130,6 +131,35 @@ func (s *ServerService) GetServerID(OnlineID uint32) model.ServerList {
|
||||
|
||||
}
|
||||
|
||||
func (s *ServerService) GetDonationAvailableServerIDs() []uint32 {
|
||||
now := time.Now()
|
||||
builder := dbm_nocache_noenable(s.Model).Builder().Where("owner", 0).WhereOr("expire_time <= ?", now)
|
||||
|
||||
var rows []struct {
|
||||
OnlineID uint32 `json:"online_id"`
|
||||
}
|
||||
dbm_nocache_noenable(s.Model).Fields("online_id").Where(builder).OrderAsc("online_id").Scan(&rows)
|
||||
|
||||
ids := make([]uint32, 0, len(rows))
|
||||
for _, row := range rows {
|
||||
if row.OnlineID == 0 {
|
||||
continue
|
||||
}
|
||||
ids = append(ids, row.OnlineID)
|
||||
}
|
||||
return ids
|
||||
}
|
||||
|
||||
func (s *ServerService) CanUseDonationName(server model.ServerList, now time.Time) bool {
|
||||
if server.OnlineID == 0 {
|
||||
return false
|
||||
}
|
||||
if server.Owner == 0 {
|
||||
return true
|
||||
}
|
||||
return !server.ExpireTime.After(now)
|
||||
}
|
||||
|
||||
// 保存版本号
|
||||
func (s *ServerService) SetServerScreen(id uint32, name string) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user