mirror of
https://github.com/BEDOLAGA-DEV/remnawave-bedolaga-telegram-bot.git
synced 2026-03-04 04:43:21 +00:00
Add balance details to promocode notifications
This commit is contained in:
@@ -59,6 +59,8 @@ async def activate_promocode_for_registration(
|
||||
user,
|
||||
result.get("promocode", {"code": code}),
|
||||
result["description"],
|
||||
result.get("balance_before_kopeks"),
|
||||
result.get("balance_after_kopeks"),
|
||||
)
|
||||
except Exception as notify_error:
|
||||
logger.error(
|
||||
|
||||
@@ -744,6 +744,8 @@ class AdminNotificationService:
|
||||
user: User,
|
||||
promocode_data: Dict[str, Any],
|
||||
effect_description: str,
|
||||
balance_before_kopeks: int | None = None,
|
||||
balance_after_kopeks: int | None = None,
|
||||
) -> bool:
|
||||
try:
|
||||
await self._record_subscription_event(
|
||||
@@ -766,6 +768,8 @@ class AdminNotificationService:
|
||||
if isinstance(promocode_data.get("valid_until"), datetime)
|
||||
else promocode_data.get("valid_until")
|
||||
),
|
||||
"balance_before_kopeks": balance_before_kopeks,
|
||||
"balance_after_kopeks": balance_after_kopeks,
|
||||
},
|
||||
)
|
||||
except Exception:
|
||||
@@ -820,6 +824,13 @@ class AdminNotificationService:
|
||||
|
||||
message_lines.extend(
|
||||
[
|
||||
"",
|
||||
"💼 <b>Баланс:</b>",
|
||||
(
|
||||
f"{settings.format_price(balance_before_kopeks)} → {settings.format_price(balance_after_kopeks)}"
|
||||
if balance_before_kopeks is not None and balance_after_kopeks is not None
|
||||
else "ℹ️ Баланс не изменился"
|
||||
),
|
||||
"",
|
||||
"📝 <b>Эффект:</b>",
|
||||
effect_description.strip() or "✅ Промокод активирован",
|
||||
|
||||
@@ -52,7 +52,10 @@ class PromoCodeService:
|
||||
if existing_use:
|
||||
return {"success": False, "error": "already_used_by_user"}
|
||||
|
||||
balance_before_kopeks = user.balance_kopeks
|
||||
|
||||
result_description = await self._apply_promocode_effects(db, user, promocode)
|
||||
balance_after_kopeks = user.balance_kopeks
|
||||
|
||||
if promocode.type == PromoCodeType.SUBSCRIPTION_DAYS.value and promocode.subscription_days > 0:
|
||||
from app.utils.user_utils import mark_user_as_had_paid_subscription
|
||||
@@ -123,6 +126,8 @@ class PromoCodeService:
|
||||
"success": True,
|
||||
"description": result_description,
|
||||
"promocode": promocode_data,
|
||||
"balance_before_kopeks": balance_before_kopeks,
|
||||
"balance_after_kopeks": balance_after_kopeks,
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user