fix: 店铺概览统计 ROI 计算精度统一改为两位小数

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
小蟑螂
2026-05-08 12:40:03 +08:00
co-authored by Claude Opus 4.7
parent 654758bf0a
commit 840914d695
@@ -379,7 +379,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
if (promotionFee == null || promotionFee.compareTo(BigDecimal.ZERO) <= 0) { if (promotionFee == null || promotionFee.compareTo(BigDecimal.ZERO) <= 0) {
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
return netSales.divide(promotionFee, 4, RoundingMode.HALF_UP); return netSales.divide(promotionFee, 2, RoundingMode.HALF_UP);
} }
/** /**
@@ -389,7 +389,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
if (totalCost.compareTo(BigDecimal.ZERO) <= 0) { if (totalCost.compareTo(BigDecimal.ZERO) <= 0) {
return BigDecimal.ZERO; return BigDecimal.ZERO;
} }
return profit.divide(totalCost, 4, RoundingMode.HALF_UP); return profit.divide(totalCost, 2, RoundingMode.HALF_UP);
} }
private Map<Long, Long> orderSpecIdToProductIdMap(List<OrderPO> orders) { private Map<Long, Long> orderSpecIdToProductIdMap(List<OrderPO> orders) {
@@ -598,7 +598,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
BigDecimal salesTax = totalSales.multiply(taxRate); BigDecimal salesTax = totalSales.multiply(taxRate);
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax); BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0 BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP) ? totalSales.subtract(totalRefund).divide(totalPromoFee, 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO; : BigDecimal.ZERO;
BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0 BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP) ? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)
@@ -915,7 +915,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
BigDecimal salesTax = totalSales.multiply(taxRate); BigDecimal salesTax = totalSales.multiply(taxRate);
BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax); BigDecimal profitAfterTax = profitBeforeTax.subtract(salesTax);
BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0 BigDecimal roi = totalPromoFee.compareTo(BigDecimal.ZERO) > 0
? totalSales.subtract(totalRefund).divide(totalPromoFee, 4, RoundingMode.HALF_UP) ? totalSales.subtract(totalRefund).divide(totalPromoFee, 2, RoundingMode.HALF_UP)
: BigDecimal.ZERO; : BigDecimal.ZERO;
BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0 BigDecimal feeRatio = totalSales.compareTo(BigDecimal.ZERO) > 0
? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP) ? totalPromoFee.add(totalBrushFee).divide(totalSales, 4, RoundingMode.HALF_UP)