Ejemplo n.º 1
0
  public static boolean checkPayBackResult(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())) {
      throw new Exception("现金流[ID:" + cashStream.getId() + "]有问题: 找不到第三方上对应的记录!");
    }

    String out = "";
    String in = "";

    Lender lender = lenderDao.findByAccountID(cashStream.getLenderAccountId());
    if (lender != null) {
      in = lender.getThirdPartyAccount();
    }
    Borrower borrower = borrowerDao.findByAccountID(cashStream.getBorrowerAccountId());
    if (borrower != null) {
      out = borrower.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;
  }
Ejemplo n.º 2
0
  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;
  }
Ejemplo n.º 3
0
  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;
  }