From 03cf396aea7ae5497bffd3c7438ce260ddb4d634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Wed, 15 Apr 2026 22:40:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=AC=E5=8F=B8/=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=A6=82=E8=A7=88=E5=AF=B9=E6=AF=94=E8=A1=A8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=95=86=E5=93=81=E6=88=90=E6=9C=AC=E5=92=8C=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E6=88=90=E6=9C=AC=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CompanyOverviewVO.ShopComparison: 加 productCost、otherCost 字段 ShopOverviewStatisticsVO.ProductComparison: 加 productCost、otherCost 字段 CompanyOverviewServiceImpl / ShopOverviewStatisticsServiceImpl: 分别计算并赋值 前端 API 类型同步更新 公司概览 + 店铺概览页面表格:成本运费列拆为商品成本/运费/其他成本三列 --- .../overview/model/vo/CompanyOverviewVO.java | 8 ++- .../model/vo/ShopOverviewStatisticsVO.java | 8 ++- .../impl/CompanyOverviewServiceImpl.java | 22 +++++++- .../ShopOverviewStatisticsServiceImpl.java | 22 +++++++- .../company-overview/types/types.vo.ts | 6 ++- .../src/api/ecommerce/shop/types/types.vo.ts | 6 ++- .../dashboard/company-overview/index.vue | 47 ++++++++++++++--- .../views/ecommerce/shop/overview/index.vue | 51 ++++++++++++++++--- 8 files changed, 152 insertions(+), 18 deletions(-) diff --git a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/CompanyOverviewVO.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/CompanyOverviewVO.java index e93bf0cb..2ecd916e 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/CompanyOverviewVO.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/model/vo/CompanyOverviewVO.java @@ -186,9 +186,15 @@ public class CompanyOverviewVO { @Schema(description = "客单价", example = "100.00") private BigDecimal averageOrderValue; - @Schema(description = "成本运费", example = "5000.00") + @Schema(description = "商品成本", example = "3000.00") + private BigDecimal productCost; + + @Schema(description = "运费", example = "1000.00") private BigDecimal shippingCost; + @Schema(description = "其他成本", example = "1000.00") + private BigDecimal otherCost; + @Schema(description = "退款金额", example = "1000.00") private BigDecimal refundAmount; 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 ae463b10..a345deab 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 @@ -147,9 +147,15 @@ public class ShopOverviewStatisticsVO { @Schema(description = "客单价", example = "100.00") private BigDecimal averageOrderValue; - @Schema(description = "成本运费", example = "5000.00") + @Schema(description = "商品成本", example = "3000.00") + private BigDecimal productCost; + + @Schema(description = "运费", example = "1000.00") private BigDecimal shippingCost; + @Schema(description = "其他成本", example = "1000.00") + private BigDecimal otherCost; + @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/CompanyOverviewServiceImpl.java b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java index d7d9f465..0fdadf59 100644 --- a/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java +++ b/ecom-dmb-backend/src/main/java/top/xyquan/ecomdmbbackend/modules/ecom/overview/service/impl/CompanyOverviewServiceImpl.java @@ -471,7 +471,16 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { .map(fee -> fee.getFeeAmount() != null ? fee.getFeeAmount() : BigDecimal.ZERO) .reduce(BigDecimal.ZERO, BigDecimal::add); - // 计算成本运费(单独计算运费成本) + // 计算商品成本 + BigDecimal productCost = shopOrders.stream() + .map(order -> { + BigDecimal cost = order.getProductCost() != null ? order.getProductCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return cost.multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 计算运费成本 BigDecimal shippingCost = shopOrders.stream() .map(order -> { BigDecimal cost = order.getShippingCost() != null ? order.getShippingCost() : BigDecimal.ZERO; @@ -480,6 +489,15 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { }) .reduce(BigDecimal.ZERO, BigDecimal::add); + // 计算其他成本 + BigDecimal otherCost = shopOrders.stream() + .map(order -> { + BigDecimal cost = order.getOtherCost() != null ? order.getOtherCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return cost.multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalCost = calculateShopTotalCost(shopOrders); BigDecimal profitBeforeTax = salesAmount.subtract(totalCost).subtract(refundAmount); @@ -540,7 +558,9 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService { comparison.setSalesAmount(salesAmount); comparison.setOrderCount(orderCount); comparison.setAverageOrderValue(averageOrderValue); + comparison.setProductCost(productCost); comparison.setShippingCost(shippingCost); + comparison.setOtherCost(otherCost); comparison.setRefundAmount(refundAmount); comparison.setTotalPromotionFee(totalPromotionFee); comparison.setBrushFee(brushFee); 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 d2a7ba2b..0527fd0f 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 @@ -380,7 +380,16 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics productPromotionFee = totalPromotionFee.multiply(ratio); } - // 计算成本运费(单独计算运费成本) + // 计算商品成本 + BigDecimal productCost = productOrders.stream() + .map(order -> { + BigDecimal cost = order.getProductCost() != null ? order.getProductCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return cost.multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 计算运费成本 BigDecimal shippingCost = productOrders.stream() .map(order -> { BigDecimal cost = order.getShippingCost() != null ? order.getShippingCost() : BigDecimal.ZERO; @@ -389,6 +398,15 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics }) .reduce(BigDecimal.ZERO, BigDecimal::add); + // 计算其他成本 + BigDecimal otherCost = productOrders.stream() + .map(order -> { + BigDecimal cost = order.getOtherCost() != null ? order.getOtherCost() : BigDecimal.ZERO; + Integer quantity = order.getQuantity() != null ? order.getQuantity() : 1; + return cost.multiply(new BigDecimal(quantity)); + }) + .reduce(BigDecimal.ZERO, BigDecimal::add); + BigDecimal totalCost = calculateProductTotalCost(productOrders); BigDecimal profitBeforeTax = salesAmount.subtract(totalCost).subtract(refundAmount); @@ -418,7 +436,9 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics comparison.setSalesAmount(salesAmount); comparison.setOrderCount(orderCount); comparison.setAverageOrderValue(averageOrderValue); + comparison.setProductCost(productCost); comparison.setShippingCost(shippingCost); + comparison.setOtherCost(otherCost); comparison.setRefundAmount(refundAmount); comparison.setTotalPromotionFee(productPromotionFee); comparison.setBrushFee(brushFee); diff --git a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/company-overview/types/types.vo.ts b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/company-overview/types/types.vo.ts index 5a55882d..b62ed535 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/company-overview/types/types.vo.ts +++ b/ecom-dmb-frontend/apps/web-antd/src/api/ecommerce/company-overview/types/types.vo.ts @@ -87,8 +87,12 @@ export namespace CompanyOverviewVO { orderCount?: number; /** 客单价 */ averageOrderValue?: number; - /** 成本运费 */ + /** 商品成本 */ + productCost?: number; + /** 运费 */ shippingCost?: number; + /** 其他成本 */ + otherCost?: 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 f1fb012d..2cdabf7f 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 @@ -159,8 +159,12 @@ export namespace ShopVO { orderCount?: number; /** 客单价 */ averageOrderValue?: number; - /** 成本运费 */ + /** 商品成本 */ + productCost?: number; + /** 运费 */ shippingCost?: number; + /** 其他成本 */ + otherCost?: number; /** 退款金额 */ refundAmount?: number; /** 推广费 */ diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/company-overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/company-overview/index.vue index 570cd1cf..61e3e6de 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/company-overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/dashboard/company-overview/index.vue @@ -59,6 +59,19 @@ watch(taxRate, (val) => { loadOverviewData(); }); +const formatTaxRate = (value: null | number | string | undefined) => { + if (value === null || value === undefined || value === '') return ''; + const num = Number(value); + if (!Number.isFinite(num)) return ''; + return `${num * 100}%`; +}; + +const parseTaxRate = (value: string | undefined) => { + if (!value) return 0; + const num = Number(value.replace('%', '').trim()); + return Number.isFinite(num) ? num / 100 : 0; +}; + // 当前选中的时间范围类型 const activeTimeRange = ref< '7days' | '30days' | 'custom' | 'today' | 'yesterday' @@ -595,7 +608,10 @@ const handleExportSelectedShops = async () => {
-
+
+ 税率 { :step="0.01" :precision="2" size="small" - class="!w-16 !border-none !bg-transparent !text-sm !font-bold" - :formatter="(val: number) => `${Number(val) * 100}%`" - :parser="(val: string) => String(Number(val.replace('%', '')) / 100)" + class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-white/30 !text-sm !font-bold" + :formatter="formatTaxRate" + :parser="parseTaxRate" />
@@ -680,7 +696,7 @@ const handleExportSelectedShops = async () => { format="YYYY-MM-DD" :allow-clear="false" :placeholder="['开始', '结束']" - class="!border-none !bg-transparent !text-sm !font-bold" + class="!h-8 !border-none !bg-transparent !text-sm !font-bold" @change="handleCustomDateRangeChange" />
@@ -985,7 +1001,9 @@ const handleExportSelectedShops = async () => { 单量 客单价 - 成本运费 + 商品成本 + 运费 + 其他成本 退款金额 @@ -1075,11 +1093,21 @@ const handleExportSelectedShops = async () => { }} + + {{ + shop.productCost ? formatAmount(shop.productCost) : '-' + }} + {{ shop.shippingCost ? formatAmount(shop.shippingCost) : '-' }} + + {{ + shop.otherCost ? formatAmount(shop.otherCost) : '-' + }} + {{ shop.refundAmount ? formatAmount(shop.refundAmount) : '-' @@ -1163,4 +1191,11 @@ const handleExportSelectedShops = async () => { left: 0; z-index: 10; } + +:deep(.tax-rate-input .ant-input-number-input) { + height: 32px; + line-height: 32px; + padding-top: 0; + padding-bottom: 0; +} diff --git a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue index 5c08da75..e497532e 100644 --- a/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue +++ b/ecom-dmb-frontend/apps/web-antd/src/views/ecommerce/shop/overview/index.vue @@ -70,6 +70,19 @@ watch(taxRate, (val) => { loadOverviewData(); }); +const formatTaxRate = (value: null | number | string | undefined) => { + if (value === null || value === undefined || value === '') return ''; + const num = Number(value); + if (!Number.isFinite(num)) return ''; + return `${num * 100}%`; +}; + +const parseTaxRate = (value: string | undefined) => { + if (!value) return 0; + const num = Number(value.replace('%', '').trim()); + return Number.isFinite(num) ? num / 100 : 0; +}; + // 切换时间范围 const switchTimeRange = ( type: '7days' | '30days' | 'custom' | 'today' | 'yesterday', @@ -722,7 +735,10 @@ onActivated(async () => {
-
+
+ 税率 { :step="0.01" :precision="2" size="small" - class="!w-16 !border-none !bg-transparent !text-sm !font-bold" - :formatter="(val: number) => `${Number(val) * 100}%`" - :parser="(val: string) => String(Number(val.replace('%', '')) / 100)" + class="tax-rate-input !h-8 !w-20 !rounded-lg !border-none !bg-white/30 !text-sm !font-bold" + :formatter="formatTaxRate" + :parser="parseTaxRate" />
@@ -803,7 +819,7 @@ onActivated(async () => { format="YYYY-MM-DD" :allow-clear="false" :placeholder="['开始日期', '结束日期']" - class="!cursor-pointer !border-none !bg-transparent !text-sm !font-bold" + class="!h-8 !cursor-pointer !border-none !bg-transparent !text-sm !font-bold" @change="handleCustomDateRangeChange" />
@@ -1112,7 +1128,9 @@ onActivated(async () => { 单量 客单价 - 成本运费 + 商品成本 + 运费 + 其他成本 退款金额 推广费 刷单费用 @@ -1163,6 +1181,13 @@ onActivated(async () => { }} + + {{ + product.productCost + ? formatAmount(product.productCost) + : '-' + }} + {{ product.shippingCost @@ -1170,6 +1195,13 @@ onActivated(async () => { : '-' }} + + {{ + product.otherCost + ? formatAmount(product.otherCost) + : '-' + }} + {{ product.refundAmount @@ -1307,4 +1339,11 @@ onActivated(async () => { left: 0; z-index: 10; } + +:deep(.tax-rate-input .ant-input-number-input) { + height: 32px; + line-height: 32px; + padding-top: 0; + padding-bottom: 0; +}