fix(promo): Исправлена ошибка при применении промокода на скидку
This commit is contained in:
@@ -43,6 +43,20 @@ async def get_active_promo_code_by_code_str(
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
|
||||
async def get_active_bonus_promo_code_by_code_str(
|
||||
session: AsyncSession, code_str: str) -> Optional[PromoCode]:
|
||||
"""Get active bonus_days-type promo code by code string"""
|
||||
stmt = select(PromoCode).where(
|
||||
PromoCode.code == code_str.upper(),
|
||||
PromoCode.promo_type == "bonus_days",
|
||||
PromoCode.is_active == True,
|
||||
PromoCode.current_activations < PromoCode.max_activations,
|
||||
or_(PromoCode.valid_until == None, PromoCode.valid_until
|
||||
> datetime.now(timezone.utc)))
|
||||
result = await session.execute(stmt)
|
||||
return result.scalar_one_or_none()
|
||||
|
||||
|
||||
async def get_active_discount_promo_code_by_code_str(
|
||||
session: AsyncSession, code_str: str) -> Optional[PromoCode]:
|
||||
"""Get active discount-type promo code by code string"""
|
||||
|
||||
Reference in New Issue
Block a user