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 () => {