feat(custom): recharge bonus pay-1-get-2, topup page & docs & about promo display, Chinese-first i18n

- payment_setting.amount_bonus: uniform top-up bonus (1 = pay ¥1 credit ¥2),
  applied to credited quota in model/topupQuotaFromAmount and
  controller/getTopUpQuota (epay/waffo/pancake/manual paths), exposed via
  /api/user/topup/info; regression test TestTopUpQuotaAppliesAmountBonus
- wallet recharge card: bonus banner, credited amount per preset,
  custom-amount credited line, credited row in payment confirm dialog;
  hardcoded Chinese copy (支付/到账/最低充值)
- list locale defaults: Chinese-first, browser locale no longer auto-selects
  English; new localStorage key resets stale language caches
- /docs top-up section: bonus notice box
- README: record the recharge-bonus update in 'About This Custom Fork'
This commit is contained in:
CaIon committed 2026-09-24 15:47:06 +08:00
1 parent 14a9acd368
commit cf06cd72be
19 files changed
+172 -22

No files matched your search

+5
View File
@@ -216,6 +216,11 @@ export function Docs() {
,页面会自动跳回本站
</li>
</ol>
<div className='rounded-lg border border-green-200 bg-green-50 p-3 text-sm text-green-700 dark:border-green-500/40 dark:bg-green-950 dark:text-green-300'>
🎉 <b>充值优惠</b>:充值 <b>¥1 实际到账 ¥2</b>
,以此类推——充多少送多少(100% 赠送)。例如支付 ¥10 到账 ¥20
,支付 ¥100 到账 ¥200,到账额度可用于全部模型与套餐。
</div>
<h3>方式二:包月套餐(推荐)</h3>
<p>
前往{' '}
@@ -47,6 +47,7 @@ interface PaymentConfirmDialogProps {
processing: boolean
discountRate?: number
usdExchangeRate?: number
amountBonus?: number
}
export function PaymentConfirmDialog({
@@ -60,11 +61,13 @@ export function PaymentConfirmDialog({
processing,
discountRate = DEFAULT_DISCOUNT_RATE,
usdExchangeRate = 1,
amountBonus = 0,
}: PaymentConfirmDialogProps) {
const { t } = useTranslation()
const hasDiscount = discountRate > 0 && discountRate < 1 && paymentAmount > 0
const originalAmount = hasDiscount ? paymentAmount / discountRate : 0
const discountAmount = hasDiscount ? originalAmount - paymentAmount : 0
const creditedAmount = topupAmount * usdExchangeRate * (1 + amountBonus)
return (
<AlertDialog open={open} onOpenChange={onOpenChange}>
@@ -92,6 +95,21 @@ export function PaymentConfirmDialog({
</span>
</div>
{amountBonus > 0 && (
<div className='flex items-center justify-between'>
<span className='text-muted-foreground text-sm'>
到账金额
</span>
<span className='text-lg font-semibold text-green-600'>
{formatLocalCurrencyAmount(creditedAmount, {
digitsLarge: 2,
digitsSmall: 2,
abbreviate: false,
})}
</span>
</div>
)}
<div className='flex items-center justify-between'>
<span className='text-muted-foreground text-sm'>
{t('You Pay')}
@@ -72,6 +72,7 @@ interface RechargeFormCardProps {
loading?: boolean
priceRatio?: number
usdExchangeRate?: number
amountBonus?: number
onOpenBilling?: () => void
creemProducts?: CreemProduct[]
enableCreemTopup?: boolean
@@ -102,6 +103,7 @@ export function RechargeFormCard({
loading,
priceRatio = 1,
usdExchangeRate = 1,
amountBonus = 0,
onOpenBilling,
creemProducts,
enableCreemTopup,
@@ -219,6 +221,12 @@ export function RechargeFormCard({
{/* Online Topup Section */}
{hasAnyTopup ? (
<div className='space-y-4 sm:space-y-6'>
{hasConfigurableTopup && amountBonus > 0 && (
<div className='flex items-center gap-2.5 rounded-lg border border-green-200 bg-green-500/10 px-3 py-2.5 text-sm font-medium text-green-700 dark:border-green-500/40 dark:text-green-400'>
<Gift className='h-4 w-4 shrink-0' aria-hidden='true' />
<span>充值优惠:充值 1 元实际到账 {(1 + amountBonus) * 1} 元,以此类推,充多少送多少。</span>
</div>
)}
{hasConfigurableTopup && (
<>
{presetAmounts.length > 0 && (
@@ -266,11 +274,17 @@ export function RechargeFormCard({
)}
</div>
<div className='text-muted-foreground mt-1.5 w-full text-xs sm:mt-2'>
Pay {formatCurrency(actualPrice)}
{amountBonus > 0 && (
<span className='font-semibold text-green-600'>
{`到账 ${formatNumber(displayValue * (1 + amountBonus))}`}
{' · '}
</span>
)}
{`支付 ${formatCurrency(actualPrice)}`}
{hasDiscount && savedAmount > 0 && (
<span className='text-green-600'>
{' '}
• Save {formatCurrency(savedAmount)}
{`· 已省 ${formatCurrency(savedAmount)}`}
</span>
)}
</div>
@@ -295,19 +309,33 @@ export function RechargeFormCard({
value={localAmount}
onChange={(e) => handleAmountChange(e.target.value)}
min={minTopup}
placeholder={`Minimum ${minTopup}`}
placeholder={`最低充值 ${minTopup}`}
className='h-9 text-base sm:h-10 sm:text-lg'
/>
<div className='bg-muted/30 flex min-h-9 items-center justify-between gap-2 rounded-md border px-3 lg:min-w-52'>
<span className='text-muted-foreground truncate text-xs'>
{t('Amount to pay:')}
</span>
{calculating ? (
<Skeleton className='h-5 w-16' />
) : (
<span className='text-sm font-semibold'>
{formatCurrency(paymentAmount)}
<div className='bg-muted/30 flex min-h-9 flex-col items-center justify-center gap-0 rounded-md border px-3 lg:min-w-52'>
<div className='flex items-center justify-between gap-2 self-stretch'>
<span className='text-muted-foreground truncate text-xs'>
待支付金额:
</span>
{calculating ? (
<Skeleton className='h-5 w-16' />
) : (
<span className='text-sm font-semibold'>
{formatCurrency(paymentAmount)}
</span>
)}
</div>
{amountBonus > 0 && (
<div className='flex items-center justify-between gap-2 self-stretch text-[11px] leading-4'>
<span className='text-muted-foreground truncate'>
到账金额
</span>
<span className='font-semibold text-green-600'>
{formatNumber(
topupAmount * usdExchangeRate * (1 + amountBonus)
)}
</span>
</div>
)}
</div>
</div>
@@ -188,6 +188,10 @@ export function useTopupInfo() {
),
amount_options: parseAmountOptions(response.data.amount_options),
discount: parseDiscountMap(response.data.discount),
amount_bonus: Math.max(
Number(response.data.amount_bonus) || 0,
0
),
creem_products: parseCreemProducts(response.data.creem_products),
waffo_pay_methods: parseWaffoPayMethods(
response.data.waffo_pay_methods
+2
View File
@@ -323,6 +323,7 @@ export function Wallet(props: WalletProps) {
: (status?.price as number) || 1
}
usdExchangeRate={effectiveUsdExchangeRate}
amountBonus={topupInfo?.amount_bonus ?? 0}
onOpenBilling={() => setBillingDialogOpen(true)}
creemProducts={topupInfo?.creem_products}
enableCreemTopup={topupInfo?.enable_creem_topup}
@@ -369,6 +370,7 @@ export function Wallet(props: WalletProps) {
processing={processing || waffoProcessing || pancakeProcessing}
discountRate={getDiscountRate()}
usdExchangeRate={effectiveUsdExchangeRate}
amountBonus={topupInfo?.amount_bonus ?? 0}
/>
<TransferDialog
+2
View File
@@ -134,6 +134,8 @@ export interface TopupInfo {
amount_options: number[]
/** Discount rates by amount */
discount: Record<number, number>
/** Uniform credited bonus ratio (1 = pay 1 get 2), 0 means no bonus */
amount_bonus: number
/** Optional topup link for purchasing codes */
topup_link?: string
/** Whether Creem topup is enabled */