feat: 新增服务器冠名CDK兑换功能
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed

This commit is contained in:
xinian
2026-04-08 15:49:03 +08:00
committed by cnb
parent 9825944efc
commit 1ca0ff344e
6 changed files with 194 additions and 72 deletions

View File

@@ -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) {