private static boolean checkRechargeResult(CashStream cashStream, String body) throws Exception {

    boolean flag = true;

    Gson gson = new Gson();
    List<Map<String, String>> res = (List<Map<String, String>>) gson.fromJson(body, List.class);

    if ((res == null || res.isEmpty()) && cashStream.getState() == cashStream.STATE_INIT) {
      return true;
    } else if ((res == null || res.isEmpty())) {
      if ("快捷支付充值".equals(cashStream.getDescription())) {
        // 快捷支付充值
        return true;
      } else {
        throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 找不到第三方上对应的记录!");
      }
    }

    String thirdPartyAccount = "";

    if (cashStream.getLenderAccountId() != null) {
      Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());
      if (lender != null) {
        thirdPartyAccount = lender.getThirdPartyAccount();
      }
    } else if (cashStream.getBorrowerAccountId() != null) {
      Borrower borrower = borrowerDao.findByAccountID(cashStream.getBorrowerAccountId());
      if (borrower != null) {
        thirdPartyAccount = borrower.getThirdPartyAccount();
      }
    }

    Map<String, String> result = res.get(0);

    // 处理提现失败退回金额的时候,用了一次描述为“提现退回”的充值操作,因此校验在充值动作里执行
    if ("提现退回".equals(cashStream.getDescription())) {
      // 额度
      String Amount = result.get("Amount");
      String WithdrawMoneymoremore = result.get("WithdrawMoneymoremore");
      String WithdrawsState = result.get("WithdrawsState");
      String LoanNo = result.get("LoanNo");
      boolean accountflag = thirdPartyAccount.equals(WithdrawMoneymoremore);
      boolean loanflag =
          cashStream.getLoanNo() == null
              ? (LoanNo == null ? true : false)
              : cashStream.getLoanNo().equals(LoanNo);
      boolean stateflag =
          cashStream.getState() == CashStream.STATE_SUCCESS && WithdrawsState.equals("2");
      boolean totalflag = cashStream.getChiefamount().compareTo(new BigDecimal(Amount)) == 0;
      flag = flag && loanflag && stateflag && totalflag && accountflag;

      StringBuilder message = new StringBuilder();

      message.append("现金流[ID:" + cashStream.getId() + "]: ");
      if (loanflag == false) {
        message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
      }
      if (stateflag == false) {
        message.append(" 操作状态不一致:[平台" + cashStream.getState() + "][钱多多" + WithdrawsState + "] ");
      }
      if (totalflag == false) {
        message.append(
            " 金额不一致:[平台" + cashStream.getChiefamount().toString() + "][钱多多" + Amount + "] ");
      }
      if (accountflag == false) {
        message.append(" 账户不一致:[平台" + thirdPartyAccount + "][钱多多" + WithdrawMoneymoremore + "] ");
      }

      if (!flag) {
        throw new Exception(message.toString());
      }

      return flag;
    }

    // 额度
    String Amount = result.get("Amount");
    // 乾多多流水号
    String LoanNo = result.get("LoanNo");

    // 充值账号
    String RechargeMoneymoremore = result.get("RechargeMoneymoremore");

    // 充值费用
    String Fee = result.get("Fee");

    // 充值状态
    String RechargeState = result.get("RechargeState");

    boolean accountflag = thirdPartyAccount.equals(RechargeMoneymoremore);

    boolean loanflag =
        cashStream.getLoanNo() == null
            ? (LoanNo == null ? true : false)
            : cashStream.getLoanNo().equals(LoanNo);
    boolean stateflag = false;
    if (RechargeState.equals("0") && cashStream.getState() == 1) {
      return true;
    } else if (RechargeState.equals("1") && cashStream.getState() == 2) {
      stateflag = true;
    } else if (RechargeState.equals("2") && cashStream.getState() == 4) {
      stateflag = true;
    }
    boolean totalflag = false;
    boolean feeflag = false;
    if ("扣费快捷充值".equals(cashStream.getDescription())) {
      totalflag =
          cashStream
                  .getChiefamount()
                  .compareTo((new BigDecimal(Amount)).subtract(new BigDecimal(Fee)))
              == 0;
      feeflag = cashStream.getFee().compareTo(new BigDecimal(0)) == 0;
    } else {
      totalflag = cashStream.getChiefamount().compareTo(new BigDecimal(Amount)) == 0;
      feeflag = cashStream.getFee().negate().compareTo(new BigDecimal(Fee)) == 0;
    }

    flag = flag && loanflag && stateflag && totalflag && feeflag && accountflag;

    StringBuilder message = new StringBuilder();

    message.append("现金流[ID:" + cashStream.getId() + "]: ");
    if (loanflag == false) {
      message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
    }
    if (stateflag == false) {
      message.append(" 操作状态不一致:[平台" + cashStream.getState() + "][钱多多" + RechargeState + "] ");
    }
    if (totalflag == false) {
      message.append(
          " 金额不一致:[平台" + cashStream.getChiefamount().toString() + "][钱多多" + Amount + "] ");
    }
    if (feeflag == false) {
      message.append(" 手续费不一致:[平台" + cashStream.getFee().toString() + "][钱多多" + Fee + "] ");
    }

    if (accountflag == false) {
      message.append(" 账户不一致:[平台" + thirdPartyAccount + "][钱多多" + RechargeMoneymoremore + "] ");
    }

    if (!flag) {
      throw new Exception(message.toString());
    }

    return flag;
  }
  private static boolean checkAwardResult(CashStream cashStream, String body) throws Exception {
    boolean flag = true;
    Gson gson = new Gson();
    List<Map<String, String>> res = (List<Map<String, String>>) gson.fromJson(body, List.class);

    if ((res == null || res.isEmpty())
        && cashStream.getState() == cashStream.STATE_INIT
        && (cashStream.getLoanNo() == null || "".equals(cashStream.getLoanNo()))) {
      return true;
    } else if ((res == null || res.isEmpty())) {
      throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 找不到第三方上对应的记录!");
    }

    String out = innerService.getPlatformMoneymoremore();
    String in = "";

    Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());
    if (lender != null) {
      in = lender.getThirdPartyAccount();
    }

    Map<String, String> result = res.get(0);

    // 付款人乾多多标识
    String LoanOutMoneymoremore = result.get("LoanOutMoneymoremore");

    // 收款人乾多多标识
    String LoanInMoneymoremore = result.get("LoanInMoneymoremore");

    // 额度
    String Amount = result.get("Amount");
    // 乾多多流水号
    String LoanNo = result.get("LoanNo");

    // 转账类型
    String TransferAction = result.get("TransferAction");

    // 转账状态
    String TransferState = result.get("TransferState");

    // 操作状态
    String ActState = result.get("ActState");

    // 还款
    boolean actionflag = TransferAction.equals("2");

    boolean accountflag = out.equals(LoanOutMoneymoremore) && in.equals(LoanInMoneymoremore);

    boolean loanflag =
        cashStream.getLoanNo() == null ? false : cashStream.getLoanNo().equals(LoanNo);

    boolean stateflag = false;
    if (ActState.equals("0") && TransferState.equals("0") && cashStream.getState() == 1) {
      stateflag = true;
    } else if (ActState.equals("1") && TransferState.equals("1") && cashStream.getState() == 2) {
      stateflag = true;
    } else if (ActState.equals("2") && TransferState.equals("1") && cashStream.getState() == 4) {
      stateflag = true;
    } else if (ActState.equals("3") && TransferState.equals("1") && cashStream.getState() == 2) {
      stateflag = true;
    }
    boolean totalflag =
        cashStream.getChiefamount().add(cashStream.getInterest()).compareTo(new BigDecimal(Amount))
            == 0;

    flag = flag && loanflag && stateflag && totalflag && accountflag && actionflag;

    StringBuilder message = new StringBuilder();

    message.append("现金流[ID:" + cashStream.getId() + "]: ");
    if (loanflag == false) {
      message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
    }
    if (stateflag == false) {
      message.append(" 操作状态不一致:[平台" + cashStream.getState() + "][钱多多" + ActState + "] ");
    }
    if (totalflag == false) {
      message.append(
          " 金额不一致:[平台" + cashStream.getChiefamount().toString() + "][钱多多" + Amount + "] ");
    }

    if (accountflag == false) {
      message.append(
          " 账户不一致:[平台 borrower:"
              + out
              + " lender:+"
              + in
              + "][钱多多 borrower:"
              + LoanOutMoneymoremore
              + " lender:"
              + LoanInMoneymoremore
              + "] ");
    }

    if (actionflag == false) {
      message.append(" 行为不一致:[平台 还款][钱多多 投标] ");
    }

    if (!flag) {
      throw new Exception(message.toString());
    }

    return flag;
  }
  public static boolean checkUnFreezeResult(CashStream cashStream, String body) throws Exception {
    boolean flag = true;
    Gson gson = new Gson();
    List<Map<String, String>> res = (List<Map<String, String>>) gson.fromJson(body, List.class);

    if ((res == null || res.isEmpty()) && cashStream.getState() == cashStream.STATE_INIT) {
      return true;
    } else if ((res == null || res.isEmpty())
        && cashStream.getLoanNo() == null
        && !"流标".equals(cashStream.getDescription())) {
      return true;
    } else if ((res == null || res.isEmpty())) {
      throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 流标解冻找不到第三方上对应的记录!");
    }

    String laccount = "";

    Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());
    if (lender != null) {
      laccount = lender.getThirdPartyAccount();
    }

    Map<String, String> result = res.get(0);

    // 付款人乾多多标识
    String LoanOutMoneymoremore = result.get("LoanOutMoneymoremore");

    // 收款人乾多多标识
    String LoanInMoneymoremore = result.get("LoanInMoneymoremore");

    // 额度
    String Amount = result.get("Amount");
    // 乾多多流水号
    String LoanNo = result.get("LoanNo");

    // 转账类型
    String TransferAction = result.get("TransferAction");

    // 转账状态
    String TransferState = result.get("TransferState");

    // 操作状态
    String ActState = result.get("ActState");

    boolean stateflag = false;
    if (TransferState.equals("0")
        && ActState.equals("0")
        && cashStream.getState() == CashStream.STATE_INIT) {
      stateflag = true;
    } else if (TransferState.equals("1")
        && ActState.equals("2")
        && cashStream.getState() == CashStream.STATE_SUCCESS) {
      stateflag = true;
    }

    boolean accountflag = laccount.equals(LoanOutMoneymoremore);

    boolean loanflag =
        cashStream.getLoanNo() == null ? false : cashStream.getLoanNo().equals(LoanNo);

    // 投标
    boolean actionflag = TransferAction.equals("1");

    boolean totalflag = cashStream.getChiefamount().compareTo(new BigDecimal(Amount)) == 0;

    flag = flag && loanflag && totalflag && accountflag && actionflag && stateflag;

    StringBuilder message = new StringBuilder();

    message.append("现金流[ID:" + cashStream.getId() + "]: ");

    if (loanflag == false) {
      message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
    }

    if (totalflag == false) {
      message.append(
          " 金额不一致:[平台" + cashStream.getChiefamount().toString() + "][钱多多" + Amount + "] ");
    }

    if (accountflag == false) {
      message.append(" 账户不一致:[平台:" + laccount + "][钱多多 :" + LoanOutMoneymoremore + "] ");
    }

    if (actionflag == false) {
      message.append(" 行为不一致:[平台 投标][钱多多 还款] ");
    }

    if (stateflag == false) {
      message.append(" 操作状态不一致:[平台" + cashStream.getState() + "][钱多多" + ActState + "]");
    }

    if (!flag) {
      throw new Exception(message.toString());
    }

    return flag;
  }
  public static boolean checkFreezeResult(CashStream cashStream, String body) throws Exception {
    boolean flag = true;
    Gson gson = new Gson();
    List<Map<String, String>> res = (List<Map<String, String>>) gson.fromJson(body, List.class);

    if ((res == null || res.isEmpty()) && cashStream.getState() == cashStream.STATE_INIT) {
      return true;
    } else if ((res == null || res.isEmpty())
        && cashStream.getLenderAccountId() == null
        && cashStream.getBorrowerAccountId() != null) {
      return true;
    } else if (cashStream.getState() == cashStream.STATE_INIT) {
      List<CashStream> cash =
          cashStreamDao.findBySubmitAndActionAndState(
              cashStream.getSubmitId(), cashStream.getAction(), CashStream.STATE_SUCCESS);
      if (cash != null && !cash.isEmpty()) {
        return true;
      } else {
        Map<String, String> result = res.get(0);
        if ("支付超时".equals(cashStream.getDescription())) {
          return true;
        } else if ("0".equals(result.get("TransferState")) && "0".equals(result.get("ActState"))) {
          return true;
        } else {
          throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 平台未处理的现金流在第三方上有对应的记录!");
        }
      }
    } else if ((res == null || res.isEmpty())) {
      throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 投标冻结找不到第三方上对应的记录!");
    }

    String laccount = "";

    Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());

    if (lender != null) {
      laccount = lender.getThirdPartyAccount();
    } else {
      laccount =
          borrowerDao.findByAccountID(cashStream.getBorrowerAccountId()).getThirdPartyAccount();
    }

    Map<String, String> result = res.get(0);

    // 付款人乾多多标识
    String LoanOutMoneymoremore = result.get("LoanOutMoneymoremore");

    // 收款人乾多多标识
    String LoanInMoneymoremore = result.get("LoanInMoneymoremore");

    // 额度
    String Amount = result.get("Amount");
    // 乾多多流水号
    String LoanNo = result.get("LoanNo");

    // 转账类型
    String TransferAction = result.get("TransferAction");

    boolean accountflag = laccount.equals(LoanOutMoneymoremore);

    boolean loanflag =
        cashStream.getLoanNo() == null ? false : cashStream.getLoanNo().equals(LoanNo);

    // 投标
    boolean actionflag = lender == null ? TransferAction.equals("2") : TransferAction.equals("1");

    boolean totalflag =
        cashStream
                .getChiefamount()
                .add(cashStream.getInterest())
                .negate()
                .compareTo(new BigDecimal(Amount))
            == 0;

    flag = flag && loanflag && totalflag && accountflag && actionflag;

    StringBuilder message = new StringBuilder();

    message.append("现金流[ID:" + cashStream.getId() + "]: ");

    if (loanflag == false) {
      message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
    }

    if (totalflag == false) {
      message.append(
          " 金额不一致:[平台" + cashStream.getChiefamount().negate().toString() + "][钱多多" + Amount + "] ");
    }

    if (accountflag == false) {
      message.append(" 账户不一致:[平台:" + laccount + "][钱多多 :" + LoanOutMoneymoremore + "] ");
    }

    if (actionflag == false) {
      message.append(" 行为不一致:[平台 投标][钱多多 还款] ");
    }

    if (!flag) {
      throw new Exception(message.toString());
    }

    return flag;
  }
  private static boolean checkWithDrawResult(CashStream cashStream, String body) throws Exception {
    boolean flag = true;

    Gson gson = new Gson();
    List<Map<String, String>> res = (List<Map<String, String>>) gson.fromJson(body, List.class);

    if ((res == null || res.isEmpty()) && cashStream.getState() == cashStream.STATE_INIT) {
      return true;
    }

    String thirdPartyAccount = "";

    if (cashStream.getLenderAccountId() != null) {
      Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());
      if (lender != null) {
        thirdPartyAccount = lender.getThirdPartyAccount();
      }
    } else if (cashStream.getBorrowerAccountId() != null) {
      Borrower borrower = borrowerDao.findByAccountID(cashStream.getBorrowerAccountId());
      if (borrower != null) {
        thirdPartyAccount = borrower.getThirdPartyAccount();
      }
    }

    Map<String, String> result = res.get(0);
    // 额度
    String Amount = result.get("Amount");
    // 乾多多流水号
    String LoanNo = result.get("LoanNo");

    // 提现费用
    String FeeWithdraws = result.get("FeeWithdraws");

    // 提现状态
    String WithdrawsState = result.get("WithdrawsState");

    // 提现账号
    String WithdrawMoneymoremore = result.get("WithdrawMoneymoremore");

    boolean accountflag = thirdPartyAccount.equals(WithdrawMoneymoremore);

    boolean loanflag =
        cashStream.getLoanNo() == null
            ? (LoanNo == null ? true : false)
            : cashStream.getLoanNo().equals(LoanNo);
    boolean stateflag = false;
    if (WithdrawsState.equals("0") && cashStream.getState() == 2) {
      stateflag = true;
    } else if (WithdrawsState.equals("1") && cashStream.getState() == 2) {
      stateflag = true;
    } else if (WithdrawsState.equals("2") && cashStream.getState() == 8) {
      stateflag = true;
    }
    boolean totalflag = cashStream.getChiefamount().negate().compareTo(new BigDecimal(Amount)) == 0;
    boolean feeflag = cashStream.getFee().compareTo(new BigDecimal(FeeWithdraws)) == 0;

    flag = flag && loanflag && stateflag && totalflag && feeflag && accountflag;

    StringBuilder message = new StringBuilder();

    message.append("现金流[ID:" + cashStream.getId() + "]: ");
    if (loanflag == false) {
      message.append(" 乾多多流水号不一致:[平台" + cashStream.getLoanNo() + "][钱多多" + LoanNo + "] ");
    }
    if (stateflag == false) {
      message.append(" 操作状态不一致:[平台" + cashStream.getState() + "][钱多多" + WithdrawsState + "] ");
    }
    if (totalflag == false) {
      message.append(
          " 金额不一致:[平台" + cashStream.getChiefamount().negate().toString() + "][钱多多" + Amount + "] ");
    }
    if (feeflag == false) {
      message.append(
          " 手续费不一致:[平台" + cashStream.getFee().toString() + "][钱多多" + FeeWithdraws + "] ");
    }

    if (accountflag == false) {
      message.append(" 账户不一致:[平台" + thirdPartyAccount + "][钱多多" + WithdrawMoneymoremore + "] ");
    }

    if (!flag) {
      throw new Exception(message.toString());
    }

    return flag;
  }