Billing and quota management system for real_deal platform including tiered storage limits, capacity packs, job slot quotas, usage metering, and charge tracking. Use when implementing billing features, managing quotas, tracking usage, creating capacity packs, or handling payment transactions.
UsageMeter - Track storage, bandwidth, transcoding timeQuota - Current limits for user/companyCapacityPack - Purchased capacity bundlesJobSlot - Active job slot allocationChargeRecord - Payment historyUsageSnapshot - Periodic usage snapshots// Track upload size
func RecordUpload(userID string, size int64) error {
usageMeter.UpdateStorage(userID, size)
quota.CheckExceeded(userID)
}
// Allocate job slot
func AllocateJobSlot(companyID string) error {
if !quota.Available(companyID) {
return ErrQuotaExceeded
}
return jobSlot.Allocate(companyID)
}
// Process pack purchase
func PurchaseCapacityPack(userID string, packType string) error {
pack := GetPack(packType)
quota.Increase(userID, pack.Storage, pack.Bandwidth)
charge := ChargeRecord{
UserID: userID,
Amount: pack.Price,
Type: "capacity_pack",
}
return charges.Save(charge)
}
Quota modelUsageMeterCapacityPack collectionChargeRecord