| | |
| | | private final PaymentSlipMapper paymentSlipMapper; |
| | | private final BipRequestRecordMapper bipRequestRecordMapper; |
| | | private final ContractExecDateMapper contractExecDateMapper; |
| | | private final MeterReadRecordMapper meterReadRecordMapper; |
| | | private final RemoteDeptService remoteDeptService; |
| | | private final RedisTemplate redisTemplate; |
| | | |
| | |
| | | if (ObjUtil.isNull(contract)) { |
| | | return R.failed("合同查询失败,请检查合同编号"); |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getRegisterName, addDTO.getBusGuestName()) |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestId()), BusinessCustomer::getId, addDTO.getBusGuestId())); |
| | | BusinessCustomer customer = businessCustomerService.getById(contract.getPartyAId()); |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("客商查询失败,请检查客商"); |
| | | } |
| | |
| | | lastTotal = lastConfirm.getTotalAmount(); |
| | | } |
| | | |
| | | |
| | | //转入 |
| | | if (StrUtil.equals(addDTO.getInOrOut(), "1")) { |
| | | |
| | | |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | | slip.setPayType(addDTO.getPayType()); |
| | | paymentSlipMapper.insert(slip); |
| | | |
| | | BigDecimal newtotal = addDTO.getTransationAmount().add(lastTotal); |
| | | PaymentConfirm entity = new PaymentConfirm(); |
| | | entity.setContractId(contract.getId()); |
| | |
| | | entity.setConfirmTime(new Date()); |
| | | baseMapper.insert(entity); |
| | | } |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = addDTO.getTransationAmount(); |
| | | for (ContractPaymentSchedule schedule : scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | | remain = remain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() : |
| | | schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | if (remain.compareTo(new BigDecimal("0")) >= 0) { |
| | | schedule.setActualAmount(schedule.getPlannedAmount()); |
| | | schedule.setPaymentDate(addDTO.getConfirmTime()); |
| | | schedule.setPaymentStatus(2); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setPaymentTime(addDTO.getConfirmTime()); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //删除当前逾期 |
| | | currentOverdueMapper.deleteById(currentOverdue); |
| | | |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = addDTO.getTransationAmount(); |
| | | for (ContractPaymentSchedule schedule : scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | | remain = remain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() : |
| | | schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | if (remain.compareTo(new BigDecimal("0")) >= 0) { |
| | | schedule.setActualAmount(schedule.getPlannedAmount()); |
| | | schedule.setPaymentDate(addDTO.getConfirmTime()); |
| | | schedule.setPaymentStatus(2); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setPaymentTime(addDTO.getConfirmTime()); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //删除当前逾期 |
| | | currentOverdueMapper.deleteById(currentOverdue); |
| | | } |
| | | } else { |
| | | schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) : |
| | | schedule.getActualAmount().add(lastRemain)); |
| | | schedule.setPaymentDate(addDTO.getConfirmTime()); |
| | | schedule.setPaymentStatus(1); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setReceivableAmount(lastRemain); |
| | | historyOverdue.setPaymentTime(addDTO.getConfirmTime()); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //更新当前逾期 |
| | | currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | currentOverdueMapper.updateById(currentOverdue); |
| | | } |
| | | break; |
| | | } |
| | | } else { |
| | | schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) : |
| | | schedule.getActualAmount().add(lastRemain)); |
| | | schedule.setPaymentDate(addDTO.getConfirmTime()); |
| | | schedule.setPaymentStatus(1); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setReceivableAmount(lastRemain); |
| | | historyOverdue.setPaymentTime(addDTO.getConfirmTime()); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //查询历史已付逾期金额 |
| | | List<HistoryOverdue> historyOverdueList = historyOverdueMapper.selectList(Wrappers.<HistoryOverdue>lambdaQuery().eq(HistoryOverdue::getScheduleId, currentOverdue.getScheduleId())); |
| | | BigDecimal hisTotal = historyOverdueList.stream().map(item -> item.getReceivableAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //更新当前逾期 |
| | | currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(hisTotal)); |
| | | currentOverdueMapper.updateById(currentOverdue); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //非房屋租赁 水电 |
| | | if (!StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | //更新合同已付款 |
| | | BigDecimal paid = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(contract.getPaidAmount())) { |
| | |
| | | } |
| | | paid = paid.add(addDTO.getTransationAmount()); |
| | | contract.setPaidAmount(paid); |
| | | if (paid.compareTo(contract.getAmount()) > 0) { |
| | | if (paid.compareTo(contract.getAmount()) == 0) { |
| | | contract.setContractStatus(3); |
| | | contract.setPaidAmount(contract.getAmount()); |
| | | } |
| | | contractService.updateById(contract); |
| | | }else { |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery().eq(ContractExecDate::getContractId,contract.getId()) |
| | | .eq(ContractExecDate::getGenFlag,"0")); |
| | | List<MeterReadRecord> recordList = meterReadRecordMapper.selectList(Wrappers.<MeterReadRecord>lambdaQuery() |
| | | .eq(MeterReadRecord::getContractId,contract.getId()) |
| | | .isNull(MeterReadRecord::getMeterReadNum)); |
| | | if (ArrayUtil.isEmpty(execDateList.toArray())&&ArrayUtil.isEmpty(recordList.toArray())){ |
| | | //更新合同已付款 |
| | | BigDecimal paid = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(contract.getPaidAmount())) { |
| | | paid = contract.getPaidAmount(); |
| | | } |
| | | paid = paid.add(addDTO.getTransationAmount()); |
| | | contract.setPaidAmount(paid); |
| | | if (contract.getAmount().compareTo(new BigDecimal("0"))==0&&paid.compareTo(contract.getAmount()) >= 0) { |
| | | contract.setContractStatus(3); |
| | | contract.setPaidAmount(contract.getAmount()); |
| | | } |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | | //转出 |
| | | if (StrUtil.equals(addDTO.getInOrOut(), "2")) { |
| | |
| | | entity.setConfirmTime(new Date()); |
| | | baseMapper.insert(entity); |
| | | } |
| | | // 查询所有付款阶段是否都付款完成 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | contract.setContractStatus(3); |
| | | contractService.updateById(contract); |
| | | } |
| | | ; |
| | | } |
| | | }else { |
| | | |
| | | List<Contract> customerContractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, addDTO.getBusGuestId()) |
| | | .eq(Contract::getPartyBId,SecurityUtils.getUser().getCompId()).orderByAsc(Contract::getCreateTime).apply(" amount != paid_amount")); |
| | | if (ArrayUtil.isEmpty(customerContractList.toArray())) { |
| | | return R.failed("为查询到未付款合同"); |
| | | } |
| | | BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getRegisterName, addDTO.getBusGuestName()) |
| | | .eq(ObjUtil.isNotNull(addDTO.getBusGuestId()), BusinessCustomer::getId, addDTO.getBusGuestId()) |
| | | .last("limit 1")); |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("客商查询失败"); |
| | | } |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | | slip.setPayType(addDTO.getPayType()); |
| | | paymentSlipMapper.insert(slip); |
| | | |
| | | BigDecimal transtionAmount = addDTO.getTransationAmount(); |
| | | //剩余付款 |
| | | BigDecimal transtionRemainAmount = transtionAmount; |
| | | //收到付款的合同 |
| | | List<Contract> payContractList = new ArrayList<>(); |
| | | //付款完成的合同 |
| | | List<Contract> payCompleteContractList = new ArrayList<>(); |
| | | //付款未完成的合同 |
| | | List<Contract> payNoCompleteContractList = new ArrayList<>(); |
| | | //有预付款的合同 |
| | | List<Contract> advanceContractList = new ArrayList<>(); |
| | | //付款时间 |
| | | Date payDate = addDTO.getConfirmTime(); |
| | | Iterator<Contract> iterator = customerContractList.iterator(); |
| | | while (iterator.hasNext()) { |
| | | Contract contract = iterator.next(); |
| | | PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId()) |
| | | .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1")); |
| | | BigDecimal lastTotal = new BigDecimal("0"); |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | lastTotal = lastConfirm.getTotalAmount(); |
| | | }else { |
| | | |
| | | } |
| | | |
| | | //合同最近明细总额为0 或 > 0 情况下 |
| | | if (lastTotal.compareTo(new BigDecimal("0")) >= 0) { |
| | | log.info("当前合同号:{},明细总额无应收款", contract.getContractNo()); |
| | | advanceContractList.add(contract); |
| | | if (iterator.hasNext()) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | transtionRemainAmount = transtionRemainAmount.add(lastTotal); |
| | | PaymentConfirm entity = new PaymentConfirm(); |
| | | entity.setContractId(contract.getId()); |
| | | entity.setContractName(contract.getContractName()); |
| | | entity.setContractNo(contract.getContractNo()); |
| | | if (ObjUtil.isNotNull(lastConfirm)) { |
| | | entity.setScheduleId(lastConfirm.getScheduleId()); |
| | | entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | } |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setConfirmTime(payDate); |
| | | // 判断是否是最后一个 |
| | | if (!iterator.hasNext()) { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setAdvanceAmount(transtionRemainAmount); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | }else { |
| | | entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(new BigDecimal("0")); |
| | | } |
| | | baseMapper.insert(entity); |
| | | payContractList.add(contract); |
| | | } else if (transtionRemainAmount.compareTo(new BigDecimal("0")) == 0) { |
| | | entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(new BigDecimal("0")); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | payContractList.add(contract); |
| | | break; |
| | | } else { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setReceivableAmount(transtionRemainAmount.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | payContractList.add(contract); |
| | | break; |
| | | } |
| | | } |
| | | |
| | | payContractList.stream().forEach(contract -> { |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = transtionAmount; |
| | | for (ContractPaymentSchedule schedule : scheduleList) { |
| | | BigDecimal lastRemain = remain; |
| | | remain = lastRemain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() : |
| | | schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | if (remain.compareTo(new BigDecimal("0")) >= 0) { |
| | | schedule.setActualAmount(schedule.getPlannedAmount()); |
| | | schedule.setPaymentDate(payDate); |
| | | schedule.setPaymentStatus(2); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setPaymentTime(payDate); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //删除当前逾期 |
| | | currentOverdueMapper.deleteById(currentOverdue); |
| | | } |
| | | } else { |
| | | schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) : |
| | | schedule.getActualAmount().add(lastRemain)); |
| | | schedule.setPaymentDate(payDate); |
| | | schedule.setPaymentStatus(1); |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | //查询是否有当前逾期 |
| | | CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | if (ObjUtil.isNotNull(currentOverdue)) { |
| | | //新增逾期历史 |
| | | HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | historyOverdue.setReceivableAmount(lastRemain); |
| | | historyOverdue.setPaymentTime(payDate); |
| | | historyOverdue.setCompId(schedule.getCompId()); |
| | | historyOverdueMapper.insert(historyOverdue); |
| | | //查询历史已付逾期金额 |
| | | List<HistoryOverdue> historyOverdueList = historyOverdueMapper.selectList(Wrappers.<HistoryOverdue>lambdaQuery().eq(HistoryOverdue::getScheduleId, currentOverdue.getScheduleId())); |
| | | BigDecimal hisTotal = historyOverdueList.stream().map(item -> item.getReceivableAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //更新当前逾期 |
| | | currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(hisTotal)); |
| | | currentOverdueMapper.updateById(currentOverdue); |
| | | } |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0) |
| | | .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){ |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() : |
| | | item.getActualAmount()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | contract.setPaidAmount(payTotal); |
| | | // if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | } |
| | | // else { |
| | | // |
| | | // List<Contract> customerContractList = contractService.list(Wrappers.<Contract>lambdaQuery().eq(Contract::getPartyAId, addDTO.getBusGuestId()) |
| | | // .eq(Contract::getPartyBId, SecurityUtils.getUser().getCompId()).orderByAsc(Contract::getCreateTime) |
| | | // .apply(" ((contract_category != 'water_house' and amount != paid_amount) or contract_category = 'water_house')")); |
| | | // if (ArrayUtil.isEmpty(customerContractList.toArray())) { |
| | | // return R.failed("为查询到未付款合同"); |
| | | // } |
| | | // BusinessCustomer customer = businessCustomerService.getOne(Wrappers.<BusinessCustomer>lambdaQuery() |
| | | // .eq(StrUtil.isNotBlank(addDTO.getBusGuestName()), BusinessCustomer::getRegisterName, addDTO.getBusGuestName()) |
| | | // .eq(ObjUtil.isNotNull(addDTO.getBusGuestId()), BusinessCustomer::getId, addDTO.getBusGuestId()) |
| | | // .last("limit 1")); |
| | | // if (ObjUtil.isNull(customer)) { |
| | | // return R.failed("客商查询失败"); |
| | | // } |
| | | // //新增付款单 |
| | | // PaymentSlip slip = new PaymentSlip(); |
| | | // slip.setBusGuestId(customer.getId()); |
| | | // slip.setBusGuestName(customer.getRegisterName()); |
| | | // slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | // slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | // slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | | // slip.setPayType(addDTO.getPayType()); |
| | | // paymentSlipMapper.insert(slip); |
| | | // |
| | | // BigDecimal transtionAmount = addDTO.getTransationAmount(); |
| | | // //剩余付款 |
| | | // BigDecimal transtionRemainAmount = transtionAmount; |
| | | // //收到付款的合同 |
| | | // List<Contract> payContractList = new ArrayList<>(); |
| | | // //付款完成的合同 |
| | | // List<Contract> payCompleteContractList = new ArrayList<>(); |
| | | // //付款未完成的合同 |
| | | // List<Contract> payNoCompleteContractList = new ArrayList<>(); |
| | | // //有预付款的合同 |
| | | // List<Contract> advanceContractList = new ArrayList<>(); |
| | | // //付款时间 |
| | | // Date payDate = addDTO.getConfirmTime(); |
| | | // Iterator<Contract> iterator = customerContractList.iterator(); |
| | | // while (iterator.hasNext()) { |
| | | // Contract contract = iterator.next(); |
| | | // PaymentConfirm lastConfirm = baseMapper.selectOne(Wrappers.<PaymentConfirm>lambdaQuery().eq(PaymentConfirm::getContractId, contract.getId()) |
| | | // .orderByDesc(PaymentConfirm::getCreateTime).last("limit 1")); |
| | | // BigDecimal lastTotal = new BigDecimal("0"); |
| | | // if (ObjUtil.isNotNull(lastConfirm)) { |
| | | // lastTotal = lastConfirm.getTotalAmount(); |
| | | // } else { |
| | | // |
| | | // } |
| | | // |
| | | // //合同最近明细总额为0 或 > 0 情况下 |
| | | // if (lastTotal.compareTo(new BigDecimal("0")) >= 0) { |
| | | // log.info("当前合同号:{},明细总额无应收款", contract.getContractNo()); |
| | | // advanceContractList.add(contract); |
| | | // if (iterator.hasNext()) { |
| | | // continue; |
| | | // } |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | payCompleteContractList.add(contract); |
| | | } |
| | | //付款 且 付款未全付 |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) > 0) { |
| | | payNoCompleteContractList.add(contract); |
| | | } |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory())&&StrUtil.equals(contract.getContractCategory(),"water_house")){ |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | .eq(ContractExecDate::getContractId,contract.getId()).eq(ContractExecDate::getGenFlag,"0")); |
| | | if (ArrayUtil.isEmpty(execDateList.toArray())){ |
| | | List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray())&&contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | contract.setContractStatus(3); |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | | }else { |
| | | contractService.updateById(contract); |
| | | } |
| | | |
| | | } |
| | | }); |
| | | // } |
| | | // |
| | | // transtionRemainAmount = transtionRemainAmount.add(lastTotal); |
| | | // PaymentConfirm entity = new PaymentConfirm(); |
| | | // entity.setContractId(contract.getId()); |
| | | // entity.setContractName(contract.getContractName()); |
| | | // entity.setContractNo(contract.getContractNo()); |
| | | // if (ObjUtil.isNotNull(lastConfirm)) { |
| | | // entity.setScheduleId(lastConfirm.getScheduleId()); |
| | | // entity.setScheduleName(lastConfirm.getScheduleName()); |
| | | // } |
| | | // entity.setBusGuestId(customer.getId()); |
| | | // entity.setBusGuestName(customer.getRegisterName()); |
| | | // entity.setBusinessType("客户付款"); |
| | | // if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | | // entity.setConfirmTime(payDate); |
| | | // // 判断是否是最后一个 |
| | | // if (!iterator.hasNext()) { |
| | | // entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | // entity.setAdvanceAmount(transtionRemainAmount); |
| | | // entity.setTotalAmount(transtionRemainAmount); |
| | | // } else { |
| | | // entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | // entity.setTotalAmount(new BigDecimal("0")); |
| | | // } |
| | | // baseMapper.insert(entity); |
| | | // payContractList.add(contract); |
| | | // } else if (transtionRemainAmount.compareTo(new BigDecimal("0")) == 0) { |
| | | // entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | // entity.setTotalAmount(new BigDecimal("0")); |
| | | // entity.setConfirmTime(payDate); |
| | | // baseMapper.insert(entity); |
| | | // payContractList.add(contract); |
| | | // break; |
| | | // } else { |
| | | // entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | // entity.setReceivableAmount(transtionRemainAmount.multiply(new BigDecimal("-1"))); |
| | | // entity.setTotalAmount(transtionRemainAmount); |
| | | // entity.setConfirmTime(payDate); |
| | | // baseMapper.insert(entity); |
| | | // payContractList.add(contract); |
| | | // break; |
| | | // } |
| | | // } |
| | | // |
| | | // payContractList.stream().forEach(contract -> { |
| | | // //更新付款阶段付款 |
| | | // List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | // .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | // .ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | // .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | // if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | // BigDecimal remain = transtionAmount; |
| | | // for (ContractPaymentSchedule schedule : scheduleList) { |
| | | // BigDecimal lastRemain = remain; |
| | | // remain = lastRemain.subtract(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount() : |
| | | // schedule.getPlannedAmount().subtract(schedule.getActualAmount())); |
| | | // if (remain.compareTo(new BigDecimal("0")) >= 0) { |
| | | // schedule.setActualAmount(schedule.getPlannedAmount()); |
| | | // schedule.setPaymentDate(payDate); |
| | | // schedule.setPaymentStatus(2); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | // //查询是否有当前逾期 |
| | | // CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | // .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | // if (ObjUtil.isNotNull(currentOverdue)) { |
| | | // //新增逾期历史 |
| | | // HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | // historyOverdue.setPaymentTime(payDate); |
| | | // historyOverdue.setCompId(schedule.getCompId()); |
| | | // historyOverdueMapper.insert(historyOverdue); |
| | | // //删除当前逾期 |
| | | // currentOverdueMapper.deleteById(currentOverdue); |
| | | // } |
| | | // } else { |
| | | // schedule.setActualAmount(StrUtil.equals(schedule.getPaymentStatus() + "", "0") ? schedule.getPlannedAmount().add(remain) : |
| | | // schedule.getActualAmount().add(lastRemain)); |
| | | // schedule.setPaymentDate(payDate); |
| | | // schedule.setPaymentStatus(1); |
| | | // contractPaymentScheduleMapper.updateById(schedule); |
| | | // //查询是否有当前逾期 |
| | | // CurrentOverdue currentOverdue = currentOverdueMapper.selectOne(Wrappers.<CurrentOverdue>lambdaQuery().eq(CurrentOverdue::getScheduleId, schedule.getId()) |
| | | // .eq(CurrentOverdue::getContractId, schedule.getContractId()).last("limit 1")); |
| | | // if (ObjUtil.isNotNull(currentOverdue)) { |
| | | // //新增逾期历史 |
| | | // HistoryOverdue historyOverdue = BeanUtil.copyProperties(currentOverdue, HistoryOverdue.class, "id"); |
| | | // historyOverdue.setReceivableAmount(lastRemain); |
| | | // historyOverdue.setPaymentTime(payDate); |
| | | // historyOverdue.setCompId(schedule.getCompId()); |
| | | // historyOverdueMapper.insert(historyOverdue); |
| | | // //查询历史已付逾期金额 |
| | | // List<HistoryOverdue> historyOverdueList = historyOverdueMapper.selectList(Wrappers.<HistoryOverdue>lambdaQuery().eq(HistoryOverdue::getScheduleId, currentOverdue.getScheduleId())); |
| | | // BigDecimal hisTotal = historyOverdueList.stream().map(item -> item.getReceivableAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // //更新当前逾期 |
| | | // currentOverdue.setReceivableAmount(schedule.getPlannedAmount().subtract(hisTotal)); |
| | | // currentOverdueMapper.updateById(currentOverdue); |
| | | // } |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // //合同所有付款阶段 |
| | | // List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | // .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0) |
| | | // .ne(ContractPaymentSchedule::getPaymentStatus, 3)); |
| | | // if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())) { |
| | | // BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "2") ? item.getPlannedAmount() : |
| | | // item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // contract.setPaidAmount(payTotal); |
| | | //// if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | //// contract.setContractStatus(3); |
| | | //// } |
| | | // if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | // |
| | | // contract.setContractStatus(3); |
| | | // payCompleteContractList.add(contract); |
| | | // } |
| | | // //付款 且 付款未全付 |
| | | // if (contract.getAmount().compareTo(contract.getPaidAmount()) > 0) { |
| | | // payNoCompleteContractList.add(contract); |
| | | // } |
| | | // if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | // List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | // .eq(ContractExecDate::getContractId, contract.getId()).eq(ContractExecDate::getGenFlag, "0")); |
| | | // if (ArrayUtil.isEmpty(execDateList.toArray())) { |
| | | // List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | // .eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | // if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray()) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | // contractService.updateById(contract); |
| | | // } |
| | | // } |
| | | // } else { |
| | | // contractService.updateById(contract); |
| | | // } |
| | | // |
| | | // } |
| | | // }); |
| | | |
| | | //客户预付有剩余 且 有预付款的合同 |
| | | // if (transtionRemainAmount.compareTo(new BigDecimal("0")) > 0) { |
| | |
| | | // |
| | | // } |
| | | // } |
| | | } |
| | | // } |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | String result = HttpUtil.post(url + "/yonbip/EFI/collection/list?access_token=" + finalAccessToken, params.toJSONString()); |
| | | log.info("SK_CX Response:{}", result); |
| | | //保存请求记录 |
| | | saveBipRequestRecord(params,"<XSJZ_SK_CX_001>-收款单查询接口", result); |
| | | saveBipRequestRecord(params, "<XSJZ_SK_CX_001>-收款单查询接口", result); |
| | | JSONObject resultJson = JSONObject.parseObject(result); |
| | | if (resultJson.containsKey("code") && resultJson.getString("code").equals("200")) { |
| | | handleAndSave(bipCode, resultJson); |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | private JSONObject genParams(String bipCode){ |
| | | private JSONObject genParams(String bipCode) { |
| | | JSONObject params = new JSONObject(); |
| | | params.put("pageIndex", 1); |
| | | params.put("pageSize", 999); |
| | |
| | | return; |
| | | } |
| | | //保存付款单 |
| | | Boolean codeFlag = savePaymentSlip(customer,record,dept); |
| | | if (codeFlag){ |
| | | Boolean codeFlag = savePaymentSlip(customer, record, dept); |
| | | if (codeFlag) { |
| | | log.error("付款单id:{},付款单已存在"); |
| | | return; |
| | | } |
| | |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setAdvanceAmount(transtionRemainAmount); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | }else { |
| | | } else { |
| | | entity.setTransationAmount(lastTotal.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(new BigDecimal("0")); |
| | | } |
| | |
| | | } |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus,3) |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | ); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())){ |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item->StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() : |
| | | item.getActualAmount()).reduce(BigDecimal.ZERO,BigDecimal::add); |
| | | if (ArrayUtil.isNotEmpty(payComScheduleList.toArray())) { |
| | | BigDecimal payTotal = payComScheduleList.stream().map(item -> StrUtil.equals(item.getPaymentStatus() + "", "0") ? item.getPlannedAmount() : |
| | | item.getActualAmount()).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | contract.setPaidAmount(payTotal); |
| | | // if (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | |
| | | // payCompleteContractList.add(contract); |
| | | // } |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | contract.setBillingStatus("2"); |
| | | // contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | payCompleteContractList.add(contract); |
| | | } |
| | |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) > 0) { |
| | | payNoCompleteContractList.add(contract); |
| | | } |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory())&&StrUtil.equals(contract.getContractCategory(),"water_house")){ |
| | | if (StrUtil.isNotEmpty(contract.getContractCategory()) && StrUtil.equals(contract.getContractCategory(), "water_house")) { |
| | | List<ContractExecDate> execDateList = contractExecDateMapper.selectList(Wrappers.<ContractExecDate>lambdaQuery() |
| | | .eq(ContractExecDate::getContractId,contract.getId()).eq(ContractExecDate::getGenFlag,"0")); |
| | | if (ArrayUtil.isEmpty(execDateList)){ |
| | | .eq(ContractExecDate::getContractId, contract.getId()).eq(ContractExecDate::getGenFlag, "0")); |
| | | if (ArrayUtil.isEmpty(execDateList)) { |
| | | List<ContractPaymentSchedule> contractPaymentScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId())); |
| | | if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray())&&contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | if (ArrayUtil.isNotEmpty(contractPaymentScheduleList.toArray()) && contractPaymentScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | contract.setContractStatus(3); |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | | }else { |
| | | } else { |
| | | contractService.updateById(contract); |
| | | } |
| | | } |
| | |
| | | // } |
| | | } |
| | | |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record,SysDept dept) { |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record, SysDept dept) { |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getRegisterName()); |
| | | slip.setPayee(dept.getName()); |
| | | slip.setPayeeCompId(dept.getDeptId()); |
| | | slip.setPaymentTime(ObjUtil.isNotNull(record.get("billDate"))? |
| | | DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT):new Date()); |
| | | slip.setPaymentAmount(ObjUtil.isNotNull(record.get("bodyItemOriTaxExcludedAmount"))?record.getBigDecimal("bodyItemOriTaxExcludedAmount"):new BigDecimal("0")); |
| | | slip.setPayType(ObjUtil.isNotNull(record.get("bodyItemSettleModeName"))?record.getString("bodyItemSettleModeName"):""); |
| | | if (ObjUtil.isNotNull(record.get("code"))){ |
| | | slip.setPaymentTime(ObjUtil.isNotNull(record.get("billDate")) ? |
| | | DateUtil.parse(record.getString("billDate"), DatePattern.NORM_DATETIME_FORMAT) : new Date()); |
| | | slip.setPaymentAmount(ObjUtil.isNotNull(record.get("bodyItemOriTaxExcludedAmount")) ? record.getBigDecimal("bodyItemOriTaxExcludedAmount") : new BigDecimal("0")); |
| | | slip.setPayType(ObjUtil.isNotNull(record.get("bodyItemSettleModeName")) ? record.getString("bodyItemSettleModeName") : ""); |
| | | if (ObjUtil.isNotNull(record.get("code"))) { |
| | | slip.setPaymentNumber(record.getString("code")); |
| | | PaymentSlip paymentSlip = paymentSlipMapper.selectOne(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getPaymentNumber,slip.getPaymentNumber())); |
| | | PaymentSlip paymentSlip = paymentSlipMapper.selectOne(Wrappers.<PaymentSlip>lambdaQuery().eq(PaymentSlip::getPaymentNumber, slip.getPaymentNumber())); |
| | | if (ObjUtil.isNull(paymentSlip)) { |
| | | paymentSlipMapper.insert(slip); |
| | | return false; |
| | |
| | | return true; |
| | | } |
| | | |
| | | public void saveNewPaymentConfirm(BusinessCustomer customer,JSONObject record,Contract contract,BigDecimal transtionRemainAmount |
| | | ,Date payDate){ |
| | | public void saveNewPaymentConfirm(BusinessCustomer customer, JSONObject record, Contract contract, BigDecimal transtionRemainAmount |
| | | , Date payDate) { |
| | | PaymentConfirm entity = new PaymentConfirm(); |
| | | entity.setContractId(contract.getId()); |
| | | entity.setContractName(contract.getContractName()); |
| | |
| | | entity.setBusGuestId(customer.getId()); |
| | | entity.setBusGuestName(customer.getRegisterName()); |
| | | entity.setBusinessType("客户付款"); |
| | | if (ObjUtil.isNotNull(record)){ |
| | | if (ObjUtil.isNotNull(record)) { |
| | | entity.setIsBip(1); |
| | | entity.setPaymentCode(record.getString("code")); |
| | | entity.setPayType(record.get("bodyItemSettleModeName") != null ? record.getString("bodyItemSettleModeName").contains("承兑汇票") ? 1 : 0 : null); |
| | |
| | | entity.setConfirmTime(payDate); |
| | | entity.setTransationAmount(transtionRemainAmount); |
| | | entity.setTotalAmount(transtionRemainAmount.add(lastTotal)); |
| | | if (entity.getTotalAmount().compareTo(new BigDecimal("0"))>0){ |
| | | if (entity.getTotalAmount().compareTo(new BigDecimal("0")) > 0) { |
| | | entity.setAdvanceAmount(entity.getTotalAmount()); |
| | | }else if (entity.getTotalAmount().compareTo(new BigDecimal("0"))<0){ |
| | | } else if (entity.getTotalAmount().compareTo(new BigDecimal("0")) < 0) { |
| | | entity.setReceivableAmount(entity.getTotalAmount().multiply(new BigDecimal("-1"))); |
| | | } |
| | | baseMapper.insert(entity); |
| | |
| | | @Override |
| | | public R queryAllBusinessType() { |
| | | return R.ok(baseMapper.selectList(Wrappers.<PaymentConfirm>lambdaQuery().select(PaymentConfirm::getBusinessType).isNotNull(PaymentConfirm::getBusinessType) |
| | | .groupBy(PaymentConfirm::getBusinessType)).stream().map(PaymentConfirm::getBusinessType).collect(Collectors.toList())); |
| | | .groupBy(PaymentConfirm::getBusinessType)).stream().map(PaymentConfirm::getBusinessType).collect(Collectors.toList())); |
| | | } |
| | | |
| | | @Override |
| | | public R queryAging() { |
| | | List<AgingCompanyVo> companys = contractPaymentScheduleMapper.selectAgingCompany(null,DataScope.of("comp_id")); |
| | | if (ArrayUtil.isEmpty(companys.toArray())){ |
| | | List<AgingCompanyVo> companys = contractPaymentScheduleMapper.selectAgingCompany(null, DataScope.of("comp_id")); |
| | | if (ArrayUtil.isEmpty(companys.toArray())) { |
| | | return R.failed("暂无账龄"); |
| | | } |
| | | List<AgingAnalysisVo> result = new ArrayList<>(); |
| | | AgingQueryDTO queryDTO = new AgingQueryDTO(); |
| | | List<AgingVo> agingVoList = contractPaymentScheduleMapper.selectAgingTotal(null); |
| | | companys.stream().forEach(company->{ |
| | | companys.stream().forEach(company -> { |
| | | BusinessCustomer businessCustomer = businessCustomerService.getById(company.getCompanyId()); |
| | | AgingAnalysisVo agingAnalysisVo = new AgingAnalysisVo(); |
| | | agingAnalysisVo.setCompanyName(businessCustomer.getCompanyName()); |
| | | queryDTO.setCompanyId(company.getCompanyId()); |
| | | List<AgingVo> companyAgingVo = contractPaymentScheduleMapper.selectAgingTotal(queryDTO); |
| | | //补全数据 |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())){ |
| | | if (ArrayUtil.isEmpty(companyAgingVo.toArray())) { |
| | | companyAgingVo = new ArrayList<>(); |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | companyAgingVo.add(agingVo2); |
| | | companyAgingVo.add(agingVo3); |
| | | companyAgingVo.add(agingVo4); |
| | | companyAgingVo.add(agingVo5); |
| | | companyAgingVo.add(agingVo6); |
| | | }else { |
| | | } else { |
| | | List<String> overdueRanges = companyAgingVo.stream().map(AgingVo::getOverdueRange).collect(Collectors.toList()); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"0-30天")){ |
| | | AgingVo agingVo1 = new AgingVo("0-30天",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "0-30天")) { |
| | | AgingVo agingVo1 = new AgingVo("0-30天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo1); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"31-60天")){ |
| | | AgingVo agingVo2 = new AgingVo("31-60天",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "31-60天")) { |
| | | AgingVo agingVo2 = new AgingVo("31-60天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo2); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"61-90天")){ |
| | | AgingVo agingVo3 = new AgingVo("61-90天",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "61-90天")) { |
| | | AgingVo agingVo3 = new AgingVo("61-90天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo3); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"91-180天")){ |
| | | AgingVo agingVo4 = new AgingVo("91-180天",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "91-180天")) { |
| | | AgingVo agingVo4 = new AgingVo("91-180天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo4); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"181-365天")){ |
| | | AgingVo agingVo5 = new AgingVo("181-365天",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "181-365天")) { |
| | | AgingVo agingVo5 = new AgingVo("181-365天", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo5); |
| | | } |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(),"1年以上")){ |
| | | AgingVo agingVo6 = new AgingVo("1年以上",new BigDecimal("0"),null); |
| | | if (!ArrayUtil.contains(overdueRanges.toArray(), "1年以上")) { |
| | | AgingVo agingVo6 = new AgingVo("1年以上", new BigDecimal("0"), null); |
| | | companyAgingVo.add(agingVo6); |
| | | } |
| | | } |
| | |
| | | |
| | | if (agingAnalysisVo.getAmount().get(i) == null || agingAnalysisVo.getAmount().get(i).compareTo(BigDecimal.ZERO) == 0) { |
| | | return null; |
| | | }else { |
| | | } else { |
| | | return new BigDecimal("100"); |
| | | } |
| | | }) |