From 566c44cc5712ab9c997424ee5a5438e0a81a016e Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期三, 17 五月 2023 18:49:38 +0800
Subject: [PATCH] BUG修改

---
 management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java |   64 +++++++++++++++++++++++++------
 1 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
index 5deea73..dd6964d 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/TDriverServiceImpl.java
@@ -24,6 +24,7 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.stereotype.Service;
 import org.springframework.ui.Model;
 import org.springframework.util.CollectionUtils;
@@ -37,8 +38,10 @@
 import java.net.URLConnection;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.time.Period;
 import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
@@ -237,8 +240,16 @@
         // 查询当前用户邀请了哪些人
         List<TDriver> list = tDriverMapper.selectList(new EntityWrapper<TDriver>().eq("inviterId", tDriver.getId()));
         if(!CollectionUtils.isEmpty(list)){
+            List<TCashWithdrawal> tCashWithdrawals = tCashWithdrawalMapper.selectList(new EntityWrapper<TCashWithdrawal>()
+                    .eq("type", UserTypeEnum.DRIVER.getCode())
+                    .eq("userDriverId", tDriver.getId())
+                    .eq("businessType", 11)
+                    .eq("state", 2));
+            Optional<BigDecimal> reduce = tCashWithdrawals.stream().map(TCashWithdrawal::getAmount).reduce(BigDecimal::add);
+            BigDecimal bigDecimal = BigDecimal.ZERO;
+            reduce.ifPresent(bigDecimal::add);
+            model.addAttribute("inviterCommission",bigDecimal.add(tDriver.getCommission()));
             model.addAttribute("inviterCount",list.size());
-            model.addAttribute("inviterCommission",0);
         }else {
             model.addAttribute("inviterCommission",0);
             model.addAttribute("inviterCount",0);
@@ -435,11 +446,23 @@
             commissionResp.setConnectedPersons(connectedPersons.get());
 
             // 已提现佣金  查询该司机的佣金提现记录
-            commissionResp.setWithdrawnAmount(BigDecimal.ZERO);
-
+            List<TCashWithdrawal> tCashWithdrawals = tCashWithdrawalMapper.selectList(new EntityWrapper<TCashWithdrawal>()
+                    .eq("type", UserTypeEnum.DRIVER.getCode())
+                    .eq("userDriverId", driver.getId())
+                    .eq("businessType", 11)
+                    .eq("state", 2));
+            BigDecimal bigDecimal = BigDecimal.ZERO;
+            if(!CollectionUtils.isEmpty(tCashWithdrawals)){
+                Optional<BigDecimal> reduce = tCashWithdrawals.stream().map(TCashWithdrawal::getAmount).reduce(BigDecimal::add);
+                if(reduce.isPresent()){
+                    bigDecimal.add(reduce.get());
+                    commissionResp.setWithdrawnAmount(bigDecimal);
+                }
+            }else {
+                commissionResp.setWithdrawnAmount(bigDecimal);
+            }
             // 累计佣金  可提现佣金+已提现佣金
-            commissionResp.setAccumulatedCommission(BigDecimal.ZERO);
-
+            commissionResp.setAccumulatedCommission(bigDecimal.add(commissionResp.getCommission()));
             commissionRespList.add(commissionResp);
 
         }
@@ -491,11 +514,26 @@
             model.addAttribute("numberPromoters",0);
         }
         model.addAttribute("connectedPersons",connectedPersons.get());
-        // 已提现佣金  查询该司机的佣金提现记录
-        model.addAttribute("withdrawnAmount",BigDecimal.ZERO);
+        List<TCashWithdrawal> tCashWithdrawals = tCashWithdrawalMapper.selectList(new EntityWrapper<TCashWithdrawal>()
+                .eq("type", UserTypeEnum.DRIVER.getCode())
+                .eq("userDriverId", driver.getId())
+                .eq("businessType", 11)
+                .eq("state", 2));
+        BigDecimal bigDecimal = BigDecimal.ZERO;
+        if(!CollectionUtils.isEmpty(tCashWithdrawals)){
+            Optional<BigDecimal> reduce = tCashWithdrawals.stream().map(TCashWithdrawal::getAmount).reduce(BigDecimal::add);
+            if(reduce.isPresent()){
+                bigDecimal.add(reduce.get());
+                // 已提现佣金  查询该司机的佣金提现记录
+                model.addAttribute("withdrawnAmount",bigDecimal);
+            }
+        }else {
+            // 已提现佣金  查询该司机的佣金提现记录
+            model.addAttribute("withdrawnAmount",bigDecimal);
+        }
 //        commissionResp.setWithdrawnAmount(BigDecimal.ZERO);
         // 累计佣金  可提现佣金+已提现佣金
-        model.addAttribute("accumulatedCommission",BigDecimal.ZERO);
+        model.addAttribute("accumulatedCommission",bigDecimal.add(driver.getCommission()));
 //        commissionResp.setAccumulatedCommission(BigDecimal.ZERO);
 
     }
@@ -506,11 +544,11 @@
         Integer driverTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>()
                 .eq("agentId", agentId));
         // 司机最近一月数量
-        LocalDate now = LocalDate.now();
-        LocalDate localDate = now.plusMonths(1);
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime localDateTime = now.minusMonths(1);
         Integer driverMonthTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>()
                 .eq("agentId", agentId)
-                .between("createTime", localDate, now));
+                .between("createTime", localDateTime, now));
         model.addAttribute("driverTotal",driverTotal);
         model.addAttribute("driverMonthTotal",driverMonthTotal);
         map.put("driverTotal",driverTotal);
@@ -523,8 +561,8 @@
         Integer driverTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>()
                 .in("agentId", ids));
         // 司机最近一月数量
-        LocalDate now = LocalDate.now();
-        LocalDate localDate = now.plusMonths(1);
+        LocalDateTime now = LocalDateTime.now();
+        LocalDateTime localDate = now.minusMonths(1);
         Integer driverMonthTotal = tDriverMapper.selectCount(new EntityWrapper<TDriver>()
                 .in("agentId", ids)
                 .between("createTime", localDate, now));

--
Gitblit v1.7.1