feat(lifecycle): add billing lifecycle with auto-suspend/delete

- New AppLifecycleService with cron-based scanner (60s interval)
- State machine: ACTIVE → SUSPENDED → PENDING_DELETION → DELETED
- Auto-renew hourly plans from wallet
- Admin-configurable grace periods via PlatformSettings table
- New LifecycleController (GET/PATCH /lifecycle/settings)
- PlatformSetting entity for runtime admin config
- BillingService: calculateCostForApp, deductWallet
- Application entity: planId, billingCycle, lifecycleStatus, planExpiresAt
- New enums: AppLifecycleStatus, BillingCycle
This commit is contained in:
keyhan
2026-04-22 16:44:20 +03:30
parent 0e408d1baa
commit 8ca787d46e
11 changed files with 562 additions and 11 deletions
+9
View File
@@ -80,3 +80,12 @@ export enum TransactionType {
DEDUCTION = 'deduction', // Payment for service
REFUND = 'refund', // Refund
}
// ── Application Lifecycle ─────────────────────────────
export enum AppLifecycleStatus {
ACTIVE = 'active', // Paid & running
SUSPENDED = 'suspended', // Plan expired, pods scaled to 0, data retained
PENDING_DELETION = 'pending_deletion', // Grace period — will be deleted if no payment
DELETED = 'deleted', // Fully removed from K8s and DB
}