java110
2021-08-12 4dbf61c9189796ec46d39ac4b839cfc064e70411
service-report/src/main/java/com/java110/report/bmo/reportFeeMonthStatistics/impl/GetReportFeeMonthStatisticsBMOImpl.java
@@ -1,14 +1,18 @@
package com.java110.report.bmo.reportFeeMonthStatistics.impl;
import com.alibaba.fastjson.JSONObject;
import com.java110.dto.PageDto;
import com.java110.dto.RoomDto;
import com.java110.dto.fee.FeeConfigDto;
import com.java110.dto.fee.FeeDto;
import com.java110.dto.repair.RepairUserDto;
import com.java110.dto.report.ReportDeposit;
import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsDto;
import com.java110.dto.reportFeeMonthStatistics.ReportFeeMonthStatisticsTotalDto;
import com.java110.intf.fee.IFeeConfigInnerServiceSMO;
import com.java110.intf.report.IReportFeeMonthStatisticsInnerServiceSMO;
import com.java110.report.bmo.reportFeeMonthStatistics.IGetReportFeeMonthStatisticsBMO;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.DateUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
@@ -19,9 +23,11 @@
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@Service("getReportFeeMonthStatisticsBMOImpl")
@@ -31,6 +37,9 @@
    @Autowired
    private IReportFeeMonthStatisticsInnerServiceSMO reportFeeMonthStatisticsInnerServiceSMOImpl;
    @Autowired
    private IFeeConfigInnerServiceSMO feeConfigInnerServiceSMOImpl;
    /**
     * @param reportFeeMonthStatisticsDto
@@ -59,9 +68,18 @@
    public ResponseEntity<String> queryReportFeeSummary(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
        int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeSummaryCount(reportFeeMonthStatisticsDto);
        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = null;
        List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos = new ArrayList<>();
        if (count > 0) {
            reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeSummary(reportFeeMonthStatisticsDto);
            List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList = reportFeeMonthStatisticsInnerServiceSMOImpl.queryReportFeeSummary(reportFeeMonthStatisticsDto);
            for (ReportFeeMonthStatisticsDto reportFeeMonthStatistics : reportFeeMonthStatisticsList) {
                //获取应收金额
                double receivableAmount = Double.parseDouble(reportFeeMonthStatistics.getReceivableAmount());
                //获取实收金额
                double receivedAmount = Double.parseDouble(reportFeeMonthStatistics.getReceivedAmount());
                double chargeRate = (receivedAmount / receivableAmount) * 100.0;
                reportFeeMonthStatistics.setChargeRate(String.format("%.2f", chargeRate) + "%");
                reportFeeMonthStatisticsDtos.add(reportFeeMonthStatistics);
            }
        } else {
            reportFeeMonthStatisticsDtos = new ArrayList<>();
        }
@@ -195,6 +213,7 @@
    @Override
    public ResponseEntity<String> queryPayFeeDetail(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
        JSONObject countInfo = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetailCount(reportFeeMonthStatisticsDto);
        int count = Integer.parseInt(countInfo.get("count").toString());
@@ -220,9 +239,17 @@
        Double allVacantHousingDiscount = 0.0;
        //空置房减免(大计)
        Double allVacantHousingReduction = 0.0;
        int size = 0;
        if (count > 0) {
            //查询缴费明细
            reportFeeMonthStatisticsDtos = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetail(reportFeeMonthStatisticsDto);
            if (reportFeeMonthStatisticsDtos != null && reportFeeMonthStatisticsDtos.size() > 0) {
                //查询所有缴费明细记录
                ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto1 = BeanConvertUtil.covertBean(reportFeeMonthStatisticsDto, ReportFeeMonthStatisticsDto.class);
                reportFeeMonthStatisticsDto1.setPage(PageDto.DEFAULT_PAGE);
                List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsDtos1 = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDetail(reportFeeMonthStatisticsDto1);
                size = reportFeeMonthStatisticsDtos1.size();
            }
            //查询应收、实收总金额(大计)
            List<ReportFeeMonthStatisticsDto> reportFeeMonthStatisticsList = reportFeeMonthStatisticsInnerServiceSMOImpl.queryAllPayFeeDetail(reportFeeMonthStatisticsDto);
            //查询(优惠、减免、滞纳金、空置房打折、空置房减免金额等)大计总金额
@@ -283,7 +310,6 @@
                    reportFeeMonthStatistics.setPreferentialAmount(reportFeeMonthStatistics.getDiscountPrice());
                } else {
                    reportFeeMonthStatistics.setPreferentialAmount("0");
                }
                //减免金额
                if (!StringUtil.isEmpty(reportFeeMonthStatistics.getDiscountSmallType()) && reportFeeMonthStatistics.getDiscountSmallType().equals("2")) {
@@ -325,7 +351,6 @@
                } else {
                    reportFeeMonthStatistics.setVacantHousingReduction("0");
                }
                if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(reportFeeMonthStatistics.getPayerObjType())) {
                    reportFeeMonthStatistics.setObjName(reportFeeMonthStatistics.getFloorNum()
                            + "栋" + reportFeeMonthStatistics.getUnitNum()
@@ -336,11 +361,9 @@
                    reportFeeMonthStatistics.setObjName(reportFeeMonthStatistics.getContractCode());
                }
                if (!StringUtil.isEmpty(reportFeeMonthStatistics.getImportFeeName())) {
                    reportFeeMonthStatistics.setFeeName(reportFeeMonthStatistics.getImportFeeName());
                }
                //费用项目
                reportFeeMonthStatistics.setFeeConfigDtos(feeConfigDtos);
                reportList.add(reportFeeMonthStatistics);
@@ -379,7 +402,7 @@
            reportFeeMonthStatisticsTotalDto = new ReportFeeMonthStatisticsTotalDto();
        }
        ResultVo resultVo = new ResultVo((int) Math.ceil((double) count / (double) reportFeeMonthStatisticsDto.getRow()), count, reportList, reportFeeMonthStatisticsTotalDto);
        ResultVo resultVo = new ResultVo((int) Math.ceil((double) size / (double) reportFeeMonthStatisticsDto.getRow()), size, reportList, reportFeeMonthStatisticsTotalDto);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
@@ -530,6 +553,8 @@
                    int dispatchAmount = 0;
                    //回访数量
                    int returnAmount = 0;
                    //评分
                    String score = "";
                    for (RepairUserDto repair : repairUserDtoList) {
                        //处理中状态
                        if (repair.getState().equals("10001")) {
@@ -554,6 +579,9 @@
                        } else if (repair.getState().equals("10008")) {  //已回访状态
                            int amount = Integer.parseInt(repair.getAmount());
                            returnAmount = returnAmount + amount;
                        }
                        if (!StringUtil.isEmpty(repair.getScore())) {
                            score = repair.getScore();
                        }
                    }
                    //员工id
@@ -586,6 +614,8 @@
                    repairUserInfo.setReturnNumber(Integer.toString(returnNumber));
                    //员工id和姓名信息集合
                    repairUserInfo.setRepairList(staffs);
                    //员工评分
                    repairUserInfo.setScore(score);
                    repairUserList.add(repairUserInfo);
                } else {
                    continue;
@@ -638,6 +668,102 @@
    }
    @Override
    public ResponseEntity<String> queryPayFeeDeposit(ReportDeposit reportDeposit) {
        //查询押金
        List<ReportDeposit> reportDeposits = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDeposit(reportDeposit);
        //查询押金退费总金额
        List<ReportDeposit> reportDepositAmounts = reportFeeMonthStatisticsInnerServiceSMOImpl.queryFeeDepositAmount(reportDeposit);
        //查询押金费用项
        FeeConfigDto feeConfigDto = new FeeConfigDto();
        feeConfigDto.setCommunityId(reportDeposit.getCommunityId());
        feeConfigDto.setFeeTypeCd("888800010006");
        List<FeeConfigDto> feeConfigDtos = feeConfigInnerServiceSMOImpl.queryFeeConfigs(feeConfigDto);
        List<ReportDeposit> newReportDeposits = new ArrayList<>();
        BigDecimal unpaidfeeAmount = new BigDecimal(0);//未交费
        BigDecimal unpaidfeeAmounts = new BigDecimal(0);//未缴费总金额
        BigDecimal paidfeeAmount = new BigDecimal(0);//已缴费
        BigDecimal paidfeeAmounts = new BigDecimal(0);//已缴费总金额
        BigDecimal refundedAmount = new BigDecimal(0);//已退费
        BigDecimal refundedAmounts = new BigDecimal(0);//已退费总金额
        BigDecimal refundInProgressAmount = new BigDecimal(0); //退费中
        BigDecimal refundInProgressAmounts = new BigDecimal(0);//退费中总金额
        BigDecimal refundFailedAmount = new BigDecimal(0); //退费失败
        BigDecimal refundFailedAmounts = new BigDecimal(0);//退费失败总金额
        for (ReportDeposit deposit : reportDeposits) {
            deposit.setFeeConfigDtos(feeConfigDtos);
            newReportDeposits.add(deposit);
            if (FeeDto.PAYER_OBJ_TYPE_ROOM.equals(deposit.getPayerObjType())) {
                deposit.setObjName(deposit.getFloorNum()
                        + "栋" + deposit.getUnitNum()
                        + "单元" + deposit.getRoomNum() + "室");
            } else if (FeeDto.PAYER_OBJ_TYPE_CAR.equals(deposit.getPayerObjType())) {
                deposit.setObjName(deposit.getCarNum());
            }
            //收费中(未交费)
            if ("2008001".equals(deposit.getState())) {
                unpaidfeeAmount = unpaidfeeAmount.add(new BigDecimal(deposit.getAdditionalAmount()));
            }
            //收费结束(已收费)
            if ("2009001".equals(deposit.getState()) && !StringUtil.isEmpty(deposit.getDetailState()) && "1400".equals(deposit.getDetailState())) {
                paidfeeAmount = paidfeeAmount.add(new BigDecimal(deposit.getAdditionalAmount()));
            }
            if (!StringUtil.isEmpty(deposit.getDetailState()) && "1100".equals(deposit.getDetailState())) {//已退费
                refundedAmount = refundedAmount.add(new BigDecimal(deposit.getAdditionalAmount()));
            }
            if (!StringUtil.isEmpty(deposit.getDetailState()) && "1000".equals(deposit.getDetailState())) {//退费中
                refundInProgressAmount = refundInProgressAmount.add(new BigDecimal(deposit.getAdditionalAmount()));
            }
            if (!StringUtil.isEmpty(deposit.getDetailState()) && "1200".equals(deposit.getDetailState())) {//退费失败
                refundFailedAmount = refundFailedAmount.add(new BigDecimal(deposit.getAdditionalAmount()));
            }
        }
        for (ReportDeposit reportDeposit1 : reportDepositAmounts) {
            if (StringUtil.isEmpty(reportDeposit1.getAllAmount())) {
                throw new IllegalArgumentException("查询总金额错误!");
            }
            //获取总金额
            BigDecimal bd = new BigDecimal(reportDeposit1.getAllAmount());
            if (StringUtil.isEmpty(reportDeposit1.getDetailState())) { //获取未缴费总金额
                unpaidfeeAmounts = bd;
            } else if (reportDeposit1.getDetailState().equals("1000")) { //获取退费中总金额
                refundInProgressAmounts = bd;
            } else if (reportDeposit1.getDetailState().equals("1100")) { //获取已退费总金额
                refundedAmounts = bd;
            } else if (reportDeposit1.getDetailState().equals("1200")) { //获取退费失败总金额
                refundFailedAmounts = bd;
            } else if (reportDeposit1.getDetailState().equals("1400")) { //获取已缴费总金额
                paidfeeAmounts = bd;
            }
        }
        HashMap<String, String> mp = new HashMap<>();
        mp.put("unpaidfeeAmount", unpaidfeeAmount.toString());
        mp.put("paidfeeAmount", paidfeeAmount.toString());
        mp.put("refundedAmount", refundedAmount.toString());
        mp.put("refundInProgressAmount", refundInProgressAmount.toString());
        mp.put("refundFailedAmount", refundFailedAmount.toString());
        mp.put("unpaidfeeAmounts", unpaidfeeAmounts.toString());
        mp.put("paidfeeAmounts", paidfeeAmounts.toString());
        mp.put("refundedAmounts", refundedAmounts.toString());
        mp.put("refundInProgressAmounts", refundInProgressAmounts.toString());
        mp.put("refundFailedAmounts", refundFailedAmounts.toString());
        int size = 0;
        if (newReportDeposits != null && newReportDeposits.size() > 0) {
            //查询所有条数
            reportDeposit.setPage(PageDto.DEFAULT_PAGE);
            List<ReportDeposit> reportDeposits1 = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPayFeeDeposit(reportDeposit);
            size = reportDeposits1.size();
        }
        ResultVo resultVo = new ResultVo((int) Math.ceil((double) size / (double) reportDeposit.getRow()), size, newReportDeposits, mp);
        ResponseEntity<String> responseEntity = new ResponseEntity<String>(resultVo.toString(), HttpStatus.OK);
        return responseEntity;
    }
    @Override
    public ResponseEntity<String> queryPrePayment(ReportFeeMonthStatisticsDto reportFeeMonthStatisticsDto) {
        int count = reportFeeMonthStatisticsInnerServiceSMOImpl.queryPrePaymentNewCount(reportFeeMonthStatisticsDto);