From 33cc3f5cf1ee7169b9c37fd0461a4ab5ceed4cd1 Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期三, 24 七月 2024 17:12:13 +0800
Subject: [PATCH] 7.24.1

---
 ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java |  115 ++++++++++++++++++++++++---------------------------------
 1 files changed, 49 insertions(+), 66 deletions(-)

diff --git a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java
index da058c3..313d3ba 100644
--- a/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java
+++ b/ManagementIGOTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/TSubsidyController.java
@@ -17,6 +17,7 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
+import org.springframework.util.StringUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
@@ -28,6 +29,7 @@
 import java.time.*;
 import java.time.temporal.TemporalAdjusters;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 控制器
@@ -181,7 +183,7 @@
         // 司机消费
         List<BalanceUsageRecord> balanceUsageRecords = new ArrayList<>();
         // 司机提现
-        List<BalanceUsageRecord> driverWithdrawal = new ArrayList<>();
+        List<TPubWithdrawal> driverWithdrawal = new ArrayList<>();
 
         Wrapper<TPubWithdrawal> driverWrapper = new EntityWrapper<TPubWithdrawal>()
                 ;
@@ -204,14 +206,7 @@
         // 司机已消费金额
         Wrapper<BalanceUsageRecord> between4 = new EntityWrapper<BalanceUsageRecord>()
                 ;
-        // 司机提现
-        Wrapper<BalanceUsageRecord> between44 = new EntityWrapper<BalanceUsageRecord>()
-                ;
-        if (time!=null && time == 5){
-            driverWrapper = new EntityWrapper<TPubWithdrawal>()
-                    .eq("state", 2)
-                    .eq("userType", 2)
-                    ;
+        if (time == 5 && !StringUtils.hasLength(insertTime)){
             // 专车wrapper
             between = new EntityWrapper<TOrderPrivateCar>()
                     .isNotNull("activityId")
@@ -238,13 +233,17 @@
             between4 = new EntityWrapper<BalanceUsageRecord>()
                     .ne("purpose", 6);
             // 司机提现
-            between44 = new EntityWrapper<BalanceUsageRecord>()
-                    .eq("purpose", 6);
+            driverWrapper = new EntityWrapper<TPubWithdrawal>()
+                    .eq("state", 2)
+                    .eq("type",1)
+                    .eq("userType", 2)
+            ;
         }else{
             driverWrapper = new EntityWrapper<TPubWithdrawal>()
                     .eq("state", 2)
+                    .eq("type",1)
                     .eq("userType", 2)
-                    .between("handleTime", start, end);
+                    .between("insertTime", start, end);
             // 专车wrapper
             between = new EntityWrapper<TOrderPrivateCar>()
                     .isNotNull("activityId")
@@ -278,9 +277,7 @@
                     .ne("purpose", 6)
                     .between("createTime", start, end);
             // 司机提现
-            between44 = new EntityWrapper<BalanceUsageRecord>()
-                    .eq("purpose", 6)
-                    .between("createTime", start, end);
+
         }
         // 司机提现wrapper
         if (type!=null){
@@ -298,8 +295,7 @@
                 case 3:
                     // 司机消费记录
                     balanceUsageRecords = balanceUsageRecordService.selectList(between4);
-
-                    driverWithdrawal = balanceUsageRecordService.selectList(between44);
+                    driverWithdrawal = pubWithdrawalService.selectList(driverWrapper);
                     break;
                 case 4:
                     // 专车订单
@@ -322,7 +318,7 @@
             // 消费
             balanceUsageRecords = balanceUsageRecordService.selectList(between4);
             // 提现
-            driverWithdrawal = balanceUsageRecordService.selectList(between44);
+            driverWithdrawal = pubWithdrawalService.selectList(driverWrapper);
         }
 
         // 已发放补贴总额
@@ -410,7 +406,7 @@
             GrantVO grantVO = new GrantVO();
             grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime()));
             grantVO.setType("优惠券");
