shiyunteng
2026-05-25 633a003d232e37c79b7135ccda35eda1c69952c6
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
@@ -269,21 +269,21 @@
               //更新发货前收款生效时间
               if (ObjUtil.isNull(schedule.getEffectiveDate())) {
                  schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                  schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                  //查询是否有后续阶段
                  List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId)
                        .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()));
                  if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                     schedule.setEffectiveEndDate(contract.getExpirationDate());
                  }
//                  List<ContractPaymentSchedule> afterSchedule = scheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contractId)
//                        .gt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()));
//                  if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
//                     schedule.setEffectiveEndDate(contract.getExpirationDate());
//                  }
                  scheduleMapper.updateById(schedule);
                  //查询是否有之前阶段
                  ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
                        .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
                  if (ObjUtil.isNotNull(beforeSchedule)) {
                     beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
                     scheduleMapper.updateById(beforeSchedule);
                  }
//                  ContractPaymentSchedule beforeSchedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, schedule.getContractId())
//                        .lt(ContractPaymentSchedule::getStageOrder, schedule.getStageOrder()).orderByDesc(ContractPaymentSchedule::getCreateTime).last("limit 1"));
//                  if (ObjUtil.isNotNull(beforeSchedule)) {
//                     beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
//                     scheduleMapper.updateById(beforeSchedule);
//                  }
                  //更新履约
                  ContractPaymentScheduleProcess contractPaymentScheduleProcess = new ContractPaymentScheduleProcess();
                  contractPaymentScheduleProcess.setContractId(schedule.getContractId());
@@ -291,7 +291,11 @@
                  contractPaymentScheduleProcess.setScheduleId(schedule.getId());
                  contractPaymentScheduleProcess.setScheduleName(schedule.getStageName());
                  contractPaymentScheduleProcess.setProcessDate(addDTO.getOutBoundTime());
                  scheduleProcessMapper.insert(contractPaymentScheduleProcess);
                  ContractPaymentScheduleProcess lastProcess = scheduleProcessMapper.selectOne(Wrappers.<ContractPaymentScheduleProcess>lambdaQuery().eq(ContractPaymentScheduleProcess::getContractId, schedule.getContractId())
                        .eq(ContractPaymentScheduleProcess::getScheduleId, schedule.getId()).last("limit 1"));
                  if (ObjUtil.isNull(lastProcess)) {
                     scheduleProcessMapper.insert(contractPaymentScheduleProcess);
                  }
               }
               //查询是否有后续阶段
@@ -303,13 +307,11 @@
                  //最后阶段生效时间
                  ContractPaymentSchedule endSchedule = afterSchedule.get(0);
                  if (StrUtil.equals(endSchedule.getStageName(), "质保金")) {
                     endSchedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays()));
                     endSchedule.setEffectiveEndDate(contract.getExpirationDate());
                     scheduleMapper.updateById(endSchedule);
//                     endSchedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), endSchedule.getAgreedDays()));
//                     scheduleMapper.updateById(endSchedule);
                     //当前阶段生效时间
                     schedule.setEffectiveDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
                     schedule.setEffectiveEndDate(endSchedule.getEffectiveDate());
                     scheduleMapper.updateById(schedule);
//                     schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(), schedule.getAgreedDays()));
//                     scheduleMapper.updateById(schedule);
                     //最后阶段应收
                     PaymentConfirm newConfim = new PaymentConfirm();
                     newConfim.setBusinessType(endSchedule.getStageName() + "应收");
@@ -344,8 +346,8 @@
                  contractMapper.updateById(contract);
               }
               if (ArrayUtil.isEmpty(afterSchedule.toArray())) {
                  schedule.setEffectiveEndDate(contract.getExpirationDate());
                  scheduleMapper.updateById(schedule);
//                  schedule.setEffectiveEndDate(contract.getExpirationDate());
//                  scheduleMapper.updateById(schedule);
                  //更新合同下个阶段
                  contract.setNextScheduleName("无");
                  contractMapper.updateById(contract);