fix(promo): Исправлена ошибка с зацыкленностью импортов для оплат звёздами и криптой

This commit is contained in:
VAQYBIN
2026-01-21 01:13:26 +05:00
parent 229ce7e1e0
commit 9ca2fe487c
2 changed files with 11 additions and 5 deletions
+8 -4
View File
@@ -18,7 +18,6 @@ from bot.services.notification_service import NotificationService
from db.dal import payment_dal, user_dal
from bot.utils.text_sanitizer import sanitize_display_name, username_for_display
from bot.utils.config_link import prepare_config_links
from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment
class CryptoPayService:
@@ -73,9 +72,14 @@ class CryptoPayService:
return None
# Apply active discount if exists
final_amount, discount_amount, promo_code_id = await apply_discount_to_payment(
session, user_id, amount, promo_code_service
)
if promo_code_service:
# Import here to avoid circular import
from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment
final_amount, discount_amount, promo_code_id = await apply_discount_to_payment(
session, user_id, amount, promo_code_service
)
else:
final_amount, discount_amount, promo_code_id = amount, None, None
# Create pending payment in DB and commit to persist
try:
+3 -1
View File
@@ -15,7 +15,6 @@ from .notification_service import NotificationService
from bot.keyboards.inline.user_keyboards import get_connect_and_main_keyboard
from bot.utils.text_sanitizer import sanitize_display_name, username_for_display
from bot.utils.config_link import prepare_config_links
from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment
class StarsService:
@@ -37,6 +36,9 @@ class StarsService:
promo_code_id = None
if promo_code_service:
# Import here to avoid circular import
from bot.handlers.user.subscription.payment_discount_helper import apply_discount_to_payment
# Apply discount and round up using ceiling
final_price_float, discount_float, promo_code_id = await apply_discount_to_payment(
session, user_id, float(stars_price), promo_code_service