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
@@ -15,7 +15,7 @@ defineProps<Props>();
const formatAmount = (amount: number | undefined) => {
if (amount === undefined || amount === null) return '-';
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
</script>
@@ -19,7 +19,7 @@ defineProps<Props>();
const formatAmount = (amount: number | undefined) => {
if (amount === undefined) return '-';
return `¥${amount.toLocaleString('zh-CN')}`;
return `¥${amount.toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
};
const toNumber = (value: unknown): number | undefined => {
@@ -1,6 +1,12 @@
<script lang="ts" setup>
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import {
formatCurrencyZhFromApi,
formatNumberZhFromApiOptional,
} from '#/utils/shop-overview-display';
interface Props {
data: ShopVO.OverviewStatistics | null;
taxRate: number;
@@ -17,13 +23,6 @@ interface Emits {
const props = defineProps<Props>();
const emit = defineEmits<Emits>();
const formatAmount = (amount: number) => `¥${amount.toLocaleString('zh-CN')}`;
const formatPercentPlain = (value: number | undefined) => {
if (value === undefined) return '-';
return `${value.toFixed(1)}%`;
};
</script>
<template>
@@ -167,27 +166,37 @@ const formatPercentPlain = (value: number | undefined) => {
{{ cat.categoryName || '未分类' }}
</span>
</td>
<td class="p-6 font-black">{{ formatAmount(cat.salesAmount) }}</td>
<td class="p-6 font-black">{{ formatCurrencyZhFromApi(cat.salesAmount) }}</td>
<td class="p-6">{{ cat.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
<td class="p-6">{{ cat.averageOrderValue ? `¥${cat.averageOrderValue.toFixed(2)}` : '-' }}</td>
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.otherCost ? formatAmount(cat.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cat.totalCost != null ? formatAmount(cat.totalCost) : '-' }}</td>
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 font-bold text-rose-600 dark:text-rose-400">{{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }}</td>
<td class="p-6 text-amber-600 dark:text-amber-400">{{ cat.totalPromotionFee ? formatAmount(cat.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ 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) : '-' }}</td>
<td class="p-6">{{
cat.averageOrderValue != null
? formatCurrencyZhFromApi(cat.averageOrderValue)
: '-'
}}</td>
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.productCost ? formatCurrencyZhFromApi(cat.productCost) : '-' }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.shippingCost ? formatCurrencyZhFromApi(cat.shippingCost) : '-' }}</td>
<td class="p-6 text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.otherCost ? formatCurrencyZhFromApi(cat.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ cat.totalCost != null ? formatCurrencyZhFromApi(cat.totalCost) : '-' }}</td>
<td class="border-l dark:border-l-[hsl(240deg_3.7%_22%)] p-6 font-bold text-rose-600 dark:text-rose-400">{{ cat.refundAmount ? formatCurrencyZhFromApi(cat.refundAmount) : '-' }}</td>
<td class="p-6 text-amber-600 dark:text-amber-400">{{ cat.totalPromotionFee ? formatCurrencyZhFromApi(cat.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ cat.brushFee ? formatCurrencyZhFromApi(cat.brushFee) : '-' }}</td>
<td class="p-6 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.feeRatio !== undefined ? formatFeeRatioPercent(cat.feeRatio) : '-' }}</td>
<td class="border-l border-slate-100 p-6 font-bold dark:border-l-[hsl(240deg_3.7%_22%)]">
{{ cat.totalProfitBeforeTax ? formatAmount(cat.totalProfitBeforeTax) : '-' }}
{{ cat.totalProfitBeforeTax ? formatCurrencyZhFromApi(cat.totalProfitBeforeTax) : '-' }}
</td>
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.salesTaxAmount ? formatAmount(cat.salesTaxAmount) : '-' }}</td>
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">{{ cat.roi?.toFixed(2) || '-' }}</td>
<td class="p-6 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">{{ cat.salesTaxAmount ? formatCurrencyZhFromApi(cat.salesTaxAmount) : '-' }}</td>
<td class="p-6 font-black text-indigo-700 dark:text-indigo-400">{{
formatNumberZhFromApiOptional(cat.roi)
}}</td>
<td
class="bg-emerald-50 p-6 text-base font-black dark:bg-emerald-950"
:class="(cat.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-600 dark:text-emerald-300'"
>
{{ cat.profitAfterTax ? formatAmount(cat.profitAfterTax) : '-' }}
{{
cat.profitAfterTax != null
? formatCurrencyZhFromApi(cat.profitAfterTax)
: '-'
}}
</td>
</tr>
<tr v-if="!props.data?.categoryOverview?.categories?.length">
@@ -200,24 +209,30 @@ const formatPercentPlain = (value: number | undefined) => {
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td v-if="props.categoryExportMode" class="sticky-col border-r border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] p-6 text-center" style="left: 40px; position: sticky; z-index: 10;"></td>
<td class="sticky-col border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; position: sticky; z-index: 10;">合计</td>
<td class="p-6">{{ props.data.categoryOverview.total.salesAmount ? formatAmount(props.data.categoryOverview.total.salesAmount) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.salesAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.salesAmount) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.orderCount ? props.data.categoryOverview.total.orderCount.toLocaleString() : '-' }}</td>
<td class="p-6">-</td>
<td class="p-6">{{ props.data.categoryOverview.total.productCost ? formatAmount(props.data.categoryOverview.total.productCost) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.shippingCost ? formatAmount(props.data.categoryOverview.total.shippingCost) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.otherCost ? formatAmount(props.data.categoryOverview.total.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ props.data.categoryOverview.total.totalCost != null ? formatAmount(props.data.categoryOverview.total.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ props.data.categoryOverview.total.refundAmount ? formatAmount(props.data.categoryOverview.total.refundAmount) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.totalPromotionFee ? formatAmount(props.data.categoryOverview.total.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ props.data.categoryOverview.total.brushFee ? formatAmount(props.data.categoryOverview.total.brushFee) : '-' }}</td>
<td class="p-6 text-slate-400">{{ props.data.categoryOverview.total.feeRatio !== undefined ? formatPercentPlain(props.data.categoryOverview.total.feeRatio) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.totalProfitBeforeTax ? formatAmount(props.data.categoryOverview.total.totalProfitBeforeTax) : '-' }}</td>
<td class="p-6 italic text-slate-400">{{ props.data.categoryOverview.total.salesTaxAmount ? formatAmount(props.data.categoryOverview.total.salesTaxAmount) : '-' }}</td>
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{ props.data.categoryOverview.total.roi !== undefined ? props.data.categoryOverview.total.roi.toFixed(2) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.productCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.productCost) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.shippingCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.shippingCost) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.otherCost ? formatCurrencyZhFromApi(props.data.categoryOverview.total.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ props.data.categoryOverview.total.totalCost != null ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ props.data.categoryOverview.total.refundAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.refundAmount) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.totalPromotionFee ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalPromotionFee) : '-' }}</td>
<td class="p-6 text-orange-600 dark:text-orange-400">{{ props.data.categoryOverview.total.brushFee ? formatCurrencyZhFromApi(props.data.categoryOverview.total.brushFee) : '-' }}</td>
<td class="p-6 text-slate-400">{{ props.data.categoryOverview.total.feeRatio !== undefined ? formatFeeRatioPercent(props.data.categoryOverview.total.feeRatio) : '-' }}</td>
<td class="p-6">{{ props.data.categoryOverview.total.totalProfitBeforeTax ? formatCurrencyZhFromApi(props.data.categoryOverview.total.totalProfitBeforeTax) : '-' }}</td>
<td class="p-6 italic text-slate-400">{{ props.data.categoryOverview.total.salesTaxAmount ? formatCurrencyZhFromApi(props.data.categoryOverview.total.salesTaxAmount) : '-' }}</td>
<td class="p-6 text-indigo-700 dark:text-indigo-400">{{
formatNumberZhFromApiOptional(props.data.categoryOverview.total.roi)
}}</td>
<td
class="bg-emerald-100 p-6 text-base dark:bg-emerald-950"
:class="(props.data.categoryOverview.total.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-800 dark:text-emerald-300'"
>{{ props.data.categoryOverview.total.profitAfterTax ? formatAmount(props.data.categoryOverview.total.profitAfterTax) : '-' }}</td>
>{{
props.data.categoryOverview.total.profitAfterTax != null
? formatCurrencyZhFromApi(props.data.categoryOverview.total.profitAfterTax)
: '-'
}}</td>
</tr>
</tfoot>
</table>
@@ -5,6 +5,11 @@ import { useRouter } from 'vue-router';
import { Button } from 'ant-design-vue';
import { getOverviewDateQueryFromLocation } from '#/utils/overview-date-range';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import {
formatCurrencyZhFromApi,
formatNumberZhFromApiOptional,
} from '#/utils/shop-overview-display';
interface Props {
data: ShopVO.OverviewStatistics | null;
@@ -28,13 +33,6 @@ function goToProductOverview(productId: number) {
: { path: `/ecom/product/overview/${productId}` },
);
}
const formatAmount = (amount: number) => `¥${amount.toLocaleString('zh-CN')}`;
const formatPercentPlain = (value: number | undefined) => {
if (value === undefined) return '-';
return `${value.toFixed(1)}%`;
};
</script>
<template>
@@ -155,39 +153,47 @@ const formatPercentPlain = (value: number | undefined) => {
编码: {{ product.productCode }}
</div>
</td>
<td class="px-6 py-4 font-black">{{ formatAmount(product.salesAmount) }}</td>
<td class="px-6 py-4 font-black">{{ formatCurrencyZhFromApi(product.salesAmount) }}</td>
<td class="px-6 py-4 font-medium">{{ product.orderCount?.toLocaleString('zh-CN') || '-' }}</td>
<td class="px-6 py-4">{{ product.averageOrderValue ? formatAmount(product.averageOrderValue) : '-' }}</td>
<td class="px-6 py-4">{{ product.productCost ? formatAmount(product.productCost) : '-' }}</td>
<td class="px-6 py-4">{{ product.shippingCost ? formatAmount(product.shippingCost) : '-' }}</td>
<td class="px-6 py-4">{{ product.otherCost ? formatAmount(product.otherCost) : '-' }}</td>
<td class="px-6 py-4">{{
product.averageOrderValue != null
? formatCurrencyZhFromApi(product.averageOrderValue)
: '-'
}}</td>
<td class="px-6 py-4">{{ product.productCost ? formatCurrencyZhFromApi(product.productCost) : '-' }}</td>
<td class="px-6 py-4">{{ product.shippingCost ? formatCurrencyZhFromApi(product.shippingCost) : '-' }}</td>
<td class="px-6 py-4">{{ product.otherCost ? formatCurrencyZhFromApi(product.otherCost) : '-' }}</td>
<td class="px-6 py-4 font-bold text-orange-800 dark:text-orange-300">
{{ product.totalCost != null ? formatAmount(product.totalCost) : '-' }}
{{ product.totalCost != null ? formatCurrencyZhFromApi(product.totalCost) : '-' }}
</td>
<td class="px-6 py-4 font-bold text-rose-500 dark:text-rose-400">
{{ product.refundAmount ? formatAmount(product.refundAmount) : '-' }}
{{ product.refundAmount ? formatCurrencyZhFromApi(product.refundAmount) : '-' }}
</td>
<td class="px-6 py-4">{{ product.totalPromotionFee ? formatAmount(product.totalPromotionFee) : '-' }}</td>
<td class="px-6 py-4">{{ product.totalPromotionFee ? formatCurrencyZhFromApi(product.totalPromotionFee) : '-' }}</td>
<td class="px-6 py-4 text-amber-500 dark:text-amber-400">
{{ product.brushFee ? formatAmount(product.brushFee) : '-' }}
{{ product.brushFee ? formatCurrencyZhFromApi(product.brushFee) : '-' }}
</td>
<td class="px-6 py-4 text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ product.feeRatio !== undefined ? formatPercentPlain(product.feeRatio) : '-' }}
{{ product.feeRatio !== undefined ? formatFeeRatioPercent(product.feeRatio) : '-' }}
</td>
<td class="px-6 py-4 font-black text-indigo-700 dark:text-indigo-400">
{{ product.roi?.toFixed(2) || '-' }}
{{ formatNumberZhFromApiOptional(product.roi) }}
</td>
<td class="px-6 py-4 font-bold text-slate-600 dark:text-[hsl(240deg_5%_64.9%)]">
{{ product.totalProfitBeforeTax ? formatAmount(product.totalProfitBeforeTax) : '-' }}
{{ product.totalProfitBeforeTax ? formatCurrencyZhFromApi(product.totalProfitBeforeTax) : '-' }}
</td>
<td class="px-6 py-4 italic text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
{{ product.salesTaxAmount ? formatAmount(product.salesTaxAmount) : '-' }}
{{ product.salesTaxAmount ? formatCurrencyZhFromApi(product.salesTaxAmount) : '-' }}
</td>
<td
class="bg-emerald-50/30 dark:bg-[hsl(142deg_71.8%_29%/20%)] px-6 py-4 text-base font-black"
:class="product.profitAfterTax && product.profitAfterTax < 0 ? 'text-rose-500 dark:text-rose-400' : 'text-emerald-600 dark:text-emerald-400'"
:class="(product.profitAfterTax ?? 0) < 0 ? 'text-rose-500 dark:text-rose-400' : 'text-emerald-600 dark:text-emerald-400'"
>
{{ product.profitAfterTax ? formatAmount(product.profitAfterTax) : '-' }}
{{
product.profitAfterTax != null
? formatCurrencyZhFromApi(product.profitAfterTax)
: '-'
}}
</td>
</tr>
<tr v-if="!data?.productOverview?.products?.length">
@@ -199,24 +205,30 @@ const formatPercentPlain = (value: number | undefined) => {
<tfoot v-if="data?.productOverview?.total">
<tr class="font-black text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
<td class="sticky-col sticky bottom-0 border-r-2 border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4 text-base font-black" style="left: 0; z-index: 30;">合计</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.salesAmount ? formatAmount(data.productOverview.total.salesAmount) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.salesAmount ? formatCurrencyZhFromApi(data.productOverview.total.salesAmount) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.orderCount ? data.productOverview.total.orderCount.toLocaleString() : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">-</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.productCost ? formatAmount(data.productOverview.total.productCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.shippingCost ? formatAmount(data.productOverview.total.shippingCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.otherCost ? formatAmount(data.productOverview.total.otherCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 font-bold text-orange-800 dark:text-orange-300 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalCost != null ? formatAmount(data.productOverview.total.totalCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-rose-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-rose-400 px-6 py-4">{{ data.productOverview.total.refundAmount ? formatAmount(data.productOverview.total.refundAmount) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalPromotionFee ? formatAmount(data.productOverview.total.totalPromotionFee) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-amber-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-amber-400 px-6 py-4">{{ data.productOverview.total.brushFee ? formatAmount(data.productOverview.total.brushFee) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.feeRatio !== undefined ? formatPercentPlain(data.productOverview.total.feeRatio) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-indigo-700 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-indigo-400 px-6 py-4">{{ data.productOverview.total.roi !== undefined ? data.productOverview.total.roi.toFixed(2) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalProfitBeforeTax ? formatAmount(data.productOverview.total.totalProfitBeforeTax) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 italic text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.salesTaxAmount ? formatAmount(data.productOverview.total.salesTaxAmount) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.productCost ? formatCurrencyZhFromApi(data.productOverview.total.productCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.shippingCost ? formatCurrencyZhFromApi(data.productOverview.total.shippingCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.otherCost ? formatCurrencyZhFromApi(data.productOverview.total.otherCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 font-bold text-orange-800 dark:text-orange-300 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalCost != null ? formatCurrencyZhFromApi(data.productOverview.total.totalCost) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-rose-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-rose-400 px-6 py-4">{{ data.productOverview.total.refundAmount ? formatCurrencyZhFromApi(data.productOverview.total.refundAmount) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalPromotionFee ? formatCurrencyZhFromApi(data.productOverview.total.totalPromotionFee) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-amber-500 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-amber-400 px-6 py-4">{{ data.productOverview.total.brushFee ? formatCurrencyZhFromApi(data.productOverview.total.brushFee) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.feeRatio !== undefined ? formatFeeRatioPercent(data.productOverview.total.feeRatio) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 text-indigo-700 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-indigo-400 px-6 py-4">{{
formatNumberZhFromApiOptional(data.productOverview.total.roi)
}}</td>
<td class="sticky bottom-0 bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)] px-6 py-4">{{ data.productOverview.total.totalProfitBeforeTax ? formatCurrencyZhFromApi(data.productOverview.total.totalProfitBeforeTax) : '-' }}</td>
<td class="sticky bottom-0 bg-slate-100 italic text-slate-400 dark:bg-[hsl(240deg_3.7%_22%)] dark:text-[hsl(240deg_5%_64.9%)] px-6 py-4">{{ data.productOverview.total.salesTaxAmount ? formatCurrencyZhFromApi(data.productOverview.total.salesTaxAmount) : '-' }}</td>
<td
class="sticky bottom-0 bg-emerald-100 px-6 py-4 text-base dark:bg-emerald-950"
:class="(data.productOverview.total.profitAfterTax ?? 0) < 0 ? 'text-rose-600 dark:text-rose-400' : 'text-emerald-800 dark:text-emerald-300'"
>{{ data.productOverview.total.profitAfterTax ? formatAmount(data.productOverview.total.profitAfterTax) : '-' }}</td>
>{{
data.productOverview.total.profitAfterTax != null
? formatCurrencyZhFromApi(data.productOverview.total.profitAfterTax)
: '-'
}}</td>
</tr>
</tfoot>
</table>
@@ -1,16 +1,13 @@
<script lang="ts" setup>
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { formatCurrencyZhFromApiOptional } from '#/utils/shop-overview-display';
interface Props {
data: ShopVO.OverviewStatistics | null;
}
defineProps<Props>();
const formatAmount = (amount: number | undefined) => {
if (amount === undefined || amount === null) return '-';
return `¥${amount.toLocaleString('zh-CN')}`;
};
</script>
<template>
@@ -65,7 +62,7 @@ const formatAmount = (amount: number | undefined) => {
<span class="text-[10px] font-semibold text-slate-400 dark:text-[hsl(240deg_5%_55%)]">单</span>
</div>
<div class="text-[11px] font-semibold text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
{{ formatAmount(row.salesAmount) }}
{{ formatCurrencyZhFromApiOptional(row.salesAmount) }}
</div>
</div>
</div>
@@ -1,6 +1,12 @@
<script lang="ts" setup>
import type { ShopVO } from '#/api/ecommerce/shop/types';
import { formatFeeRatioPercent } from '#/utils/overview-fee-ratio';
import {
formatCurrencyZhFromApi,
formatNumberZhFromApiOptional,
} from '#/utils/shop-overview-display';
interface Props {
data: ShopVO.OverviewStatistics | null;
loading?: boolean;
@@ -8,10 +14,6 @@ interface Props {
defineProps<Props>();
const formatAmount = (amount: number) => {
return `¥${amount.toLocaleString('zh-CN')}`;
};
const formatPercentPlain = (value: number | undefined) => {
if (value === undefined) return '-';
return `${value.toFixed(1)}%`;
@@ -41,7 +43,11 @@ const formatPercent = (value: number | undefined) => {
</span>
</div>
<div class="text-4xl font-black leading-none text-slate-900 dark:text-[hsl(0deg_0%_95%)]">
{{ data?.totalSalesAmount ? formatAmount(data.totalSalesAmount) : '-' }}
{{
data?.totalSalesAmount != null
? formatCurrencyZhFromApi(data.totalSalesAmount)
: '-'
}}
</div>
<div
v-if="data?.salesAmountAchievementRate !== undefined"
@@ -93,7 +99,7 @@ const formatPercent = (value: number | undefined) => {
投资回报率 (ROI)
</div>
<div class="text-4xl font-black leading-none text-indigo-600 dark:text-indigo-400">
{{ data?.totalROI?.toFixed(2) || '-' }}
{{ formatNumberZhFromApiOptional(data?.totalROI) }}
</div>
<div
v-if="data?.averageFeeRatio !== undefined"
@@ -102,7 +108,7 @@ const formatPercent = (value: number | undefined) => {
<div class="flex justify-between text-xs font-bold">
<span class="text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">平均费比</span>
<span class="text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
{{ formatPercentPlain(data.averageFeeRatio) }}
{{ formatFeeRatioPercent(data.averageFeeRatio) }}
</span>
</div>
</div>
@@ -116,7 +122,11 @@ const formatPercent = (value: number | undefined) => {
店铺总净利润 (税后)
</div>
<div class="text-4xl font-black leading-none text-emerald-600 dark:text-emerald-400">
{{ data?.totalNetProfitAfterTax ? formatAmount(data.totalNetProfitAfterTax) : '-' }}
{{
data?.totalNetProfitAfterTax != null
? formatCurrencyZhFromApi(data.totalNetProfitAfterTax)
: '-'
}}
</div>
<div
v-if="data"
@@ -132,8 +142,8 @@ const formatPercent = (value: number | undefined) => {
"
>
{{
data.totalProfitBeforeTax !== undefined
? formatAmount(data.totalProfitBeforeTax)
data.totalProfitBeforeTax != null
? formatCurrencyZhFromApi(data.totalProfitBeforeTax)
: '-'
}}
</span>
@@ -142,8 +152,8 @@ const formatPercent = (value: number | undefined) => {
<div class="text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">税额</div>
<div class="text-rose-500 dark:text-rose-400">
{{
data.totalTaxAmount !== undefined
? `-${formatAmount(data.totalTaxAmount)}`
data.totalTaxAmount != null
? `-${formatCurrencyZhFromApi(data.totalTaxAmount)}`
: '-'
}}
</div>