feat(promo): Enhance promo code functionality and discount consumption logic

- Integrated promo code service into subscription service to streamline discount consumption during payment processing.
- Improved error handling and logging for promo code activation and usage increment.
- Updated payment services to handle discount calculations more robustly, including fallback mechanisms for invalid discount scenarios.
- Added new methods for managing promo code activations and usage in the database layer.
This commit is contained in:
kavore
2026-02-01 19:29:31 +03:00
parent 9b4a58f82f
commit 484327a032
10 changed files with 319 additions and 98 deletions
+3 -2
View File
@@ -190,9 +190,10 @@ async def process_promo_code_input(message: types.Message, state: FSMContext,
# Both failed
await session.rollback()
logging.info(
f"Promo code '{code_input}' application failed for user {user.id}. Reason: {result}"
f"Promo code '{code_input}' application failed for user {user.id}. "
f"Bonus reason: {result}. Discount reason: {result_discount}"
)
response_to_user_text = result # Original error message from bonus code attempt
response_to_user_text = result_discount # Prefer the discount attempt error
reply_markup = get_back_to_main_menu_markup(
current_lang, i18n
)