| | |
| | | } |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .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(); |
| | |
| | | ; |
| | | } |
| | | }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())) { |
| | |
| | | if (ObjUtil.isNull(customer)) { |
| | | return R.failed("客商查询失败"); |
| | | } |
| | | //新增付款单 |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | slip.setPayeeCompId(SecurityUtils.getUser().getCompId()); |
| | | slip.setPaymentTime(addDTO.getConfirmTime()); |
| | | slip.setPaymentAmount(addDTO.getTransationAmount()); |
| | | slip.setPayType(addDTO.getPayType()); |
| | | paymentSlipMapper.insert(slip); |
| | | |
| | | BigDecimal transtionAmount = addDTO.getTransationAmount(); |
| | | //剩余付款 |
| | |
| | | break; |
| | | } else { |
| | | entity.setTransationAmount(transtionRemainAmount.subtract(lastTotal)); |
| | | entity.setTotalAmount(transtionAmount); |
| | | entity.setReceivableAmount(transtionRemainAmount.multiply(new BigDecimal("-1"))); |
| | | entity.setTotalAmount(transtionRemainAmount); |
| | | entity.setConfirmTime(payDate); |
| | | baseMapper.insert(entity); |
| | | payContractList.add(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; |
| | |
| | | //合同所有付款阶段 |
| | | 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() + "", "0") ? item.getPlannedAmount() : |
| | | 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 (payComScheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))) { |
| | | // contract.setContractStatus(3); |
| | | // } |
| | | contractService.updateById(contract); |
| | | if (contract.getAmount().compareTo(contract.getPaidAmount()) == 0) { |
| | | contract.setBillingStatus("2"); |
| | | contract.setContractStatus(3); |
| | | payCompleteContractList.add(contract); |
| | | } |
| | | //付款 且 付款未全付 |
| | |
| | | return; |
| | | } |
| | | //保存付款单 |
| | | Boolean codeFlag = savePaymentSlip(customer,record); |
| | | Boolean codeFlag = savePaymentSlip(customer,record,dept); |
| | | if (codeFlag){ |
| | | log.error("付款单id:{},付款单已存在"); |
| | | return; |
| | |
| | | payContractList.stream().forEach(contract -> { |
| | | //更新付款阶段付款 |
| | | List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2) |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 2).ne(ContractPaymentSchedule::getPaymentStatus, 3) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(scheduleList.toArray())) { |
| | | BigDecimal remain = transtionAmount; |
| | |
| | | } |
| | | //合同所有付款阶段 |
| | | List<ContractPaymentSchedule> payComScheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus, 0) |
| | | .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() : |
| | |
| | | } |
| | | } |
| | | |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record) { |
| | | private Boolean savePaymentSlip(BusinessCustomer customer, JSONObject record,SysDept dept) { |
| | | PaymentSlip slip = new PaymentSlip(); |
| | | slip.setBusGuestId(customer.getId()); |
| | | slip.setBusGuestName(customer.getCompanyName()); |
| | | 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")); |