добавлен биллинг и тарифы

добавлена интеграция с юкасса
This commit is contained in:
2025-12-24 09:06:19 +03:00
parent b4ce819931
commit 5f35d7a75f
15 changed files with 745 additions and 212 deletions

View File

@@ -65,7 +65,11 @@ type RMSServer struct {
RootGroupGUID *uuid.UUID `gorm:"type:uuid" json:"root_group_guid"`
AutoProcess bool `gorm:"default:false" json:"auto_process"`
// Billing / Stats
// Billing
Balance int `gorm:"default:0" json:"balance"`
PaidUntil *time.Time `json:"paid_until"`
// Stats
InvoiceCount int `gorm:"default:0" json:"invoice_count"`
CreatedAt time.Time `json:"created_at"`
@@ -77,10 +81,12 @@ type Repository interface {
// Users
GetOrCreateUser(telegramID int64, username, first, last string) (*User, error)
GetUserByTelegramID(telegramID int64) (*User, error)
GetUserByID(id uuid.UUID) (*User, error)
// ConnectServer - Основной метод подключения.
// Реализует логику: Новый URL -> Owner, Старый URL -> Operator.
ConnectServer(userID uuid.UUID, url, login, encryptedPass, name string) (*RMSServer, error)
GetServerByURL(url string) (*RMSServer, error)
GetServerByID(id uuid.UUID) (*RMSServer, error)
SaveServerSettings(server *RMSServer) error
@@ -106,7 +112,10 @@ type Repository interface {
AddUserToServer(serverID, userID uuid.UUID, role Role) error
RemoveUserFromServer(serverID, userID uuid.UUID) error
// Billing & Stats
IncrementInvoiceCount(serverID uuid.UUID) error
UpdateBalance(serverID uuid.UUID, amountChange int, newPaidUntil *time.Time) error
DecrementBalance(serverID uuid.UUID) error
// Super Admin Functions
GetAllServersSystemWide() ([]RMSServer, error)