瀏覽代碼

防止丢失精度

yq 3 年之前
父節點
當前提交
7db0395e56

+ 2 - 2
src/main/java/com/usky/dxtop/service/impl/OrderServiceImpl.java

@@ -406,12 +406,12 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
         }
         QueryWrapper<Order> queryWrapper = new QueryWrapper<>();
         queryWrapper.select(dateType,
-                "sum(money) as totalMoney",
+                "cast(sum(money) AS decimal(15,2)) as totalMoney",
                 "sum(if(pay_type = '1', money, 0)) as cashMoney",
                 "sum(if(pay_type = '2', money, 0)) as wxMoney",
                 "sum(if(pay_type = '3', money, 0)) as zfbMoney")
                 .between(null != startTime && null != endTime,"create_time",startTime,endTime)
-                .eq("order_flag",OrderStatus.COMPLETE.getCode())
+                .and(wrapper -> wrapper.eq("order_flag",OrderStatus.SUCCESS.getCode()).or().eq("order_flag",OrderStatus.COMPLETE.getCode()))
                 .groupBy("reportDate")
                 .orderByDesc("reportDate");
         IPage<Map<String, Object>> mapIPage = baseMapper.selectMapsPage(page, queryWrapper);

+ 5 - 5
src/main/java/com/usky/dxtop/service/vo/OrderReport.java

@@ -3,7 +3,7 @@ package com.usky.dxtop.service.vo;
 import cn.afterturn.easypoi.excel.annotation.Excel;
 import lombok.Data;
 
-import java.util.Date;
+import java.math.BigDecimal;
 
 /**
  * 订单报表
@@ -17,16 +17,16 @@ public class OrderReport {
     private String reportDate;
 
     @Excel(name = "总金额", height = 6, width = 20)
-    private Double totalMoney;
+    private BigDecimal totalMoney;
 
     @Excel(name = "微信支付", height = 6, width = 20)
-    private Double wxMoney;
+    private BigDecimal wxMoney;
 
     @Excel(name = "支付宝支付", height = 6, width = 20)
-    private Double zfbMoney;
+    private BigDecimal zfbMoney;
 
     @Excel(name = "现金支付", height = 6, width = 20)
-    private Double cashMoney;
+    private BigDecimal cashMoney;
 
     private String type;