| | |
| | | } |
| | | } |
| | | if (ArrayUtil.isNotEmpty(outAmountList.toArray())) { |
| | | BigDecimal currentSum = new BigDecimal("0"); |
| | | for (BigDecimal currentAmount : outAmountList |
| | | ) { |
| | | currentSum = currentSum.add(currentAmount); |
| | | BigDecimal currentInSum = outAmountList.stream().reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //新增当前合同 资金转入 |
| | | PaymentConfirm inConfirm = BeanUtil.copyProperties(paymentConfirm, PaymentConfirm.class, "id", "transationAmount", |
| | | "advanceAmount", "receivableAmount", "overdueAmount", "totalAmount"); |
| | | inConfirm.setBusinessType("资金转入"); |
| | | inConfirm.setConfirmTime(new Date()); |
| | | inConfirm.setTransationAmount(currentSum.subtract(currentAmount)); |
| | | inConfirm.setTotalAmount(paymentConfirm.getTotalAmount().add(currentSum)); |
| | | inConfirm.setTransationAmount(currentInSum); |
| | | inConfirm.setTotalAmount(paymentConfirm.getTotalAmount().add(currentInSum)); |
| | | //更新当前阶段实际收款 和 收款状态 |
| | | schedule.setActualAmount(inConfirm.getTransationAmount()); |
| | | schedule.setPaymentStatus(2); |
| | | if (inConfirm.getTotalAmount().compareTo(new BigDecimal("0")) > 0) { |
| | | inConfirm.setAdvanceAmount(inConfirm.getTotalAmount()); |
| | | } else if (inConfirm.getTotalAmount().compareTo(new BigDecimal("0")) < 0) { |
| | | inConfirm.setReceivableAmount(inConfirm.getTotalAmount().multiply(new BigDecimal("-1"))); |
| | | schedule.setActualAmount(currentInSum); |
| | | schedule.setPaymentStatus(1); |
| | | } |
| | | paymentConfirmMapper.insert(inConfirm); |
| | | } |
| | | //更新当前阶段实际收款 和 收款状态 |
| | | contractPaymentScheduleMapper.updateById(schedule); |
| | | } |
| | | |
| | | |
| | | }else { |
| | | paymentConfirmMapper.insert(paymentConfirm); |
| | | } |
| | | } |
| | | |