浏览代码

fix: 补回 getStatisticsData 缺失的 avgOrderPrice/customerPrice 变量

Co-Authored-By: Claude <noreply@anthropic.com>
skyline 1 天之前
父节点
当前提交
5df019c2c1
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      haha-service/src/main/java/com/haha/service/impl/DashboardServiceImpl.java

+ 4 - 0
haha-service/src/main/java/com/haha/service/impl/DashboardServiceImpl.java

@@ -213,6 +213,8 @@ public class DashboardServiceImpl implements DashboardService {
                 ? compareSales.divide(BigDecimal.valueOf(compareOrderCount), 2, RoundingMode.HALF_UP)
                 : BigDecimal.ZERO;
 
+        BigDecimal avgOrderPrice = totalOrders > 0
+                ? totalSales.divide(BigDecimal.valueOf(totalOrders), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
         result.put("salesGrowth", formatGrowth(totalSales, compareSales));
         result.put("ordersGrowth", formatGrowth(totalOrders, compareOrderCount));
         result.put("avgOrderGrowth", formatGrowth(avgOrderPrice, compareAvgPrice));
@@ -247,6 +249,8 @@ public class DashboardServiceImpl implements DashboardService {
                 ? compareSales.divide(BigDecimal.valueOf(compareTransactUserIds.size()), 2, RoundingMode.HALF_UP)
                 : BigDecimal.ZERO;
 
+        BigDecimal customerPrice = transactUserIds.size() > 0
+                ? totalSales.divide(BigDecimal.valueOf(transactUserIds.size()), 2, RoundingMode.HALF_UP) : BigDecimal.ZERO;
         result.put("newUsersGrowth", formatGrowth(newUsers, compareNewUsers));
         result.put("transactGrowth", formatGrowth(transactUserIds.size(), compareTransactUserIds.size()));
         result.put("customerGrowth", formatGrowth(customerPrice, compareCustomerPrice));