/* Copyright (C) 2025 QuantumNous This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . For commercial licensing, please contact support@quantumnous.com */ import React from 'react'; import { Banner, Modal, Typography, Card, Button, Select, Divider, Tooltip, } from '@douyinfe/semi-ui'; import { Crown, CalendarClock, Package } from 'lucide-react'; import { SiStripe } from 'react-icons/si'; import { IconCreditCard } from '@douyinfe/semi-icons'; import { renderQuota } from '../../../helpers'; import { getCurrencyConfig } from '../../../helpers/render'; import { formatSubscriptionDuration, formatSubscriptionResetPeriod, } from '../../../helpers/subscriptionFormat'; const { Text } = Typography; const SubscriptionPurchaseModal = ({ t, visible, onCancel, selectedPlan, paying, selectedEpayMethod, setSelectedEpayMethod, epayMethods = [], enableOnlineTopUp = false, enableStripeTopUp = false, enableCreemTopUp = false, purchaseLimitInfo = null, onPayStripe, onPayCreem, onPayEpay, }) => { const plan = selectedPlan?.plan; const totalAmount = Number(plan?.total_amount || 0); const { symbol, rate } = getCurrencyConfig(); const price = plan ? Number(plan.price_amount || 0) : 0; const convertedPrice = price * rate; const displayPrice = convertedPrice.toFixed( Number.isInteger(convertedPrice) ? 0 : 2, ); // 只有当管理员开启支付网关 AND 套餐配置了对应的支付ID时才显示 const hasStripe = enableStripeTopUp && !!plan?.stripe_price_id; const hasCreem = enableCreemTopUp && !!plan?.creem_product_id; const hasEpay = enableOnlineTopUp && epayMethods.length > 0; const hasAnyPayment = hasStripe || hasCreem || hasEpay; const purchaseLimit = Number(purchaseLimitInfo?.limit || 0); const purchaseCount = Number(purchaseLimitInfo?.count || 0); const purchaseLimitReached = purchaseLimit > 0 && purchaseCount >= purchaseLimit; return ( {t('购买订阅套餐')} } visible={visible} onCancel={onCancel} footer={null} size='small' centered > {plan ? (
{/* 套餐信息 */}
{t('套餐名称')}: {plan.title}
{t('有效期')}:
{formatSubscriptionDuration(plan, t)}
{formatSubscriptionResetPeriod(plan, t) !== t('不重置') && (
{t('重置周期')}: {formatSubscriptionResetPeriod(plan, t)}
)}
{t('总额度')}:
{totalAmount > 0 ? ( {renderQuota(totalAmount)} ) : ( {t('不限')} )}
{plan?.upgrade_group ? (
{t('升级分组')}: {plan.upgrade_group}
) : null}
{t('应付金额')}: {symbol} {displayPrice}
{/* 支付方式 */} {purchaseLimitReached && ( )} {hasAnyPayment ? (
{t('选择支付方式')}: {/* Stripe / Creem */} {(hasStripe || hasCreem) && (
{hasStripe && ( )} {hasCreem && ( )}
)} {/* 易支付 */} {hasEpay && (