feat: hwid limits and topups

This commit is contained in:
3252a8
2026-05-03 22:36:33 +03:00
parent 00f8e5fb20
commit aa5a9496ed
21 changed files with 738 additions and 15 deletions
+19 -1
View File
@@ -3,7 +3,7 @@ from typing import Any, Dict, List, Optional
from sqlalchemy import and_, delete, select
from sqlalchemy.ext.asyncio import AsyncSession
from db.models import TariffChange, TrafficTopup, TrafficWarning
from db.models import HwidDevicePurchase, TariffChange, TrafficTopup, TrafficWarning
async def create_traffic_topup(
@@ -26,6 +26,24 @@ async def create_traffic_topup(
return record
async def create_hwid_device_purchase(
session: AsyncSession,
*,
subscription_id: int,
payment_id: Optional[int],
purchased_devices: int,
) -> HwidDevicePurchase:
record = HwidDevicePurchase(
subscription_id=subscription_id,
payment_id=payment_id,
purchased_devices=purchased_devices,
)
session.add(record)
await session.flush()
await session.refresh(record)
return record
async def create_tariff_change(
session: AsyncSession,
change_data: Dict[str, Any],