shiyunteng
2026-09-04 c427840445fefb679a287dbeaba81bd417388aeb
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/OutBoundServiceImpl.java
@@ -337,18 +337,6 @@
//                     beforeSchedule.setEffectiveEndDate(schedule.getEffectiveDate());
//                     scheduleMapper.updateById(beforeSchedule);
//                  }
                  //更新履约
                  ContractPaymentScheduleProcess contractPaymentScheduleProcess = new ContractPaymentScheduleProcess();
                  contractPaymentScheduleProcess.setContractId(schedule.getContractId());
                  contractPaymentScheduleProcess.setContractName(schedule.getContractName());
                  contractPaymentScheduleProcess.setScheduleId(schedule.getId());
                  contractPaymentScheduleProcess.setScheduleName(schedule.getStageName());
                  contractPaymentScheduleProcess.setProcessDate(addDTO.getOutBoundTime());
                  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);
                  }
               }
               //查询是否有后续阶段
@@ -479,6 +467,7 @@
      Contract contract = r.getData();
      //出库
      handleOutBound(contract,addDTO);
      //保存资金明细
      BigDecimal outBoundAmount = savePaymentConfirm(contract,addDTO);
      //更新合同状态及阶段
@@ -502,15 +491,17 @@
   private BigDecimal savePaymentConfirm(Contract contract,OutBoundAddDTO addDTO) {
      //查询合同是否有出库阶段
      ContractPaymentSchedule schedule = scheduleMapper.selectOne(Wrappers.<ContractPaymentSchedule>lambdaQuery().eq(ContractPaymentSchedule::getContractId, contract.getId())
            .eq(ContractPaymentSchedule::getStageName, "发货前").gt(ContractPaymentSchedule::getPaymentRatio,0).last("limit 1"));
            .eq(ContractPaymentSchedule::getStageName, "发货前").last("limit 1"));
      if (ObjUtil.isNull(schedule.getEffectiveDate())&&ObjUtil.isNull(schedule.getEffectiveEndDate())){
         schedule.setEffectiveDate(addDTO.getOutBoundTime());
         schedule.setEffectiveEndDate(DateUtil.offsetDay(addDTO.getOutBoundTime(),schedule.getAgreedDays()));
         scheduleMapper.updateById(schedule);
      }
      //履约几率
      processService.saveScheduleProcess(addDTO.getOutBoundTime(),schedule);
      BigDecimal outAmount = new BigDecimal("0");
      //计算出库价格
      BigDecimal outAmount = new BigDecimal("0");
      for (OutSubjectMatterAddDTO outSubjectMatterAddDTO : addDTO.getSubjectMatterList()) {
         ContractSubjectMatter subjectMatter = contractSubjectMatterMapper.selectOne(Wrappers.<ContractSubjectMatter>lambdaQuery()
               .eq(ContractSubjectMatter::getContractId, contract.getId())
@@ -520,7 +511,7 @@
         outAmount = outAmount.add(outSubjectMatterAddDTO.getOutBoundNum().multiply(subjectMatter.getUnitPrice()));
      }
      //存在发货前收款阶段
      if (ObjUtil.isNotNull(schedule)) {
      if (schedule.getPaymentRatio().compareTo(new BigDecimal("0")) > 0) {
         //新增当前阶段应收
         PaymentConfirm currentConfim = new PaymentConfirm();
         currentConfim.setBusinessType(schedule.getStageName() + "应收");