update: lifetime discount
This commit is contained in:
parent
d0b364460f
commit
06b00f2c8c
|
|
@ -79,7 +79,7 @@ export const routes = new Elysia()
|
||||||
// Lifetime discount: credit up to 50% of lifetime price from previous payments
|
// Lifetime discount: credit up to 50% of lifetime price from previous payments
|
||||||
if (plan === "lifetime" && planDef.priceUsd) {
|
if (plan === "lifetime" && planDef.priceUsd) {
|
||||||
const [{ total }] = await sql`SELECT COALESCE(SUM(amount_usd), 0)::numeric as total FROM payments WHERE account_id = ${accountId} AND status = 'paid'`;
|
const [{ total }] = await sql`SELECT COALESCE(SUM(amount_usd), 0)::numeric as total FROM payments WHERE account_id = ${accountId} AND status = 'paid'`;
|
||||||
const credit = Math.min(Number(total), planDef.priceUsd * 0.5);
|
const credit = Math.min(Number(total), planDef.priceUsd * 0.75);
|
||||||
amountUsd = Math.max(amountUsd - credit, 1);
|
amountUsd = Math.max(amountUsd - credit, 1);
|
||||||
}
|
}
|
||||||
const rates = await getExchangeRates();
|
const rates = await getExchangeRates();
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
const payApi = it.payApi || '';
|
const payApi = it.payApi || '';
|
||||||
const totalSpent = it.totalSpent || 0;
|
const totalSpent = it.totalSpent || 0;
|
||||||
const lifetimeBase = 140;
|
const lifetimeBase = 140;
|
||||||
const lifetimeDiscount = Math.min(totalSpent, lifetimeBase * 0.5);
|
const lifetimeDiscount = Math.min(totalSpent, lifetimeBase * 0.75);
|
||||||
const lifetimePrice = lifetimeBase - lifetimeDiscount;
|
const lifetimePrice = lifetimeBase - lifetimeDiscount;
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -552,7 +552,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-sm text-gray-500 mt-8 max-w-lg mx-auto">Start with Pro and upgrade to Lifetime whenever you're ready. What you've spent on Pro gets credited toward the lifetime price, up to 50% off.</p>
|
<p class="text-sm text-gray-500 mt-8 max-w-lg mx-auto">Start with Pro and upgrade to Lifetime whenever you're ready. What you've spent on Pro gets credited toward the lifetime price, up to 75% off.</p>
|
||||||
|
|
||||||
<div class="mt-6">
|
<div class="mt-6">
|
||||||
<a href="/dashboard" class="inline-flex items-center gap-2 px-8 py-3.5 text-white font-medium rounded-lg transition-all text-sm" style="background:#2563eb;box-shadow:0 1px 3px rgba(0,0,0,0.3),0 0 12px rgba(59,130,246,0.15)">
|
<a href="/dashboard" class="inline-flex items-center gap-2 px-8 py-3.5 text-white font-medium rounded-lg transition-all text-sm" style="background:#2563eb;box-shadow:0 1px 3px rgba(0,0,0,0.3),0 0 12px rgba(59,130,246,0.15)">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue