@Transactional(rollbackFor = {Exception.class, RuntimeException.class})
  public synchronized void updateClaimPayPlan(String orderId, boolean isResult) {
    List<AccountOrder> accountOrderList = accountOrderRepository.findByCashFlowId(orderId);
    AccountOrder accountOrder = accountOrderList.get(0);

    Long count =
        accountOrderRepository.getCountPayPlanNotSuccess(
            accountOrder.getCommodityTablePrimaryKeyValue());
    if (count == 0) {
      ClaimPayPlan claimPayPlan =
          claimPayPlanRepository.findOne(accountOrder.getCommodityTablePrimaryKeyValue());

      // 取得项目的借款人
      Long loanDataSequence = null;
      LoanData loanData = null;
      LoanCut loanCut = null;

      List<InvestmentAccountReference> investmentAccountReferenceList =
          investmentAccountReferenceRepository.findByInvestmentSequence(
              claimPayPlan.getInvestmentSequence());
      if (!CollectionUtil.isEmpty(investmentAccountReferenceList)) {
        loanDataSequence = investmentAccountReferenceList.get(0).getLoanDataSequence();
        loanData = loanDataRepository.findOne(loanDataSequence);

        if (loanData != null) {
          loanCut =
              loanCutRepository.findByInvestmentBusinessCodeAndLoanPeriod(
                  loanData.getInvestmentBusinessCode(), claimPayPlan.getClaimPayPlanNumber());
        }
      }

      if (loanCut != null
          && loanCut.getTotalShouldGet().compareTo(loanCut.getTotalActulGet()) == 0) {
        // 若垫付时借款人已还
        claimPayPlan.setClaimPayPlanStatus(ClaimPayPlanStatusEnum.PAID.getCode());
        claimPayPlan.setRecordEditDate(new Date());
        claimPayPlanRepository.save(claimPayPlan);

        Investment investment = investmentRepository.findOne(claimPayPlan.getInvestmentSequence());
        // 期数
        final int investmentPeriod =
            Integer.valueOf(
                dictionaryUtil.getDicChinaMean(
                    DictionaryEnum.T_INV.getCode()
                        + DictionaryEnum.T_INV_INV_PERIOD.getCode()
                        + investment.getInvestmentPeriod()));
        // 最后一期还款成功
        if (investmentPeriod == claimPayPlan.getClaimPayPlanNumber().intValue()) {
          investment.setInvestmentStatus(InvestmentStatusEnum.REPAY_FINISH.getCode());
          investment.setInvestmentOverDate(new Date());
          investmentRepository.save(investment);
        }
      } else {
        // final Date sysDate = dealRepository.getSystemTime();
        // 更新债权还款计划状态-〉 逾期已垫付
        claimPayPlan.setClaimPayPlanStatus(ClaimPayPlanStatusEnum.OVERDUE_PAID.getCode());
        claimPayPlan.setRecordEditDate(new Date());
        claimPayPlanRepository.save(claimPayPlan);

        insertClaimPayPlanHistory(new Date(), claimPayPlan);
      }
    }
  }