fix: 统一盈亏字段精度为 2 位小数;修复 sub_plan_pricing.status 拼写错误

- CompanyOverviewServiceImpl / CategoryExportExcelServiceImpl / ExportServiceImpl / ShopOverviewStatisticsServiceImpl / ProductOverviewServiceImpl:所有 profitAfterTax / netProfit 等盈亏字段统一 setScale(2, RoundingMode.HALF_UP),避免 JSON 序列化时出现过多小数位
- sub_design.sql:stauts → status 拼写修正
- 前端:品类/商品排行榜/概览卡片等表格 feeRatio / roi 等数值精度统一展示处理
This commit is contained in:
小蟑螂
2026-05-07 22:04:13 +08:00
parent d8da5a1b33
commit 061737a984
20 changed files with 205 additions and 129 deletions
@@ -3,6 +3,8 @@ import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
import { computed } from 'vue';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
defineOptions({ name: 'CategoryComparisonTable' });
interface Props {
@@ -35,13 +37,9 @@ const someCategoriesSelected = computed(() => {
});
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
const formatPercentPlain = (value: number | undefined) => {
if (value === undefined) return '-';
return `${value.toFixed(1)}%`;
};
</script>
<template>
@@ -226,7 +224,7 @@ const formatPercentPlain = (value: number | undefined) => {
{{ cat.brushFee ? formatAmount(cat.brushFee) : '-' }}
</td>
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ cat.feeRatio !== undefined ? formatPercentPlain(cat.feeRatio) : '-' }}
{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}
</td>
<td class="p-6 font-bold">
{{ cat.totalProfitBeforeTax ? formatAmount(cat.totalProfitBeforeTax) : '-' }}
@@ -263,7 +261,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6 text-rose-600 dark:text-rose-400">{{ categoryComparisons?.total?.refundAmount ? formatAmount(categoryComparisons?.total?.refundAmount) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.totalPromotionFee ? formatAmount(categoryComparisons?.total?.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ categoryComparisons?.total?.brushFee ? formatAmount(categoryComparisons?.total?.brushFee) : '-' }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.feeRatio !== undefined ? formatPercentPlain(categoryComparisons?.total?.feeRatio) : '-' }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(categoryComparisons?.total?.feeRatio) : '-' }}</td>
<!-- 盈利 -->
<td class="p-6">{{ categoryComparisons?.total?.totalProfitBeforeTax ? formatAmount(categoryComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ categoryComparisons?.total?.salesTaxAmount ? formatAmount(categoryComparisons?.total?.salesTaxAmount) : '-' }}</td>
@@ -1,6 +1,8 @@
<script lang="ts" setup>
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
defineOptions({ name: 'KpiCards' });
interface Props {
@@ -12,7 +14,7 @@ const props = defineProps<Props>();
void props; // kept for template compatibility
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
const formatPercent = (value: number | undefined) => {
@@ -82,7 +84,7 @@ const formatPercentPlain = (value: number | undefined) => {
>
<span>全店平均费比</span>
<span class="text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ formatPercentPlain(overviewData.averageFeeRatio) }}
{{ formatFeeRatioPercent(overviewData.averageFeeRatio) }}
</span>
</div>
</div>
@@ -2,6 +2,8 @@
import { computed, ref } from 'vue';
import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
defineOptions({ name: 'PlatformSummaryCard' });
interface Props {
@@ -32,7 +34,7 @@ const somePlatformsSelected = computed(() => {
});
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
const formatPercentPlain = (value: number | undefined) => {
@@ -281,7 +283,7 @@ const sortedData = computed(() => {
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">{{ formatAmount(p.refundAmount) }}</td>
<td class="p-6">{{ formatAmount(p.totalPromotionFee) }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ formatAmount(p.brushFee) }}</td>
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatPercentPlain(p.feeRatio) }}</td>
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ formatFeeRatioPercent(p.feeRatio) }}</td>
<!-- 盈利 -->
<td class="p-6 font-bold" :class="p.totalProfitBeforeTax >= 0 ? 'text-slate-800 dark:text-[hsl(0deg_0%_95%)]' : 'text-rose-600 dark:text-rose-400'">
{{ formatAmount(p.totalProfitBeforeTax) }}
@@ -318,7 +320,7 @@ const sortedData = computed(() => {
<td class="p-6">{{ totalData.totalPromotionFee ? formatAmount(totalData.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ totalData.brushFee ? formatAmount(totalData.brushFee) : '-' }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ totalData.feeRatio !== undefined ? formatPercentPlain(totalData.feeRatio) : '-' }}
{{ totalData.feeRatio !== undefined ? formatFeeRatioPercent(totalData.feeRatio) : '-' }}
</td>
<!-- 盈利 -->
<td class="p-6">
@@ -24,7 +24,7 @@ const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
const { renderEcharts: renderTrendChart } = useEcharts(trendChartRef);
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
// 渲染店铺销售占比排行图表
@@ -96,7 +96,7 @@ const renderShopBarChart = () => {
show: true,
position: 'right',
formatter: (params: any) =>
`¥${params.value.toLocaleString('zh-CN')}`,
`¥${params.value.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`,
fontWeight: 900,
color: isDark ? 'hsl(0deg 0% 95%)' : '#334155',
},
@@ -3,6 +3,8 @@ import type { CompanyOverviewVO } from '#/api/ecommerce/store-overview';
import { computed } from 'vue';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
defineOptions({ name: 'ShopComparisonTable' });
interface Props {
@@ -31,7 +33,7 @@ const someShopsSelected = computed(() => {
});
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
const formatPercentPlain = (value: number | undefined) => {
@@ -304,7 +306,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{
shop.feeRatio !== undefined
? formatPercentPlain(shop.feeRatio)
? formatFeeRatioPercent(shop.feeRatio)
: '-'
}}
</td>
@@ -361,7 +363,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6 text-rose-600 dark:text-rose-400">{{ shopComparisons?.total?.refundAmount ? formatAmount(shopComparisons?.total?.refundAmount) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.totalPromotionFee ? formatAmount(shopComparisons?.total?.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ shopComparisons?.total?.brushFee ? formatAmount(shopComparisons?.total?.brushFee) : '-' }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.feeRatio !== undefined ? formatPercentPlain(shopComparisons?.total?.feeRatio) : '-' }}</td>
<td class="p-6 text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.feeRatio !== undefined ? formatFeeRatioPercent(shopComparisons?.total?.feeRatio) : '-' }}</td>
<!-- 盈利 -->
<td class="p-6">{{ shopComparisons?.total?.totalProfitBeforeTax ? formatAmount(shopComparisons?.total?.totalProfitBeforeTax) : '-' }}</td>
<td class="p-6 italic text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">{{ shopComparisons?.total?.salesTaxAmount ? formatAmount(shopComparisons?.total?.salesTaxAmount) : '-' }}</td>