feat(ecom): 产品概况增加总成本字段及按自动统计状态过滤订单

- CompanyOverviewVO 新增 totalCost 字段(商品成本+运费+其他成本)
- ProductOverviewServiceImpl 查询订单时仅统计 autoStatistics=1 的订单状态
- 同步前端 types.vo.ts 及各组件展示总成本
- SQL 迁移文件整理至 sql/migration/ 目录
This commit is contained in:
小蟑螂
2026-05-05 12:06:09 +08:00
parent 17bbae66a1
commit 44662a4790
14 changed files with 116 additions and 51 deletions
@@ -117,6 +117,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */
refundAmount?: number;
/** 推广费 */
@@ -153,6 +155,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */
refundAmount?: number;
/** 推广费 */
@@ -197,6 +201,8 @@ export namespace CompanyOverviewVO {
shippingCost?: number;
/** 其他成本 */
otherCost?: number;
/** 总成本(商品成本+运费+其他成本) */
totalCost?: number;
/** 退款金额 */
refundAmount?: number;
/** 推广费 */
@@ -131,7 +131,7 @@ const formatPercentPlain = (value: number | undefined) => {
经营规模维度
</th>
<th
colspan="7"
colspan="8"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
>
成本费用维度
@@ -152,6 +152,7 @@ const formatPercentPlain = (value: number | undefined) => {
<th class="border-b border-l px-6 py-4">商品成本</th>
<th class="border-b px-6 py-4">运费</th>
<th class="border-b px-6 py-4">其他成本</th>
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
退款金额
</th>
@@ -214,6 +215,9 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ cat.productCost ? formatAmount(cat.productCost) : '-' }}</td>
<td class="p-6">{{ cat.shippingCost ? formatAmount(cat.shippingCost) : '-' }}</td>
<td class="p-6">{{ 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="p-6 font-bold text-rose-600 dark:text-rose-400">
{{ cat.refundAmount ? formatAmount(cat.refundAmount) : '-' }}
</td>
@@ -238,7 +242,7 @@ const formatPercentPlain = (value: number | undefined) => {
</td>
</tr>
<tr v-if="!categoryComparisons?.categories?.length">
<td :colspan="categoryExportMode ? 16 : 15" class="p-8 text-center text-gray-400">
<td :colspan="categoryExportMode ? 18 : 17" class="p-8 text-center text-gray-400">
暂无数据
</td>
</tr>
@@ -255,6 +259,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ categoryComparisons?.total?.productCost ? formatAmount(categoryComparisons?.total?.productCost) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.shippingCost ? formatAmount(categoryComparisons?.total?.shippingCost) : '-' }}</td>
<td class="p-6">{{ categoryComparisons?.total?.otherCost ? formatAmount(categoryComparisons?.total?.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ categoryComparisons?.total?.totalCost != null ? formatAmount(categoryComparisons?.total?.totalCost) : '-' }}</td>
<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>
@@ -58,6 +58,7 @@ const platformData = computed(() => {
productCost: p.productCost ?? 0,
shippingCost: p.shippingCost ?? 0,
otherCost: p.otherCost ?? 0,
totalCost: p.totalCost ?? 0,
refundAmount: p.refundAmount ?? 0,
totalPromotionFee: p.totalPromotionFee ?? 0,
brushFee: p.brushFee ?? 0,
@@ -191,7 +192,7 @@ const sortedData = computed(() => {
</th>
<!-- 成本 -->
<th
colspan="7"
colspan="8"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] p-3 text-center bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] text-orange-700 dark:text-orange-400"
>
成本费用维度
@@ -218,6 +219,7 @@ const sortedData = computed(() => {
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">运费</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">其他成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 font-bold text-rose-600 dark:text-rose-400">退款金额</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4">推广费</th>
<th class="border-b border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] px-6 py-4 text-orange-600 dark:text-orange-400">刷单费用</th>
@@ -275,6 +277,7 @@ const sortedData = computed(() => {
<td class="p-6">{{ formatAmount(p.productCost) }}</td>
<td class="p-6">{{ formatAmount(p.shippingCost) }}</td>
<td class="p-6">{{ formatAmount(p.otherCost) }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ formatAmount(p.totalCost) }}</td>
<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>
@@ -310,6 +313,7 @@ const sortedData = computed(() => {
<td class="p-6">{{ totalData.productCost ? formatAmount(totalData.productCost) : '-' }}</td>
<td class="p-6">{{ totalData.shippingCost ? formatAmount(totalData.shippingCost) : '-' }}</td>
<td class="p-6">{{ totalData.otherCost ? formatAmount(totalData.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ totalData.totalCost != null ? formatAmount(totalData.totalCost) : '-' }}</td>
<td class="p-6 text-rose-600 dark:text-rose-400">{{ totalData.refundAmount ? formatAmount(totalData.refundAmount) : '-' }}</td>
<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>
@@ -335,7 +339,7 @@ const sortedData = computed(() => {
</tfoot>
<tfoot v-else class="bg-slate-100 dark:bg-[hsl(240deg_3.7%_22%)]">
<tr class="text-center text-slate-400 dark:text-[hsl(240deg_5%_64.9%)]">
<td :colspan="platformExportMode ? 20 : 19" class="p-6">暂无数据</td>
<td :colspan="platformExportMode ? 22 : 21" class="p-6">暂无数据</td>
</tr>
</tfoot>
</table>
@@ -142,7 +142,7 @@ const formatPercentPlain = (value: number | undefined) => {
经营规模维度
</th>
<th
colspan="7"
colspan="8"
class="border-b border-l border-slate-200 dark:border-b-[hsl(240deg_3.7%_22%)] dark:border-l-[hsl(240deg_3.7%_22%)] dark:border-[hsl(240deg_3.7%_22%)] bg-orange-50/50 dark:bg-[hsl(24deg_9.8%_15%/50%)] p-3 text-center text-orange-700 dark:text-orange-400"
>
成本费用维度
@@ -170,6 +170,7 @@ const formatPercentPlain = (value: number | undefined) => {
<th class="border-b border-l border-slate-200 dark:border-[hsl(240deg_3.7%_22%)] px-6 py-4">商品成本</th>
<th class="border-b px-6 py-4">运费</th>
<th class="border-b px-6 py-4">其他成本</th>
<th class="border-b px-6 py-4 font-bold text-orange-800 dark:text-orange-300">总成本</th>
<th class="border-b px-6 py-4 font-bold text-rose-600 dark:text-rose-400">
退款金额
</th>
@@ -280,6 +281,11 @@ const formatPercentPlain = (value: number | undefined) => {
shop.otherCost ? formatAmount(shop.otherCost) : '-'
}}
</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">
{{
shop.totalCost != null ? formatAmount(shop.totalCost) : '-'
}}
</td>
<td class="p-6 font-bold text-rose-600 dark:text-rose-400">
{{
shop.refundAmount ? formatAmount(shop.refundAmount) : '-'
@@ -329,7 +335,7 @@ const formatPercentPlain = (value: number | undefined) => {
</td>
</tr>
<tr v-if="!shopComparisons?.shops?.length">
<td colspan="17" class="p-8 text-center text-gray-400">
<td :colspan="shopExportMode ? 22 : 21" class="p-8 text-center text-gray-400">
暂无数据
</td>
</tr>
@@ -351,6 +357,7 @@ const formatPercentPlain = (value: number | undefined) => {
<td class="p-6">{{ shopComparisons?.total?.productCost ? formatAmount(shopComparisons?.total?.productCost) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.shippingCost ? formatAmount(shopComparisons?.total?.shippingCost) : '-' }}</td>
<td class="p-6">{{ shopComparisons?.total?.otherCost ? formatAmount(shopComparisons?.total?.otherCost) : '-' }}</td>
<td class="p-6 font-bold text-orange-800 dark:text-orange-300">{{ shopComparisons?.total?.totalCost != null ? formatAmount(shopComparisons?.total?.totalCost) : '-' }}</td>
<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>