-            grantVO.setAmount(userCouponRecord.getPayMoney().toString());
+            grantVO.setAmount(userCouponRecord.getCouponMoney().toString());
             TUser tUser = appUserService.selectById(userCouponRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getNickName());
@@ -423,7 +419,7 @@
             GrantVO grantVO = new GrantVO();
             grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime()));
             grantVO.setType("优惠券");
-            grantVO.setAmount(userCouponRecord.getPayMoney().toString());
+            grantVO.setAmount(userCouponRecord.getCouponMoney().toString());
             TUser tUser = appUserService.selectById(userCouponRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getNickName());
@@ -468,20 +464,16 @@
             res.add(grantVO);
         }
         // 司机提现
-        for (BalanceUsageRecord balanceUsageRecord : driverWithdrawal) {
+        for (TPubWithdrawal balanceUsageRecord : driverWithdrawal) {
             GrantVO grantVO = new GrantVO();
-            grantVO.setInsertTime(format.format(balanceUsageRecord.getCreateTime()));
+            grantVO.setInsertTime(format.format(balanceUsageRecord.getInsertTime()));
             grantVO.setType("司机奖励");
             grantVO.setAmount(balanceUsageRecord.getMoney().toString());
-            TDriver tUser = driverService.selectById(balanceUsageRecord.getDriverId());
+            TDriver tUser = driverService.selectById(balanceUsageRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getFirstName()+tUser.getLastName());
             }
-            switch (balanceUsageRecord.getPurpose()){
-                case 6:
-                    grantVO.setRemark("司机提现");
-                    break;
-            }
+            grantVO.setRemark("司机提现");
             driverWithdrawal1 = driverWithdrawal1.add(new BigDecimal(balanceUsageRecord.getMoney().toString()));
             res.add(grantVO);
         }
@@ -492,6 +484,7 @@
         driver = driverConsume.add(driverWithdrawal1);
         return res;
     }
+
     @RequestMapping(value = "/use/getCount")
     @ResponseBody
     public Object getCount1(Integer time,String insertTime,Integer type) {
@@ -570,7 +563,7 @@
         // 司机消费
         List<BalanceUsageRecord> balanceUsageRecords = new ArrayList<>();
         // 司机提现
-        List<BalanceUsageRecord> driverWithdrawal = new ArrayList<>();
+        List<TPubWithdrawal> driverWithdrawal = new ArrayList<>();
         Wrapper<TPubWithdrawal> driverWrapper = new EntityWrapper<TPubWithdrawal>()
                 ;
         // 专车wrapper
@@ -593,9 +586,9 @@
         Wrapper<BalanceUsageRecord> between4 = new EntityWrapper<BalanceUsageRecord>()
                 ;
         // 司机提现
-        Wrapper<BalanceUsageRecord> between44 = new EntityWrapper<BalanceUsageRecord>()
+        Wrapper<TPubWithdrawal> between44 = new EntityWrapper<TPubWithdrawal>()
                 ;
-        if (time!=null && time == 5){
+        if (time == 5 && !StringUtils.hasLength(insertTime)){
             driverWrapper = new EntityWrapper<TPubWithdrawal>()
                     .eq("state", 2)
                     .eq("userType", 2)
@@ -625,14 +618,12 @@
             // 司机已消费金额
             between4 = new EntityWrapper<BalanceUsageRecord>()
                     .ne("purpose", 6);
-            // 司机提现
-            between44 = new EntityWrapper<BalanceUsageRecord>()
-                    .eq("purpose", 6);
+
         }else{
             driverWrapper = new EntityWrapper<TPubWithdrawal>()
                     .eq("state", 2)
                     .eq("userType", 2)
-                    .between("handleTime", start, end);
+                    .between("insertTime", start, end);
             // 专车wrapper
             between = new EntityWrapper<TOrderPrivateCar>()
                     .isNotNull("activityId")
@@ -665,10 +656,6 @@
             between4 = new EntityWrapper<BalanceUsageRecord>()
                     .ne("purpose", 6)
                     .between("createTime", start, end);
-            // 司机提现
-            between44 = new EntityWrapper<BalanceUsageRecord>()
-                    .eq("purpose", 6)
-                    .between("createTime", start, end);
         }
 
         if (type!=null){
@@ -687,7 +674,7 @@
                     // 司机消费记录
                     balanceUsageRecords = balanceUsageRecordService.selectList(between4);
 
-                    driverWithdrawal = balanceUsageRecordService.selectList(between44);
+                    driverWithdrawal = pubWithdrawalService.selectList(driverWrapper);
                     break;
                 case 4:
                     // 专车订单
@@ -710,7 +697,7 @@
             // 消费
             balanceUsageRecords = balanceUsageRecordService.selectList(between4);
             // 提现
-            driverWithdrawal = balanceUsageRecordService.selectList(between44);
+            driverWithdrawal = pubWithdrawalService.selectList(between44);
         }
 
         // 已发放补贴总额
@@ -781,7 +768,7 @@
             }
             grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum());
             res.add(grantVO);
