fix: 统一盈亏字段精度为 2 位小数;修复 sub_plan_pricing.status 拼写错误

- CompanyOverviewServiceImpl / CategoryExportExcelServiceImpl / ExportServiceImpl / ShopOverviewStatisticsServiceImpl / ProductOverviewServiceImpl:所有 profitAfterTax / netProfit 等盈亏字段统一 setScale(2, RoundingMode.HALF_UP),避免 JSON 序列化时出现过多小数位
- sub_design.sql:stauts → status 拼写修正
- 前端:品类/商品排行榜/概览卡片等表格 feeRatio / roi 等数值精度统一展示处理
This commit is contained in:
小蟑螂
2026-05-07 22:04:13 +08:00
parent d8da5a1b33
commit 061737a984
20 changed files with 205 additions and 129 deletions
@@ -229,7 +229,7 @@ public class CategoryExportExcelServiceImpl implements CategoryExportExcelServic
data.setFeeRatio(feeRatio);
data.setTotalProfitBeforeTax(profitBeforeTax);
data.setSalesTaxAmount(salesTaxAmount);
data.setProfitAfterTax(profitAfterTax);
data.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
data.setRoi(roi);
categoryDataList.add(data);
}
@@ -212,7 +212,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
.subtract(totalPromotionFee)
.subtract(totalBrushFee);
BigDecimal totalTaxAmount = totalSalesAmount.multiply(taxRate);
BigDecimal totalNetProfitAfterTax = totalProfitBeforeTax.subtract(totalTaxAmount);
BigDecimal totalNetProfitAfterTax = totalProfitBeforeTax.subtract(totalTaxAmount).setScale(2, RoundingMode.HALF_UP);
overviewVO.setTotalNetProfitAfterTax(totalNetProfitAfterTax);
overviewVO.setTotalTaxAmount(totalTaxAmount);
@@ -459,7 +459,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
shopQuadrant.setShopId(shop.getId());
shopQuadrant.setShopName(shop.getName());
shopQuadrant.setRoi(roi);
shopQuadrant.setNetProfit(netProfit);
shopQuadrant.setNetProfit(netProfit.setScale(2, RoundingMode.HALF_UP));
shopQuadrant.setQuadrant(quadrant);
quadrants.add(shopQuadrant);
}
@@ -611,7 +611,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
comparison.setFeeRatio(feeRatio);
comparison.setTotalProfitBeforeTax(profitBeforeTax);
comparison.setSalesTaxAmount(salesTaxAmount);
comparison.setProfitAfterTax(profitAfterTax);
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
comparison.setRoi(roi);
comparisons.add(comparison);
}
@@ -700,7 +700,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setTotalProfitBeforeTax(profitBeforeTax);
total.setSalesTaxAmount(salesTax);
total.setRoi(roi);
total.setProfitAfterTax(profitAfterTax);
total.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return total;
}
@@ -918,7 +918,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
comparison.setFeeRatio(feeRatio);
comparison.setTotalProfitBeforeTax(profitBeforeTax);
comparison.setSalesTaxAmount(salesTaxAmount);
comparison.setProfitAfterTax(profitAfterTax);
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
comparison.setRoi(roi);
comparisons.add(comparison);
}
@@ -991,7 +991,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setTotalProfitBeforeTax(profitBeforeTax);
total.setSalesTaxAmount(salesTax);
total.setRoi(roi);
total.setProfitAfterTax(profitAfterTax);
total.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return total;
}
@@ -1191,7 +1191,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
platformSummary.setTotalProfitBeforeTax(profitBeforeTax);
platformSummary.setSalesTaxAmount(salesTaxAmount);
platformSummary.setRoi(roi);
platformSummary.setProfitAfterTax(profitAfterTax);
platformSummary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
platformSummaries.add(platformSummary);
}
@@ -1290,7 +1290,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
total.setTotalProfitBeforeTax(profitBeforeTax);
total.setSalesTaxAmount(salesTax);
total.setRoi(roi);
total.setProfitAfterTax(profitAfterTax);
total.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return total;
}
@@ -1413,7 +1413,7 @@ public class CompanyOverviewServiceImpl implements CompanyOverviewService {
summary.setTotalProfitBeforeTax(profitBeforeTax);
summary.setSalesTaxAmount(salesTaxAmount);
summary.setRoi(roi);
summary.setProfitAfterTax(profitAfterTax);
summary.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return summary;
}
@@ -471,7 +471,7 @@ public class ExportServiceImpl implements ExportService {
data.put("totalCost", totalCost);
data.put("totalProfitBeforeTax", profitBeforeTax); // 对齐 ShopComparison
data.put("salesTaxAmount", tax); // 对齐 ShopComparison
data.put("profitAfterTax", profitAfterTax);
data.put("profitAfterTax", profitAfterTax.setScale(2, RoundingMode.HALF_UP));
data.put("roi", roi);
data.put("targetAmount", targetAmount);
data.put("targetOrderCount", targetOrderCount);
@@ -759,7 +759,7 @@ public class ExportServiceImpl implements ExportService {
data.put("totalProfitBeforeTax", profitBeforeTax);
data.put("salesTaxAmount", salesTaxAmount);
data.put("roi", roi);
data.put("profitAfterTax", profitAfterTax);
data.put("profitAfterTax", profitAfterTax.setScale(2, RoundingMode.HALF_UP));
platformDataList.add(data);
}
@@ -231,7 +231,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
overviewVO.setTotalProfitBeforeTax(totalProfitBeforeTax);
BigDecimal totalSalesTaxAmount = totalSalesAmount.multiply(taxRate);
BigDecimal totalNetProfitAfterTax = totalProfitBeforeTax.subtract(totalSalesTaxAmount);
overviewVO.setTotalNetProfitAfterTax(totalNetProfitAfterTax);
overviewVO.setTotalNetProfitAfterTax(totalNetProfitAfterTax.setScale(2, RoundingMode.HALF_UP));
overviewVO.setTotalTaxAmount(totalSalesTaxAmount);
// 7. 计算目标维度的数据
@@ -547,7 +547,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
comparison.setFeeRatio(feeRatio);
comparison.setTotalProfitBeforeTax(profitBeforeTax);
comparison.setSalesTaxAmount(salesTaxAmount);
comparison.setProfitAfterTax(profitAfterTax);
comparison.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
comparison.setRoi(roi);
comparisons.add(comparison);
}
@@ -621,7 +621,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
total.setTotalProfitBeforeTax(profitBeforeTax);
total.setSalesTaxAmount(salesTax);
total.setRoi(roi);
total.setProfitAfterTax(profitAfterTax);
total.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return total;
}
@@ -865,7 +865,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
cc.setFeeRatio(feeRatio);
cc.setTotalProfitBeforeTax(profitBeforeTax);
cc.setSalesTaxAmount(salesTaxAmount);
cc.setProfitAfterTax(profitAfterTax);
cc.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
cc.setRoi(roi);
results.add(cc);
}
@@ -938,7 +938,7 @@ public class ShopOverviewStatisticsServiceImpl implements ShopOverviewStatistics
total.setTotalProfitBeforeTax(profitBeforeTax);
total.setSalesTaxAmount(salesTax);
total.setRoi(roi);
total.setProfitAfterTax(profitAfterTax);
total.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
return total;
}
}
@@ -195,7 +195,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
.subtract(totalRefundAmount)
.subtract(totalPromotionFee)
.subtract(totalTaxAmount);
vo.setTotalNetProfitAfterTax(totalProfitAfterTax);
vo.setTotalNetProfitAfterTax(totalProfitAfterTax.setScale(2, RoundingMode.HALF_UP));
// ROI = (销售额 - 退款金额) / 推广费(与店铺概览 calculateSalesROI 口径一致)
BigDecimal totalROI = totalPromotionFee.compareTo(BigDecimal.ZERO) > 0
@@ -489,7 +489,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
item.setProfitBeforeTax(profitBeforeTax);
item.setSalesTaxAmount(salesTaxAmount);
item.setRoi(roi);
item.setProfitAfterTax(profitAfterTax);
item.setProfitAfterTax(profitAfterTax.setScale(2, RoundingMode.HALF_UP));
specItems.add(item);
}
@@ -546,7 +546,7 @@ public class ProductOverviewServiceImpl implements ProductOverviewService {
: BigDecimal.ZERO;
total.setRoi(totalRoi);
total.setProfitAfterTax(totalProfitBT.subtract(totalSalesTax));
total.setProfitAfterTax(totalProfitBT.subtract(totalSalesTax).setScale(2, RoundingMode.HALF_UP));
ProductOverviewVO.SpecSummary summary = new ProductOverviewVO.SpecSummary();
summary.setList(specItems);
@@ -40,9 +40,9 @@ public class PlanPricingPO {
private Integer durationMonths;
/**
* 是否启用当前价格(1-启用,0-禁用)
* 状态(1-启用,0-禁用)
*/
@TableField("stauts")
@TableField("status")
private Integer status;
/**