shiyunteng
2026-05-25 633a003d232e37c79b7135ccda35eda1c69952c6
platformx-business-finance-biz/src/main/java/com/by4cloud/platformx/business/service/impl/PaymentOffsetServiceImpl.java
@@ -77,7 +77,7 @@
      //更新付款阶段付款
      List<ContractPaymentSchedule> scheduleList = contractPaymentScheduleMapper.selectList(Wrappers.<ContractPaymentSchedule>lambdaQuery()
            .eq(ContractPaymentSchedule::getContractId,contract.getId()).ne(ContractPaymentSchedule::getPaymentStatus,2)
            .orderByAsc(ContractPaymentSchedule::getCreateTime));
            .ne(ContractPaymentSchedule::getPaymentStatus,3).orderByAsc(ContractPaymentSchedule::getCreateTime));
      if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
         BigDecimal remain = paymentOffset.getOffsetAmount();
         for (ContractPaymentSchedule schedule:scheduleList) {
@@ -135,17 +135,18 @@
      }
      paid = paid.add(paymentOffset.getOffsetAmount());
      contract.setPaidAmount(paid);
      if (paid.compareTo(contract.getAmount())>0){
         contract.setPaidAmount(contract.getAmount());
      if (paid.compareTo(contract.getAmount())==0){
         contract.setBillingStatus("2");
         contract.setContractStatus(3);
      }
      contractService.updateById(contract);
      // 查询所有付款阶段是否都付款完成
      if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
         if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){
            contract.setContractStatus(3);
            contractService.updateById(contract);
         };
      }
//      if (ArrayUtil.isNotEmpty(scheduleList.toArray())){
//         if (scheduleList.stream().allMatch(item -> Objects.equals(item.getPaymentStatus(), 2))){
//            contract.setContractStatus(3);
//            contractService.updateById(contract);
//         };
//      }
      return R.ok();
   }
}