Преглед на файлове

问题修复-财务统计

xucaiqin преди 2 години
родител
ревизия
d3bb74e34c

+ 1 - 1
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/controller/WalletController.java

@@ -3,8 +3,8 @@ package com.sckw.payment.controller;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.payment.model.dto.Id;
 import com.sckw.payment.model.vo.req.*;
-import com.sckw.payment.model.vo.req.page.PrePayPage;
 import com.sckw.payment.model.vo.req.page.MoneyPage;
+import com.sckw.payment.model.vo.req.page.PrePayPage;
 import com.sckw.payment.model.vo.req.page.RefundPage;
 import com.sckw.payment.service.WalletService;
 import jakarta.annotation.Resource;

+ 1 - 0
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/model/dto/wallet/CashLog.java

@@ -10,6 +10,7 @@ import java.io.Serializable;
 public class CashLog implements Serializable {
     @Serial
     private static final long serialVersionUID = 7233982475006805580L;
+    @JSONField(name = "order_no")
     private String orderNo;
     @JSONField(name = "status")
     private Integer status;

+ 34 - 39
sckw-modules/sckw-payment/src/main/java/com/sckw/payment/service/WorkbenchService.java

@@ -1,5 +1,6 @@
 package com.sckw.payment.service;
 
+import com.sckw.core.common.enums.NumberConstant;
 import com.sckw.core.web.context.LoginUserHolder;
 import com.sckw.payment.model.vo.SettlementRecord;
 import com.sckw.payment.model.vo.req.FinanceCount;
@@ -14,8 +15,8 @@ import org.springframework.stereotype.Service;
 import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -30,6 +31,35 @@ public class WorkbenchService {
 
     @Resource
     private KwpSettlementRecordService kwpSettlementRecordService;
+    private final Map<String, Function<SettlementRecord, String>> map = new HashMap<>(NumberConstant.FOUR);
+
+    public WorkbenchService() {
+        DecimalFormat df = new DecimalFormat("0.00");
+        map.put("1", (d) -> {
+            if (Objects.isNull(d.getReceivedMoney())) {
+                return "0.00";
+            }
+            return df.format(d.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
+        });
+        map.put("2", (d) -> {
+            if (Objects.isNull(d.getExactMoney())) {
+                return "0.00";
+            }
+            return df.format(d.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
+        });
+        map.put("3", (d) -> {
+            if (Objects.isNull(d.getOverdueExactMoney())) {
+                return "0.00";
+            }
+            return df.format(d.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
+        });
+        map.put("4", (d) -> {
+            BigDecimal overdueExactMoney = d.getOverdueExactMoney();
+            //总应收金额
+            BigDecimal totalReceiveMoney = d.getTotalReceiveMoney();
+             return DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney);
+        });
+    }
 
     public Object financeCount(FinanceCount financeCount) {
         //周期维度 1-天 2-周 3-月
@@ -59,48 +89,13 @@ public class WorkbenchService {
             }
         }
         Long entId = LoginUserHolder.getEntId();
-        DecimalFormat df = new DecimalFormat("0.00");
         //获取数据,按照统计因子进行处理,并转换成万元
         List<SettlementRecord> settlementRecords = kwpSettlementRecordService.financeCount(time, entId, circle);
         return settlementRecords.stream().map(a -> {
             EChartsVo eChartsVo = new EChartsVo();
             eChartsVo.setCreateTime(a.getCreateTime());
-            switch (financeCount.getFactorOne()) {
-                case "1" ->
-                        eChartsVo.setFactorOne(df.format(a.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "2" ->
-                        eChartsVo.setFactorOne(df.format(a.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "3" ->
-                        eChartsVo.setFactorOne(df.format(a.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "4" -> {
-                    BigDecimal overdueExactMoney = a.getOverdueExactMoney();
-                    //总应收金额
-                    BigDecimal totalReceiveMoney = a.getTotalReceiveMoney();
-                    if (totalReceiveMoney.compareTo(new BigDecimal("0.0")) <= 0) {
-                        eChartsVo.setFactorOne("0.00%");
-                    } else {
-                        eChartsVo.setFactorOne(DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney));
-                    }
-                }
-            }
-            switch (financeCount.getFactorTwo()) {
-                case "1" ->
-                        eChartsVo.setFactorTwo(df.format(a.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "2" ->
-                        eChartsVo.setFactorTwo(df.format(a.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "3" ->
-                        eChartsVo.setFactorTwo(df.format(a.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
-                case "4" ->{
-                    BigDecimal overdueExactMoney = a.getOverdueExactMoney();
-                    //总应收金额
-                    BigDecimal totalReceiveMoney = a.getTotalReceiveMoney();
-                    if (totalReceiveMoney.compareTo(new BigDecimal("0.0")) <= 0) {
-                        eChartsVo.setFactorTwo("0.00%");
-                    } else {
-                        eChartsVo.setFactorTwo(DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney));
-                    }
-                }
-            }
+            eChartsVo.setFactorOne(map.get(financeCount.getFactorOne()).apply(a));
+            eChartsVo.setFactorTwo(map.get(financeCount.getFactorTwo()).apply(a));
             return eChartsVo;
         }).collect(Collectors.toList());
     }

+ 9 - 9
sckw-modules/sckw-payment/src/main/resources/mapper/KwpSettlementRecordMapper.xml

@@ -117,15 +117,15 @@
     </select>
     <!--    支持时间范围筛选的按月统计-->
     <select id="countMonth" resultType="com.sckw.payment.model.vo.SettlementRecord">
-        select tmpd.createTime,
-               tmpd.totalReceiveMoney,
-               tmpd.exactMoney,
-               tmpd.receivedMoney,
-               tmpd.overdueExactMoney,
-               tmpd.totalPayMoney,
-               tmpd.unpaidMoney,
-               tmpd.paidMoney,
-               tmpd.overduePaidMoney
+        select temp.date as createTime,
+               ifnull(tmpd.totalReceiveMoney, 0),
+               ifnull(tmpd.exactMoney, 0),
+               ifnull(tmpd.receivedMoney, 0),
+               ifnull(tmpd.overdueExactMoney, 0),
+               ifnull(tmpd.totalPayMoney, 0),
+               ifnull(tmpd.unpaidMoney, 0),
+               ifnull(tmpd.paidMoney, 0),
+               ifnull(tmpd.overduePaidMoney, 0)
         FROM (
         <foreach collection="timeAll" item="date" separator="UNION ALL">
             SELECT #{date} AS date