-            redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString()));
+            redPackage = redPackage.add(new BigDecimal(temp.toString()));
         }
         for (TOrderLogistics userRedPacketRecord : userRedPacketRecords1) {
             if (userRedPacketRecord.getState() != 9 &&userRedPacketRecord.getState() != 8){
@@ -803,7 +790,7 @@
             }
             grantVO.setRemark("订单号:"+userRedPacketRecord.getOrderNum());
             res.add(grantVO);
-            redPackage = redPackage.add(new BigDecimal(userRedPacketRecord.getPayMoney().toString()));
+            redPackage = redPackage.add(new BigDecimal(temp.toString()));
         }
         // 查询已领取优惠券总额
         for (TOrderPrivateCar userCouponRecord : userCouponRecords) {
@@ -813,13 +800,13 @@
             GrantVO grantVO = new GrantVO();
             grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime()));
             grantVO.setType("优惠券");
-            grantVO.setAmount(userCouponRecord.getPayMoney().toString());
+            grantVO.setAmount(userCouponRecord.getCouponMoney().toString());
             TUser tUser = appUserService.selectById(userCouponRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getNickName());
             }
             grantVO.setRemark("订单号:"+userCouponRecord.getOrderNum());
-            coupon = coupon.add(new BigDecimal(userCouponRecord.getPayMoney().toString()));
+            coupon = coupon.add(new BigDecimal(userCouponRecord.getCouponMoney().toString()));
             res.add(grantVO);
         }
         for (TOrderLogistics userCouponRecord : userCouponRecords1) {
@@ -829,13 +816,13 @@
             GrantVO grantVO = new GrantVO();
             grantVO.setInsertTime(format.format(userCouponRecord.getInsertTime()));
             grantVO.setType("优惠券");
-            grantVO.setAmount(userCouponRecord.getPayMoney().toString());
+            grantVO.setAmount(userCouponRecord.getCouponMoney().toString());
             TUser tUser = appUserService.selectById(userCouponRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getNickName());
             }
             grantVO.setRemark("订单号:"+userCouponRecord.getOrderNum());
-            coupon = coupon.add(new BigDecimal(userCouponRecord.getPayMoney().toString()));
+            coupon = coupon.add(new BigDecimal(userCouponRecord.getCouponMoney().toString()));
             res.add(grantVO);
         }
         // 司机消费奖励
@@ -875,24 +862,19 @@
             res.add(grantVO);
         }
         // 司机提现
