feat: implement subscription management and billing enhancements
This commit is contained in:
@@ -72,3 +72,18 @@ class SubscriptionRepository:
|
||||
result = await session.execute(stmt)
|
||||
await session.commit()
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
async def update_subscription_autorenew(
|
||||
self, session: AsyncSession, user_id: int, autorenew: bool
|
||||
) -> Subscription | None:
|
||||
stmt = (
|
||||
update(Subscription)
|
||||
.where(Subscription.user_id == user_id)
|
||||
.values(
|
||||
autorenew=autorenew,
|
||||
)
|
||||
.returning(Subscription)
|
||||
)
|
||||
result = await session.execute(stmt)
|
||||
await session.commit()
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
@@ -105,7 +105,7 @@ class UserRepository:
|
||||
if not user or user.balance < amount:
|
||||
return None
|
||||
|
||||
created_at = datetime.datetime.now(datetime.timezone.UTC)
|
||||
created_at = datetime.datetime.now(datetime.UTC)
|
||||
transaction = BalanceTransaction(
|
||||
user_id=user_id,
|
||||
amount=amount,
|
||||
|
||||
Reference in New Issue
Block a user