/* 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 { Popover, Tooltip } from '@douyinfe/semi-ui'; import { IconHelpCircle } from '@douyinfe/semi-icons'; import { formatCommissionRatioPercent, renderQuotaFlexible, } from '../../helpers'; const popupContainer = () => typeof document !== 'undefined' ? document.body : null; /** 利润分成额度列:常态 2 位小数,极低值自动展示至多 6 位;悬停显示完整 6 位精度。 */ export function renderProfitShareQuotaCell(quota) { const q = Number(quota) || 0; const main = renderQuotaFlexible(q, 2, 6); const exact = renderQuotaFlexible(q, 6, 6); if (main === exact) { return main; } return ( {main} ); } export function ProfitShareRewardFormulaTooltipContent({ t }) { return (
{t('利润分成计算公式')}
{t('利润分成计算说明-用户消耗')}
{t('利润分成计算说明-加价折扣')}
{t('利润分成计算说明-加价切片')}
{t('利润分成计算说明-分成比例')}
{t('利润分成计算说明-收益')}
); } /** 「收益额度」列表头:标题旁问号,点击展示计算公式(挂载 body,避免被弹窗裁切)。 */ export function ProfitShareRewardColumnTitle({ t }) { return (
{t('收益额度')} } position='leftTop' trigger='click' showArrow spacing={12} getPopupContainer={popupContainer} >
); } /** 收益额度单元格:悬停展示本笔代入公式。 */ export function renderProfitShareRewardCell(row, t) { const reward = Number(row?.reward_quota) || 0; const slice = Number(row?.markup_slice_quota) || 0; const bps = row?.commission_bps; const display = renderProfitShareQuotaCell(reward); if (slice > 0 && typeof bps === 'number' && bps > 0) { const rate = formatCommissionRatioPercent(bps); const formula = t('利润分成单行计算', { slice: renderQuotaFlexible(slice, 2, 6), rate, reward: renderQuotaFlexible(reward, 2, 6), }); return ( {display} ); } return display; }