32 lines
1.0 KiB
Go
32 lines
1.0 KiB
Go
package ports
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// SubscriptionCacheData represents cached subscription data
|
|
type SubscriptionCacheData struct {
|
|
Status string
|
|
ExpiresAt time.Time
|
|
DailyUsage float64
|
|
WeeklyUsage float64
|
|
MonthlyUsage float64
|
|
Version int64
|
|
}
|
|
|
|
// BillingCache defines cache operations for billing service
|
|
type BillingCache interface {
|
|
// Balance operations
|
|
GetUserBalance(ctx context.Context, userID int64) (float64, error)
|
|
SetUserBalance(ctx context.Context, userID int64, balance float64) error
|
|
DeductUserBalance(ctx context.Context, userID int64, amount float64) error
|
|
InvalidateUserBalance(ctx context.Context, userID int64) error
|
|
|
|
// Subscription operations
|
|
GetSubscriptionCache(ctx context.Context, userID, groupID int64) (*SubscriptionCacheData, error)
|
|
SetSubscriptionCache(ctx context.Context, userID, groupID int64, data *SubscriptionCacheData) error
|
|
UpdateSubscriptionUsage(ctx context.Context, userID, groupID int64, cost float64) error
|
|
InvalidateSubscriptionCache(ctx context.Context, userID, groupID int64) error
|
|
}
|