zhibing.pu
2024-07-25 01d8de48c76467ff3b99b204e66d3ef86506fa52
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")
@@ -277,10 +276,8 @@
            between4 = new EntityWrapper<BalanceUsageRecord>()
                    .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
@@ -595,11 +588,12 @@
        // 司机提现
        Wrapper<BalanceUsageRecord> between44 = new EntityWrapper<BalanceUsageRecord>()
                ;
        if (time!=null && time == 5){
        if (time == 5 && !StringUtils.hasLength(insertTime)){
            driverWrapper = new EntityWrapper<TPubWithdrawal>()
                    .eq("state", 2)
                    .eq("type",1)
                    .eq("userType", 2)
            ;
                    .between("insertTime", start, end);
            // 专车wrapper
            between = new EntityWrapper<TOrderPrivateCar>()
                    .isNotNull("activityId")
@@ -625,14 +619,13 @@
            // 司机已消费金额
            between4 = new EntityWrapper<BalanceUsageRecord>()
                    .ne("purpose", 6);
            // 司机提现
            between44 = new EntityWrapper<BalanceUsageRecord>()
                    .eq("purpose", 6);
        }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")
@@ -665,10 +658,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 +676,8 @@
                    // 司机消费记录
                    balanceUsageRecords = balanceUsageRecordService.selectList(between4);
                    driverWithdrawal = balanceUsageRecordService.selectList(between44);
                    // 司机提现记录
                    driverWithdrawal = pubWithdrawalService.selectList(driverWrapper);
                    break;
                case 4:
                    // 专车订单
@@ -710,7 +700,7 @@
            // 消费
            balanceUsageRecords = balanceUsageRecordService.selectList(between4);
            // 提现
            driverWithdrawal = balanceUsageRecordService.selectList(between44);
            driverWithdrawal = pubWithdrawalService.selectList(driverWrapper);
        }
        // 已发放补贴总额
@@ -781,7 +771,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 +793,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 +803,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 +819,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 +865,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 +890,6 @@
        useMoneyVO.setDriver(driver);
        useMoneyVO.setDriverWithdrawal(driverWithdrawal1);
        useMoneyVO.setDriverConsume(driverConsume);
        return useMoneyVO;
    }
@@ -1005,7 +989,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 +1082,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 +1104,7 @@
            res.add(grantVO);
        }
        for (TOrderLogistics tOrderPrivateCar : tOrderLogistics) {
            if (tOrderPrivateCar.getDiscountMoney()==null){
            if (tOrderPrivateCar.getDiscountMoney()==null || tOrderPrivateCar.getDiscountMoney() == 0){
                continue;
            }
@@ -1174,10 +1158,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 +1193,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 +1292,7 @@
        // 司机奖励
        Wrapper<DriverActivityHistory> between4 = new EntityWrapper<DriverActivityHistory>()
                ;
        if (time == 5){
        if (time == 5 && !StringUtils.hasLength(insertTime)){
            // 专车wrapper
            between = new EntityWrapper<TOrderPrivateCar>()
                    .isNotNull("discountMoney")