Add referral system and user balance tracking
Introduce balance field to User model with Alembic migration. Add referral menu, admin /refpay command, and deep link sharing. Update Dockerfile to multi-stage build and add Postgres service to compose. Fix deep link parsing logic and conditional proxy initialization.
This commit is contained in:
@@ -47,3 +47,25 @@ class UserRepository:
|
||||
|
||||
await session.commit()
|
||||
return user
|
||||
|
||||
async def update_user_balance(
|
||||
self, session: AsyncSession, user_id: int, balance: int
|
||||
) -> Optional[User]:
|
||||
user = await self.get_user_by_id(session, user_id=user_id)
|
||||
if not user:
|
||||
return None
|
||||
user.balance = balance
|
||||
|
||||
await session.commit()
|
||||
return user
|
||||
|
||||
async def increase_user_balance(
|
||||
self, session: AsyncSession, user_id: int, amount: int
|
||||
) -> Optional[User]:
|
||||
user = await self.get_user_by_id(session, user_id=user_id)
|
||||
if not user:
|
||||
return None
|
||||
user.balance += amount
|
||||
|
||||
await session.commit()
|
||||
return user
|
||||
|
||||
Reference in New Issue
Block a user