/* 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 { Modal, Typography, Card, Skeleton } from '@douyinfe/semi-ui'; import { SiAlipay, SiWechat, SiStripe } from 'react-icons/si'; import { CreditCard } from 'lucide-react'; const { Text } = Typography; const PaymentConfirmModal = ({ t, open, onlineTopUp, handleCancel, confirmLoading, topUpCount, renderQuotaWithAmount, amountLoading, renderAmount, payWay, payMethods, // 新增:用于显示折扣明细 amountNumber, discountRate, }) => { const hasDiscount = discountRate && discountRate > 0 && discountRate < 1 && amountNumber > 0; const originalAmount = hasDiscount ? amountNumber / discountRate : 0; const discountAmount = hasDiscount ? originalAmount - amountNumber : 0; return ( {t('充值确认')} } visible={open} onOk={onlineTopUp} onCancel={handleCancel} maskClosable={false} size='small' centered confirmLoading={confirmLoading} >
{t('充值数量')}: {renderQuotaWithAmount(topUpCount)}
{t('实付金额')}: {amountLoading ? ( ) : (
{renderAmount()} {hasDiscount && ( {Math.round(discountRate * 100)}% )}
)}
{hasDiscount && !amountLoading && ( <>
{t('原价')}: {`${originalAmount.toFixed(2)} ${t('元')}`}
{t('优惠')}: {`- ${discountAmount.toFixed(2)} ${t('元')}`}
)}
{t('支付方式')}:
{(() => { const payMethod = payMethods.find( (method) => method.type === payWay, ); if (payMethod) { return ( <> {payMethod.type === 'alipay' ? ( ) : payMethod.type === 'wxpay' ? ( ) : payMethod.type === 'stripe' ? ( ) : ( )} {payMethod.name} ); } else { // 默认充值方式 if (payWay === 'alipay') { return ( <> {t('支付宝')} ); } else if (payWay === 'stripe') { return ( <> Stripe ); } else { return ( <> {t('微信')} ); } } })()}
); }; export default PaymentConfirmModal;