feat: 公司/店铺概览对比表增加商品成本和其他成本字段

CompanyOverviewVO.ShopComparison: 加 productCost、otherCost 字段
ShopOverviewStatisticsVO.ProductComparison: 加 productCost、otherCost 字段
CompanyOverviewServiceImpl / ShopOverviewStatisticsServiceImpl: 分别计算并赋值
前端 API 类型同步更新
公司概览 + 店铺概览页面表格:成本运费列拆为商品成本/运费/其他成本三列
This commit is contained in:
小蟑螂
2026-04-15 22:40:37 +08:00
parent f57b3ebb29
commit 03cf396aea
8 changed files with 152 additions and 18 deletions
@@ -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;
@@ -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;
@@ -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);
@@ -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);