From 31dc0cb2a187819bf2534fe8efd747a56ffcf421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Tue, 5 May 2026 12:14:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(ecom):=20=E4=BA=A7=E5=93=81=E6=A6=82?= =?UTF-8?q?=E5=86=B5=E5=90=8C=E6=AD=A5=E5=A2=9E=E5=8A=A0=E6=80=BB=E6=88=90?= =?UTF-8?q?=E6=9C=AC=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ProductOverviewVO.SpecSummaryItem 和 SpecSummaryTotal 新增 totalCost 字段 - ShopOverviewStatisticsVO 也新增 totalCost - ProductOverviewServiceImpl / ShopOverviewStatisticsServiceImpl 计算并赋值总成本 - 前端 types.vo.ts 及各表格组件同步展示 --- .../model/vo/ShopOverviewStatisticsVO.java | 6 ++ .../ShopOverviewStatisticsServiceImpl.java | 4 ++ .../overview/model/vo/ProductOverviewVO.java | 12 ++++ .../impl/ProductOverviewServiceImpl.java | 5 ++ .../service/impl/ShopExportServiceImpl.java | 21 +++--- .../product-overview/types/types.vo.ts | 4 ++ .../src/api/ecommerce/shop/types/types.vo.ts | 4 ++ .../overview/components/SpecSummaryTable.vue | 68 +++++++++++++------ .../ecommerce/product/overview/index.vue | 3 +- .../components/CategoryComparisonTable.vue | 7 +- .../components/ProductComparisonTable.vue | 10 ++- 11 files changed, 108 insertions(+), 36 deletions(-) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java index 3b218ab7..e4c43050 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/ShopOverviewStatisticsVO.java @@ -204,6 +204,9 @@ public class ShopOverviewStatisticsVO { @Schema(description = "其他成本", example = "1000.00") private BigDecimal otherCost; + @Schema(description = "总成本(商品成本+运费+其他成本)", example = "5000.00") + private BigDecimal totalCost; + @Schema(description = "退款金额", example = "1000.00") private BigDecimal refundAmount; @@ -259,6 +262,9 @@ public class ShopOverviewStatisticsVO { @Schema(description = "其他成本", example = "1000.00") private BigDecimal otherCost; + @Schema(description = "总成本(商品成本+运费+其他成本)", example = "5000.00") + private BigDecimal totalCost; + @Schema(description = "退款金额", example = "1000.00") private BigDecimal refundAmount; diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java index 446f936d..ab83882a 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/ShopOverviewStatisticsServiceImpl.java @@ -510,6 +510,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics comparison.setProductCost(productCost); comparison.setShippingCost(shippingCost); comparison.setOtherCost(otherCost); + comparison.setTotalCost(productCost.add(shippingCost).add(otherCost)); comparison.setRefundAmount(refundAmount); comparison.setTotalPromotionFee(productPromotionFee); comparison.setBrushFee(brushFee); @@ -581,6 +582,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics total.setProductCost(totalProductCost); total.setShippingCost(totalShippingCost); total.setOtherCost(totalOtherCost); + total.setTotalCost(totalCost); total.setRefundAmount(totalRefund); total.setTotalPromotionFee(totalPromoFee); total.setBrushFee(totalBrushFee); @@ -842,6 +844,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics cc.setProductCost(productCost); cc.setShippingCost(shippingCost); cc.setOtherCost(otherCost); + cc.setTotalCost(totalCost); cc.setRefundAmount(refundAmount); cc.setTotalPromotionFee(catPromotionFee); cc.setBrushFee(catBrushFee); @@ -912,6 +915,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics total.setProductCost(totalProductCost); total.setShippingCost(totalShippingCost); total.setOtherCost(totalOtherCost); + total.setTotalCost(totalCost); total.setRefundAmount(totalRefund); total.setTotalPromotionFee(totalPromoFee); total.setBrushFee(totalBrushFee); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/model/vo/ProductOverviewVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/model/vo/ProductOverviewVO.java index 966ddaf1..2d1f369d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/model/vo/ProductOverviewVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/model/vo/ProductOverviewVO.java @@ -255,6 +255,12 @@ public class ProductOverviewVO { @Schema(description = "其他成本") private BigDecimal otherCost; + /** + * 总成本(商品成本+运费+其他成本) + */ + @Schema(description = "总成本(商品成本+运费+其他成本)") + private BigDecimal totalCost; + /** * 退款金额 */ @@ -340,6 +346,12 @@ public class ProductOverviewVO { @Schema(description = "其他成本") private BigDecimal otherCost; + /** + * 总成本(商品成本+运费+其他成本) + */ + @Schema(description = "总成本(商品成本+运费+其他成本)") + private BigDecimal totalCost; + /** * 退款金额 */ diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java index ec8ec7ba..f31c59bb 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/product/overview/service/impl/ProductOverviewServiceImpl.java @@ -521,6 +521,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { item.setProductCost(productCostTotal); item.setShippingCost(shippingCostTotal); item.setOtherCost(otherCostTotal); + item.setTotalCost(productCostTotal.add(shippingCostTotal).add(otherCostTotal)); item.setRefundAmount(refundAmount); item.setPromotionFee(specPromotionFee); item.setFeeRatio(feeRatio.multiply(new BigDecimal("100")) @@ -551,6 +552,9 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { total.setOtherCost(specItems.stream() .map(ProductOverviewVO.SpecSummaryItem::getOtherCost) .reduce(BigDecimal.ZERO, BigDecimal::add)); + total.setTotalCost(specItems.stream() + .map(ProductOverviewVO.SpecSummaryItem::getTotalCost) + .reduce(BigDecimal.ZERO, BigDecimal::add)); total.setRefundAmount(specItems.stream() .map(ProductOverviewVO.SpecSummaryItem::getRefundAmount) .reduce(BigDecimal.ZERO, BigDecimal::add)); @@ -600,6 +604,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService { total.setProductCost(BigDecimal.ZERO); total.setShippingCost(BigDecimal.ZERO); total.setOtherCost(BigDecimal.ZERO); + total.setTotalCost(BigDecimal.ZERO); total.setRefundAmount(BigDecimal.ZERO); total.setPromotionFee(BigDecimal.ZERO); total.setFeeRatio(BigDecimal.ZERO); diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopExportServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopExportServiceImpl.java index c284154e..0e26e85d 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopExportServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/shop/service/impl/ShopExportServiceImpl.java @@ -196,7 +196,6 @@ public class ShopExportServiceImpl implements ShopExportService { Cell titleCell = titleRow.createCell(0); titleCell.setCellValue("核心商品多维度损益汇总表 | " + dateRangeLabel); titleCell.setCellStyle(createTitleStyle(sheet.getWorkbook())); - sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 12)); CellStyle headerStyle = createHeaderStyle(sheet.getWorkbook()); CellStyle dataStyle = createDataStyle(sheet.getWorkbook()); @@ -204,9 +203,10 @@ public class ShopExportServiceImpl implements ShopExportService { String taxLabel = (taxRate.multiply(new BigDecimal("100")).setScale(0, RoundingMode.HALF_UP)).toPlainString() + "%税额"; String[] headers = { "商品详情", "销售额", "单量", "客单价", - "商品成本", "运费", "其他成本", "退款金额", "推广费", "刷单费用", + "商品成本", "运费", "其他成本", "总成本", "退款金额", "推广费", "刷单费用", "费比(%)", "单品ROI", "税前盈亏", taxLabel, "税后净利" }; + sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, headers.length - 1)); Row headerRow = sheet.createRow(1); for (int i = 0; i < headers.length; i++) { @@ -225,14 +225,15 @@ public class ShopExportServiceImpl implements ShopExportService { setCell(row, 4, nvl(p.getProductCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); setCell(row, 5, nvl(p.getShippingCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); setCell(row, 6, nvl(p.getOtherCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 7, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 8, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 9, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 10, nvl(p.getFeeRatio(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 11, nvl(p.getRoi(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 12, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 13, nvl(p.getSalesTaxAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); - setCell(row, 14, nvl(p.getProfitAfterTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 7, nvl(p.getTotalCost(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 8, nvl(p.getRefundAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 9, nvl(p.getTotalPromotionFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 10, nvl(p.getBrushFee(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 11, nvl(p.getFeeRatio(), BigDecimal.ZERO).setScale(4, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 12, nvl(p.getRoi(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 13, nvl(p.getTotalProfitBeforeTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 14, nvl(p.getSalesTaxAmount(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); + setCell(row, 15, nvl(p.getProfitAfterTax(), BigDecimal.ZERO).setScale(2, RoundingMode.HALF_UP).doubleValue(), dataStyle); } sheet.setColumnWidth(0, 5000); diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/product-overview/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/product-overview/types/types.vo.ts index 2b67b6ce..47e78fca 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/product-overview/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/product-overview/types/types.vo.ts @@ -37,6 +37,8 @@ export namespace ProductOverviewVO { shippingCost: number; /** 其他成本 */ otherCost: number; + /** 总成本(商品成本+运费+其他成本) */ + totalCost?: number; /** 退款金额 */ refundAmount: number; /** 推广费 */ @@ -67,6 +69,8 @@ export namespace ProductOverviewVO { shippingCost: number; /** 其他成本 */ otherCost: number; + /** 总成本(商品成本+运费+其他成本) */ + totalCost?: number; /** 退款金额 */ refundAmount: number; /** 推广费 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts index 189acbe9..34e507b5 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/shop/types/types.vo.ts @@ -123,6 +123,8 @@ export namespace ShopVO { shippingCost?: number; /** 其他成本 */ otherCost?: number; + /** 总成本(商品成本+运费+其他成本) */ + totalCost?: number; /** 退款金额 */ refundAmount?: number; /** 推广费 */ @@ -159,6 +161,8 @@ export namespace ShopVO { shippingCost?: number; /** 其他成本 */ otherCost?: number; + /** 总成本(商品成本+运费+其他成本) */ + totalCost?: number; /** 退款金额 */ refundAmount?: number; /** 推广费 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/SpecSummaryTable.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/SpecSummaryTable.vue index cee7b627..8e6deaa7 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/SpecSummaryTable.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/product/overview/components/SpecSummaryTable.vue @@ -1,4 +1,8 @@