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:
1 parent
14a9acd368
commit
cf06cd72be
19 files changed
+172
-22
No files matched your search
@@ -65,6 +65,8 @@
|
|||||||
| Feature | Description |
|
| Feature | Description |
|
||||||
| ------- | ----------- |
|
| ------- | ----------- |
|
||||||
| 💰 **Native CNY billing** | Quota is displayed in CNY: top-up amount equals RMB paid, credited quota = amount ÷ Price × QuotaPerUnit. No exchange-rate conversion in the wallet; applies to all top-up channels such as Epay and Waffo (`controller/topup.go`, `model/topup.go`) |
|
| 💰 **Native CNY billing** | Quota is displayed in CNY: top-up amount equals RMB paid, credited quota = amount ÷ Price × QuotaPerUnit. No exchange-rate conversion in the wallet; applies to all top-up channels such as Epay and Waffo (`controller/topup.go`, `model/topup.go`) |
|
||||||
|
| 🎉 **Recharge bonus (pay 1 get 2)** | New uniform top-up bonus: set `payment_setting.amount_bonus` to `1.0` and every ¥1 paid credits ¥2 of quota ("充多少送多少"). Backend multiplies credited quota in `model/topupQuotaFromAmount` (covers Epay/Waffo/pancake/补单 paths) and `controller/getTopUpQuota` keeps validation consistent; bonus ratio is exposed via `/api/user/topup/info`. The wallet recharge card shows a 100%-bonus banner, per-preset credited amounts ("到账 ¥2"), custom-amount credited line, and a credited amount row in the payment confirm dialog — all hardcoded Chinese for the zh audience |
|
||||||
|
| 🈷️ **Chinese-first i18n** | Recharge UI texts are written directly in Chinese (banner, "支付"/"到账", placeholders). Site language no longer follows the browser locale: it defaults to Chinese (fallback `zhCN`) and honors a user's manual switch only; old language caches are reset via a new storage key |
|
||||||
| 🎁 **Daily check-in + header button** | New `CheckinButton` component in both authenticated and public headers, with Turnstile support; guides anonymous visitors to sign up |
|
| 🎁 **Daily check-in + header button** | New `CheckinButton` component in both authenticated and public headers, with Turnstile support; guides anonymous visitors to sign up |
|
||||||
| 📦 **Subscription plans page `/subscribe`** | Public plan listing (reads a `plans.json` snapshot when logged out, system API when logged in), supports Alipay purchase, balance payment, and free claims; auto group upgrade on purchase, periodic quota reset, auto downgrade on expiry |
|
| 📦 **Subscription plans page `/subscribe`** | Public plan listing (reads a `plans.json` snapshot when logged out, system API when logged in), supports Alipay purchase, balance payment, and free claims; auto group upgrade on purchase, periodic quota reset, auto downgrade on expiry |
|
||||||
| 📖 **Built-in usage docs `/docs`** | A brand-new 12-section beginner guide (intro, quick start, check-in, top-up, group explanation, API keys, pricing, Playground, third-party clients, API examples, FAQ) with sticky anchor navigation |
|
| 📖 **Built-in usage docs `/docs`** | A brand-new 12-section beginner guide (intro, quick start, check-in, top-up, group explanation, API keys, pricing, Playground, third-party clients, API examples, FAQ) with sticky anchor navigation |
|
||||||
@@ -74,6 +76,25 @@
|
|||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Try it live at <https://ai.88531.cn>: get ¥0.1 on sign-up and ¥0.5 per daily check-in — no deposit needed to try 30+ models including GLM, DeepSeek, and Kimi.
|
> Try it live at <https://ai.88531.cn>: get ¥0.1 on sign-up and ¥0.5 per daily check-in — no deposit needed to try 30+ models including GLM, DeepSeek, and Kimi.
|
||||||
|
|
||||||
|
### 🗒️ 更新日志(Latest update — 充值优惠上线)
|
||||||
|
|
||||||
|
**2026-09-24 · v"充值优惠"(RC42)**
|
||||||
|
|
||||||
|
1. **充值优惠「充 1 元到账 2 元」**
|
||||||
|
- 后端新增统一赠送比例 `payment_setting.amount_bonus`:`1` = 充多少送多少(¥1 实到 ¥2),`0` = 关闭;改数据库一行再重启即可调整,无需改代码
|
||||||
|
- 到账额度统一在 `topupQuotaFromAmount` / `getTopUpQuota` 乘以 `(1 + bonus)`,覆盖易支付、Waffo、Pancake、管理员补单全部到账路径;Stripe/Creem 保持原有逻辑
|
||||||
|
- 携带回归测试 `TestTopUpQuotaAppliesAmountBonus`(含赠送关闭恢复原状)
|
||||||
|
2. **充值页展示优惠**(位置:控制台 → 钱包)
|
||||||
|
- 顶部绿色横幅:「充值优惠:充值 1 元实际到账 2 元,以此类推,充多少送多少。」
|
||||||
|
- 每个金额档显示「到账 ¥x」(绿色)+「支付 ¥x · 已省 ¥x」
|
||||||
|
- 自定义金额旁显示「待支付金额」+「到账金额」两行;输入框占位符改「最低充值 N」
|
||||||
|
- 支付确认弹窗新增「到账金额」绿色行
|
||||||
|
3. **文档页 `/docs`** 第 05 节「充值与包月套餐」加入优惠说明框(¥10→¥20、¥100→¥200 举例)
|
||||||
|
4. **关于页**(后台可编辑的 HTML 内容)新增「🎁 充值优惠 · 充 1 元到账 2 元」小节,含 ¥1/¥10/¥100 到账价格卡片
|
||||||
|
5. **默认中文**:i18n 不再跟随浏览器语言,默认中文;充值页关键文案直接中文写死,避免英文浏览器显示英文
|
||||||
|
|
||||||
|
> 配置入口:数据库 `options` 表 `payment_setting.amount_bonus`(如改回 `0` 即取消优惠)。关于页优惠小节保存在 `options` 表的 `About` 键中,可在后台 系统设置 → 导航 内容里继续编辑。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 📝 Project Description
|
## 📝 Project Description
|
||||||
|
|||||||
+3
-1
@@ -119,6 +119,7 @@ func GetTopUpInfo(c *gin.Context) {
|
|||||||
"waffo_pancake_min_topup": setting.WaffoPancakeMinTopUp,
|
"waffo_pancake_min_topup": setting.WaffoPancakeMinTopUp,
|
||||||
"amount_options": operation_setting.GetPaymentSetting().AmountOptions,
|
"amount_options": operation_setting.GetPaymentSetting().AmountOptions,
|
||||||
"discount": operation_setting.GetPaymentSetting().AmountDiscount,
|
"discount": operation_setting.GetPaymentSetting().AmountDiscount,
|
||||||
|
"amount_bonus": operation_setting.GetTopupBonusRatio(),
|
||||||
"topup_link": common.TopUpLink,
|
"topup_link": common.TopUpLink,
|
||||||
}
|
}
|
||||||
common.ApiSuccess(c, data)
|
common.ApiSuccess(c, data)
|
||||||
@@ -210,7 +211,6 @@ func getMinTopup() int64 {
|
|||||||
|
|
||||||
func getTopUpQuota(amount int64) (int, error) {
|
func getTopUpQuota(amount int64) (int, error) {
|
||||||
quota := decimal.NewFromInt(amount)
|
quota := decimal.NewFromInt(amount)
|
||||||
// CNY 模式:amount 为人民币金额,到账额度 = 人民币 / Price × QuotaPerUnit(换算为美元额度)
|
|
||||||
if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeCNY {
|
if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeCNY {
|
||||||
dPrice := decimal.NewFromFloat(operation_setting.Price)
|
dPrice := decimal.NewFromFloat(operation_setting.Price)
|
||||||
if dPrice.IsPositive() {
|
if dPrice.IsPositive() {
|
||||||
@@ -223,6 +223,8 @@ func getTopUpQuota(amount int64) (int, error) {
|
|||||||
} else {
|
} else {
|
||||||
quota = quota.Mul(decimal.NewFromFloat(common.QuotaPerUnit))
|
quota = quota.Mul(decimal.NewFromFloat(common.QuotaPerUnit))
|
||||||
}
|
}
|
||||||
|
// 到账额度同样叠加统一赠送比例,确保校验与实际到账一致(如充值 1 元到账 2 元)
|
||||||
|
quota = quota.Mul(decimal.NewFromFloat(1 + operation_setting.GetTopupBonusRatio()))
|
||||||
return common.WalletQuotaFromDecimalStrict(quota)
|
return common.WalletQuotaFromDecimalStrict(quota)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -74,6 +75,36 @@ func TestTopUpQuotaValidation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestTopUpQuotaAppliesAmountBonus(t *testing.T) {
|
||||||
|
oldQuotaPerUnit := common.QuotaPerUnit
|
||||||
|
oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType
|
||||||
|
oldPrice := operation_setting.Price
|
||||||
|
oldBonus := operation_setting.GetPaymentSetting().AmountBonus
|
||||||
|
common.QuotaPerUnit = 500000
|
||||||
|
operation_setting.GetGeneralSetting().QuotaDisplayType = operation_setting.QuotaDisplayTypeCNY
|
||||||
|
operation_setting.Price = 7.1
|
||||||
|
// 1.0 = 充值多少到账翻倍(充 1 元到账 2 元)
|
||||||
|
operation_setting.GetPaymentSetting().AmountBonus = 1.0
|
||||||
|
t.Cleanup(func() {
|
||||||
|
common.QuotaPerUnit = oldQuotaPerUnit
|
||||||
|
operation_setting.GetGeneralSetting().QuotaDisplayType = oldDisplayType
|
||||||
|
operation_setting.Price = oldPrice
|
||||||
|
operation_setting.GetPaymentSetting().AmountBonus = oldBonus
|
||||||
|
})
|
||||||
|
|
||||||
|
quota, err := getTopUpQuota(1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
// 到账 = round(1 / 7.1 × 500000) × (1 + 1),即充值 1 元实际到账 2 元
|
||||||
|
expectedBase := int(math.Round(1 / 7.1 * 500000))
|
||||||
|
assert.Equal(t, expectedBase*2, quota)
|
||||||
|
|
||||||
|
// bonus=0 恢复无赠送行为
|
||||||
|
operation_setting.GetPaymentSetting().AmountBonus = 0
|
||||||
|
quota, err = getTopUpQuota(1)
|
||||||
|
require.NoError(t, err)
|
||||||
|
assert.Equal(t, expectedBase, quota)
|
||||||
|
}
|
||||||
|
|
||||||
func TestValidateTopUpQuotaReturnsMaximumAmount(t *testing.T) {
|
func TestValidateTopUpQuotaReturnsMaximumAmount(t *testing.T) {
|
||||||
oldQuotaPerUnit := common.QuotaPerUnit
|
oldQuotaPerUnit := common.QuotaPerUnit
|
||||||
oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType
|
oldDisplayType := operation_setting.GetGeneralSetting().QuotaDisplayType
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ import (
|
|||||||
|
|
||||||
// topupQuotaFromAmount 将充值记录的 Amount 换算为到账 quota。
|
// topupQuotaFromAmount 将充值记录的 Amount 换算为到账 quota。
|
||||||
// CNY 展示模式下 Amount 为人民币金额,需先除以 Price 再乘 QuotaPerUnit。
|
// CNY 展示模式下 Amount 为人民币金额,需先除以 Price 再乘 QuotaPerUnit。
|
||||||
|
// 充值赠送比例(payment_setting.amount_bonus)在所有换算路径统一叠加,
|
||||||
|
// 例如 amount_bonus=1.0 时充值 1 元实际到账 2 元。
|
||||||
func topupQuotaFromAmount(amount int64) decimal.Decimal {
|
func topupQuotaFromAmount(amount int64) decimal.Decimal {
|
||||||
d := decimal.NewFromInt(amount)
|
d := decimal.NewFromInt(amount)
|
||||||
if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeCNY {
|
if operation_setting.GetQuotaDisplayType() == operation_setting.QuotaDisplayTypeCNY {
|
||||||
@@ -23,6 +25,7 @@ func topupQuotaFromAmount(amount int64) decimal.Decimal {
|
|||||||
d = d.Div(dPrice)
|
d = d.Div(dPrice)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
d = d.Mul(decimal.NewFromFloat(1 + operation_setting.GetTopupBonusRatio()))
|
||||||
return d.Mul(decimal.NewFromFloat(common.QuotaPerUnit))
|
return d.Mul(decimal.NewFromFloat(common.QuotaPerUnit))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import "github.com/QuantumNous/new-api/setting/config"
|
|||||||
type PaymentSetting struct {
|
type PaymentSetting struct {
|
||||||
AmountOptions []int `json:"amount_options"`
|
AmountOptions []int `json:"amount_options"`
|
||||||
AmountDiscount map[int]float64 `json:"amount_discount"` // 充值金额对应的折扣,例如 100 元 0.9 表示 100 元充值享受 9 折优惠
|
AmountDiscount map[int]float64 `json:"amount_discount"` // 充值金额对应的折扣,例如 100 元 0.9 表示 100 元充值享受 9 折优惠
|
||||||
|
AmountBonus float64 `json:"amount_bonus"` // 统一赠送比例:1.0 表示充值多少到账双倍(充1到2),0 表示无赠送
|
||||||
|
|
||||||
ComplianceConfirmed bool `json:"compliance_confirmed"`
|
ComplianceConfirmed bool `json:"compliance_confirmed"`
|
||||||
ComplianceTermsVersion string `json:"compliance_terms_version"`
|
ComplianceTermsVersion string `json:"compliance_terms_version"`
|
||||||
@@ -30,6 +31,14 @@ func GetPaymentSetting() *PaymentSetting {
|
|||||||
return &paymentSetting
|
return &paymentSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTopupBonusRatio 返回充值赠送比例(负值视为 0,0 表示无赠送,1.0 表示到账翻倍)
|
||||||
|
func GetTopupBonusRatio() float64 {
|
||||||
|
if paymentSetting.AmountBonus > 0 {
|
||||||
|
return paymentSetting.AmountBonus
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
func IsPaymentComplianceConfirmed() bool {
|
func IsPaymentComplianceConfirmed() bool {
|
||||||
return paymentSetting.ComplianceConfirmed &&
|
return paymentSetting.ComplianceConfirmed &&
|
||||||
paymentSetting.ComplianceTermsVersion == CurrentComplianceTermsVersion
|
paymentSetting.ComplianceTermsVersion == CurrentComplianceTermsVersion
|
||||||
|
|||||||
@@ -216,6 +216,11 @@ export function Docs() {
|
|||||||
,页面会自动跳回本站
|
,页面会自动跳回本站
|
||||||
</li>
|
</li>
|
||||||
</ol>
|
</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>
|
<h3>方式二:包月套餐(推荐)</h3>
|
||||||
<p>
|
<p>
|
||||||
前往{' '}
|
前往{' '}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ interface PaymentConfirmDialogProps {
|
|||||||
processing: boolean
|
processing: boolean
|
||||||
discountRate?: number
|
discountRate?: number
|
||||||
usdExchangeRate?: number
|
usdExchangeRate?: number
|
||||||
|
amountBonus?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PaymentConfirmDialog({
|
export function PaymentConfirmDialog({
|
||||||
@@ -60,11 +61,13 @@ export function PaymentConfirmDialog({
|
|||||||
processing,
|
processing,
|
||||||
discountRate = DEFAULT_DISCOUNT_RATE,
|
discountRate = DEFAULT_DISCOUNT_RATE,
|
||||||
usdExchangeRate = 1,
|
usdExchangeRate = 1,
|
||||||
|
amountBonus = 0,
|
||||||
}: PaymentConfirmDialogProps) {
|
}: PaymentConfirmDialogProps) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
const hasDiscount = discountRate > 0 && discountRate < 1 && paymentAmount > 0
|
const hasDiscount = discountRate > 0 && discountRate < 1 && paymentAmount > 0
|
||||||
const originalAmount = hasDiscount ? paymentAmount / discountRate : 0
|
const originalAmount = hasDiscount ? paymentAmount / discountRate : 0
|
||||||
const discountAmount = hasDiscount ? originalAmount - paymentAmount : 0
|
const discountAmount = hasDiscount ? originalAmount - paymentAmount : 0
|
||||||
|
const creditedAmount = topupAmount * usdExchangeRate * (1 + amountBonus)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
<AlertDialog open={open} onOpenChange={onOpenChange}>
|
||||||
@@ -92,6 +95,21 @@ export function PaymentConfirmDialog({
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</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'>
|
<div className='flex items-center justify-between'>
|
||||||
<span className='text-muted-foreground text-sm'>
|
<span className='text-muted-foreground text-sm'>
|
||||||
{t('You Pay')}
|
{t('You Pay')}
|
||||||
|
|||||||
@@ -72,6 +72,7 @@ interface RechargeFormCardProps {
|
|||||||
loading?: boolean
|
loading?: boolean
|
||||||
priceRatio?: number
|
priceRatio?: number
|
||||||
usdExchangeRate?: number
|
usdExchangeRate?: number
|
||||||
|
amountBonus?: number
|
||||||
onOpenBilling?: () => void
|
onOpenBilling?: () => void
|
||||||
creemProducts?: CreemProduct[]
|
creemProducts?: CreemProduct[]
|
||||||
enableCreemTopup?: boolean
|
enableCreemTopup?: boolean
|
||||||
@@ -102,6 +103,7 @@ export function RechargeFormCard({
|
|||||||
loading,
|
loading,
|
||||||
priceRatio = 1,
|
priceRatio = 1,
|
||||||
usdExchangeRate = 1,
|
usdExchangeRate = 1,
|
||||||
|
amountBonus = 0,
|
||||||
onOpenBilling,
|
onOpenBilling,
|
||||||
creemProducts,
|
creemProducts,
|
||||||
enableCreemTopup,
|
enableCreemTopup,
|
||||||
@@ -219,6 +221,12 @@ export function RechargeFormCard({
|
|||||||
{/* Online Topup Section */}
|
{/* Online Topup Section */}
|
||||||
{hasAnyTopup ? (
|
{hasAnyTopup ? (
|
||||||
<div className='space-y-4 sm:space-y-6'>
|
<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 && (
|
{hasConfigurableTopup && (
|
||||||
<>
|
<>
|
||||||
{presetAmounts.length > 0 && (
|
{presetAmounts.length > 0 && (
|
||||||
@@ -266,11 +274,17 @@ export function RechargeFormCard({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<div className='text-muted-foreground mt-1.5 w-full text-xs sm:mt-2'>
|
<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 && (
|
{hasDiscount && savedAmount > 0 && (
|
||||||
<span className='text-green-600'>
|
<span className='text-green-600'>
|
||||||
{' '}
|
{' '}
|
||||||
• Save {formatCurrency(savedAmount)}
|
{`· 已省 ${formatCurrency(savedAmount)}`}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -295,19 +309,33 @@ export function RechargeFormCard({
|
|||||||
value={localAmount}
|
value={localAmount}
|
||||||
onChange={(e) => handleAmountChange(e.target.value)}
|
onChange={(e) => handleAmountChange(e.target.value)}
|
||||||
min={minTopup}
|
min={minTopup}
|
||||||
placeholder={`Minimum ${minTopup}`}
|
placeholder={`最低充值 ${minTopup}`}
|
||||||
className='h-9 text-base sm:h-10 sm:text-lg'
|
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'>
|
<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'>
|
||||||
<span className='text-muted-foreground truncate text-xs'>
|
<div className='flex items-center justify-between gap-2 self-stretch'>
|
||||||
{t('Amount to pay:')}
|
<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>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -188,6 +188,10 @@ export function useTopupInfo() {
|
|||||||
),
|
),
|
||||||
amount_options: parseAmountOptions(response.data.amount_options),
|
amount_options: parseAmountOptions(response.data.amount_options),
|
||||||
discount: parseDiscountMap(response.data.discount),
|
discount: parseDiscountMap(response.data.discount),
|
||||||
|
amount_bonus: Math.max(
|
||||||
|
Number(response.data.amount_bonus) || 0,
|
||||||
|
0
|
||||||
|
),
|
||||||
creem_products: parseCreemProducts(response.data.creem_products),
|
creem_products: parseCreemProducts(response.data.creem_products),
|
||||||
waffo_pay_methods: parseWaffoPayMethods(
|
waffo_pay_methods: parseWaffoPayMethods(
|
||||||
response.data.waffo_pay_methods
|
response.data.waffo_pay_methods
|
||||||
|
|||||||
@@ -323,6 +323,7 @@ export function Wallet(props: WalletProps) {
|
|||||||
: (status?.price as number) || 1
|
: (status?.price as number) || 1
|
||||||
}
|
}
|
||||||
usdExchangeRate={effectiveUsdExchangeRate}
|
usdExchangeRate={effectiveUsdExchangeRate}
|
||||||
|
amountBonus={topupInfo?.amount_bonus ?? 0}
|
||||||
onOpenBilling={() => setBillingDialogOpen(true)}
|
onOpenBilling={() => setBillingDialogOpen(true)}
|
||||||
creemProducts={topupInfo?.creem_products}
|
creemProducts={topupInfo?.creem_products}
|
||||||
enableCreemTopup={topupInfo?.enable_creem_topup}
|
enableCreemTopup={topupInfo?.enable_creem_topup}
|
||||||
@@ -369,6 +370,7 @@ export function Wallet(props: WalletProps) {
|
|||||||
processing={processing || waffoProcessing || pancakeProcessing}
|
processing={processing || waffoProcessing || pancakeProcessing}
|
||||||
discountRate={getDiscountRate()}
|
discountRate={getDiscountRate()}
|
||||||
usdExchangeRate={effectiveUsdExchangeRate}
|
usdExchangeRate={effectiveUsdExchangeRate}
|
||||||
|
amountBonus={topupInfo?.amount_bonus ?? 0}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TransferDialog
|
<TransferDialog
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ export interface TopupInfo {
|
|||||||
amount_options: number[]
|
amount_options: number[]
|
||||||
/** Discount rates by amount */
|
/** Discount rates by amount */
|
||||||
discount: Record<number, number>
|
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 */
|
/** Optional topup link for purchasing codes */
|
||||||
topup_link?: string
|
topup_link?: string
|
||||||
/** Whether Creem topup is enabled */
|
/** Whether Creem topup is enabled */
|
||||||
|
|||||||
@@ -44,7 +44,8 @@ i18n
|
|||||||
.use(initReactI18next)
|
.use(initReactI18next)
|
||||||
.init({
|
.init({
|
||||||
resources,
|
resources,
|
||||||
fallbackLng: 'en',
|
// 站点面向中文用户:无语言偏好缓存时默认中文,同时支持在界面上手动切换语言
|
||||||
|
fallbackLng: 'zhCN',
|
||||||
supportedLngs: ['en', 'zhCN', 'fr', 'ru', 'ja', 'vi', 'zhTW'],
|
supportedLngs: ['en', 'zhCN', 'fr', 'ru', 'ja', 'vi', 'zhTW'],
|
||||||
load: 'currentOnly',
|
load: 'currentOnly',
|
||||||
nsSeparator: false, // Allow literal colons in keys (e.g., URLs, labels)
|
nsSeparator: false, // Allow literal colons in keys (e.g., URLs, labels)
|
||||||
@@ -53,7 +54,10 @@ i18n
|
|||||||
escapeValue: false, // not needed for react as it escapes by default
|
escapeValue: false, // not needed for react as it escapes by default
|
||||||
},
|
},
|
||||||
detection: {
|
detection: {
|
||||||
order: ['localStorage', 'navigator'],
|
// 仅信任已保存的语言偏好,不再跟随浏览器语言,避免英文环境误显示英文
|
||||||
|
order: ['localStorage'],
|
||||||
|
// 使用新的存储键名:丢弃旧版本残留的浏览器语言缓存(如曾识别为 en 的用户)
|
||||||
|
lookupLocalStorage: 'i18nextLngV2',
|
||||||
caches: ['localStorage'],
|
caches: ['localStorage'],
|
||||||
// Browsers report `zh-CN`/`zh-TW`/`zh`; map them onto our `zhCN`/`zhTW`
|
// Browsers report `zh-CN`/`zh-TW`/`zh`; map them onto our `zhCN`/`zhTW`
|
||||||
// codes (non-Chinese codes pass through for normal supportedLngs matching).
|
// codes (non-Chinese codes pass through for normal supportedLngs matching).
|
||||||
|
|||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "Zhipu",
|
"Zhipu": "Zhipu",
|
||||||
"Zhipu V4": "Zhipu V4",
|
"Zhipu V4": "Zhipu V4",
|
||||||
"Zoom": "Zoom"
|
"Zoom": "Zoom"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Recharge bonus: pay ¥{{pay}}, get ¥{{credit}} credited — the more you top up, the more you get.",
|
||||||
|
"Credited amount": "Credited amount",
|
||||||
|
"Credited {{amount}}": "Credited {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "Zhipu",
|
"Zhipu": "Zhipu",
|
||||||
"Zhipu V4": "Zhipu V4",
|
"Zhipu V4": "Zhipu V4",
|
||||||
"Zoom": "Zoom"
|
"Zoom": "Zoom"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Bonus de recharge : payez ¥{{pay}} et recevez ¥{{credit}} — plus vous rechargez, plus vous gagnez.",
|
||||||
|
"Credited amount": "Montant crédité",
|
||||||
|
"Credited {{amount}}": "Crédité {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "Zhipu",
|
"Zhipu": "Zhipu",
|
||||||
"Zhipu V4": "Zhipu V 4",
|
"Zhipu V4": "Zhipu V 4",
|
||||||
"Zoom": "ズーム"
|
"Zoom": "ズーム"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "チャージ特典:{{pay}}元の支払いで{{credit}}元が付与されます。金額が多いほどお得です。",
|
||||||
|
"Credited amount": "付与額",
|
||||||
|
"Credited {{amount}}": "付与 {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "Zhipu",
|
"Zhipu": "Zhipu",
|
||||||
"Zhipu V4": "Zhipu V4",
|
"Zhipu V4": "Zhipu V4",
|
||||||
"Zoom": "Zoom"
|
"Zoom": "Zoom"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Бонус за пополнение: платите ¥{{pay}} — получаете ¥{{credit}}. Чем больше пополнение, тем больше бонус.",
|
||||||
|
"Credited amount": "Начислено",
|
||||||
|
"Credited {{amount}}": "Начислено {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "Zhipu",
|
"Zhipu": "Zhipu",
|
||||||
"Zhipu V4": "Zhipu V4",
|
"Zhipu V4": "Zhipu V4",
|
||||||
"Zoom": "Zoom"
|
"Zoom": "Zoom"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "Ưu đãi nạp tiền: nạp {{pay}} nhận {{credit}} — nạp càng nhiều nhận càng nhiều.",
|
||||||
|
"Credited amount": "Số tiền nhận được",
|
||||||
|
"Credited {{amount}}": "Nhận {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "智譜",
|
"Zhipu": "智譜",
|
||||||
"Zhipu V4": "智譜 V4",
|
"Zhipu V4": "智譜 V4",
|
||||||
"Zoom": "縮放"
|
"Zoom": "縮放"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "儲值優惠:儲值 {{pay}} 元實際入帳 {{credit}} 元,以此類推,儲多少送多少。",
|
||||||
|
"Credited amount": "入帳金額",
|
||||||
|
"Credited {{amount}}": "入帳 {{amount}}"
|
||||||
}
|
}
|
||||||
@@ -6145,5 +6145,8 @@
|
|||||||
"Zhipu": "智谱",
|
"Zhipu": "智谱",
|
||||||
"Zhipu V4": "智谱 V4",
|
"Zhipu V4": "智谱 V4",
|
||||||
"Zoom": "缩放"
|
"Zoom": "缩放"
|
||||||
}
|
},
|
||||||
|
"Recharge bonus: pay {{pay}} get {{credit}} — the more you top up, the more you get.": "充值优惠:充值 {{pay}} 元实际到账 {{credit}} 元,以此类推,充多少送多少。",
|
||||||
|
"Credited amount": "到账金额",
|
||||||
|
"Credited {{amount}}": "到账 {{amount}}"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user