-        for (BalanceUsageRecord balanceUsageRecord : driverWithdrawal) {
+        for (TPubWithdrawal balanceUsageRecord : driverWithdrawal) {
             GrantVO grantVO = new GrantVO();
-            grantVO.setInsertTime(format.format(balanceUsageRecord.getCreateTime()));
+            grantVO.setInsertTime(format.format(balanceUsageRecord.getInsertTime()));
             grantVO.setType("司机奖励");
             grantVO.setAmount(balanceUsageRecord.getMoney().toString());
-            TDriver tUser = driverService.selectById(balanceUsageRecord.getDriverId());
+            TDriver tUser = driverService.selectById(balanceUsageRecord.getUserId());
             if (tUser!=null){
                 grantVO.setName(tUser.getFirstName()+tUser.getLastName());
             }
-            switch (balanceUsageRecord.getPurpose()){
-                case 6:
-                    grantVO.setRemark("司机提现");
-                    break;
-            }
+            grantVO.setRemark("司机提现");
             driverWithdrawal1 = driverWithdrawal1.add(new BigDecimal(balanceUsageRecord.getMoney().toString()));
             res.add(grantVO);
         }
-
         // 总额
         total = total.add(redPackage).add(coupon).add(discount).add(driverConsume).add(driverWithdrawal1);
         // 已使用司机奖励合计
@@ -905,7 +887,6 @@
         useMoneyVO.setDriver(driver);
         useMoneyVO.setDriverWithdrawal(driverWithdrawal1);
         useMoneyVO.setDriverConsume(driverConsume);
-
         return useMoneyVO;
     }
 
@@ -1005,7 +986,7 @@
         // 司机奖励
         Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>()
                 ;
-        if (time == 5){
+        if (time == 5 && !StringUtils.hasLength(insertTime)){
             // 专车wrapper
             between = new EntityWrapper<TOrderPrivateCar>()
                     .isNotNull("discountMoney")
@@ -1098,7 +1079,7 @@
         BigDecimal driver = new BigDecimal("0");
         // 查询已使用折扣总额
         for (TOrderPrivateCar tOrderPrivateCar : tOrderPrivateCars) {
-            if (tOrderPrivateCar.getDiscountMoney()==null){
+            if (tOrderPrivateCar.getDiscountMoney()==null || tOrderPrivateCar.getDiscountMoney() == 0){
                 continue;
             }
             discount = discount.add(new BigDecimal(tOrderPrivateCar.getDiscountMoney().toString()));
@@ -1120,7 +1101,7 @@
             res.add(grantVO);
         }
         for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) {
-            if (tOrderPrivateCar.getDiscountMoney()==null){
+            if (tOrderPrivateCar.getDiscountMoney()==null || tOrderPrivateCar.getDiscountMoney() == 0){
                 continue;
             }
 
@@ -1174,10 +1155,9 @@
             if (tUser!=null){
                 grantVO.setName(tUser.getNickName());
             }
-            SysCouponRecord sysCouponRecord =
-                    sysCouponRecordService.selectById(userCouponRecord.getCouponId());
-            if (sysCouponRecord!=null){
-                grantVO.setRemark(sysCouponRecord.getName());
+            SysCouponActivity sysCouponActivity = sysCouponActivityService.selectById(userCouponRecord.getCouponActivityId());
+            if (sysCouponActivity!=null){
+                grantVO.setRemark(sysCouponActivity.getName());
             }
             coupon = coupon.add(new BigDecimal(userCouponRecord.getMoney().toString()));
             res.add(grantVO);
@@ -1210,8 +1190,11 @@
             driver = driver.add(new BigDecimal(driverActivityHistory.getMoney().toString()));
             res.add(grantVO);
         }
+        List<GrantVO> sortedList = res.stream()
+                .sorted((o1, o2) -> o2.getInsertTime().compareTo(o1.getInsertTime()))
+                .collect(Collectors.toList());
         total = total.add(redPackage).add(coupon).add(discount).add(driver);
-        return res;
+        return sortedList;
     }
     @RequestMapping(value = "/grant/getCount")
     @ResponseBody
@@ -1306,7 +1289,7 @@
         // 司机奖励
         Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>()
                 ;
-        if (time == 5){
+        if (time == 5 && !StringUtils.hasLength(insertTime)){
             // 专车wrapper
             between = new EntityWrapper<TOrderPrivateCar>()
                     .isNotNull("discountMoney")

--
Gitblit v1.7.1