| | |
| | | baseMapper.updateById(contract); |
| | | ContractPaymentSchedule fitstSchedule = contractPaymentScheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId,contract.getId()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime).last("limit 1")); |
| | | // PaymentConfirm entity = new PaymentConfirm(); |
| | | // entity.setContractId(contract.getId()); |
| | | // entity.setContractName(contract.getContractName()); |
| | | // entity.setContractNo(contract.getContractNo()); |
| | | // entity.setBusGuestId(contract.getPartyAId()); |
| | | // entity.setBusGuestName(contract.getPartyA()); |
| | | // entity.setBusinessType(fitstSchedule.getStageName()+"应收"); |
| | | // entity.setTransationAmount(new BigDecimal(fitstSchedule.getPlannedAmount())); |
| | | // entity.setReceivableAmount(new BigDecimal(fitstSchedule.getPlannedAmount())); |
| | | // entity.setTotalAmount(new BigDecimal("0").subtract(new BigDecimal(fitstSchedule.getPlannedAmount()))); |
| | | // entity.setConfirmTime(new Date()); |
| | | // paymentConfirmMapper.insert(entity); |
| | | |
| | | if (fitstSchedule.getStageName().equals("合同签订")){ |
| | | //新增应收 |
| | | PaymentConfirm paymentConfirm = new PaymentConfirm(); |
| | |
| | | //查询是否有后续阶段 |
| | | List<ContractPaymentSchedule> afterSchedule = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery() |
| | | .eq(ContractPaymentSchedule::getContractId, fitstSchedule.getContractId()) |
| | | .gt(ContractPaymentSchedule::getStageOrder, fitstSchedule.getStageOrder())); |
| | | .gt(ContractPaymentSchedule::getStageOrder, fitstSchedule.getStageOrder()) |
| | | .orderByAsc(ContractPaymentSchedule::getCreateTime)); |
| | | if (ArrayUtil.isNotEmpty(afterSchedule.toArray())&&afterSchedule.size()==1){ |
| | | //最后阶段生效时间 |
| | | ContractPaymentSchedule endSchedule = afterSchedule.get(0); |
| | | if (StrUtil.equals(endSchedule.getStageName(),"质保金")){ |
| | | endSchedule.setEffectiveDate(DateUtil.offsetDay(new Date(),endSchedule.getAgreedDays())); |
| | | endSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(endSchedule); |
| | |
| | | newConfim.setTotalAmount(lastNewTotal.subtract(newConfim.getReceivableAmount())); |
| | | paymentConfirmMapper.insert(newConfim); |
| | | } |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(endSchedule.getStageName()); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | if(ArrayUtil.isNotEmpty(afterSchedule.toArray())&&afterSchedule.size()>1){ |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName(afterSchedule.get(0).getStageName()); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | if(ArrayUtil.isEmpty(afterSchedule.toArray())){ |
| | | fitstSchedule.setEffectiveEndDate(contract.getExpirationDate()); |
| | | contractPaymentScheduleMapper.updateById(fitstSchedule); |
| | | //更新合同下个阶段 |
| | | contract.setNextScheduleName("无"); |
| | | baseMapper.updateById(contract); |
| | | } |
| | | return Boolean.TRUE; |
| | | } |