Ejemplo n.º 1
0
  // 每一次批量提交的投标审核一定是针对同一个产品,因此不会出现一批投标购买针对不同产品的情况
  // 审核提交给第三方后,对第三方返回的执行结果参数的后续处理
  @Override
  public void buyAuditSuccessHandle(List<String> loanNos) throws Exception {
    if (loanNos == null || loanNos.isEmpty()) {
      throw new Exception("审核返回列表为空");
    }

    // 每一次批量提交的投标审核一定是针对同一个产品,因此取出第一条投标对应的产品,判断其状态,如果已经为还款中,则说明已经执行成功
    String eLoanNo = loanNos.get(0);
    List<CashStream> eCashStreams = cashStreamDao.findSuccessByActionAndLoanNo(-1, eLoanNo);
    CashStream eCashStream = eCashStreams.get(0);
    Submit eSubmit = submitDao.find(eCashStream.getSubmitId());
    Product product = productDao.find(eSubmit.getProductId());
    GovermentOrder order = orderDao.find(product.getGovermentorderId());

    Borrower borrower = borrowerDao.find(order.getBorrowerId());
    if (Product.STATE_REPAYING == product.getState()) {
      // 产品已经处于还款状态,说明针对本产品的购买审核已经执行完毕
      return;
    }

    for (String loanNo : loanNos) {
      List<CashStream> cashStreams = cashStreamDao.findSuccessByActionAndLoanNo(-1, loanNo);
      CashStream cashStream = cashStreams.get(0);

      if (cashStreams.size() == 2) {
        // 针对本个LoanNo,在平台上有两条执行成功的现金流与之对应,那肯定说明这次购买已经处理成功,一条冻结,一条转账
        continue; // 重复的命令
      }

      try {
        Integer cashStreamId = null;
        cashStreamId =
            accountService.pay(
                cashStream.getLenderAccountId(),
                borrower.getAccountId(),
                cashStream.getChiefamount().negate(),
                cashStream.getSubmitId(),
                "支付");
        cashStreamDao.updateLoanNo(cashStreamId, loanNo, null);
      } catch (IllegalConvertException e) {
        e.printStackTrace();
      }
    }

    // 校验 Product实际支付额=所有Lender的支付资金流之和
    CashStreamSum sum = cashStreamDao.sumProduct(product.getId(), CashStream.ACTION_PAY);
    if (sum.getChiefAmount().negate().compareTo(product.getRealAmount()) != 0)
      throw new CheckException("投标购买审核完成总金额与产品实际融资金额不符,查看是否有尚未审核完毕的投标");

    // 根据产品实际融资额度重新计算并更新还款计划
    innerPayBackService.refreshPayBack(product.getId(), true);

    // 状态转换为还款中,及一系列后续操作
    innerProductService.startRepaying(product.getId());
  }
Ejemplo n.º 2
0
  private void buyAuditReturnHandle(List<String> loanNos) throws Exception {
    if (loanNos == null || loanNos.isEmpty()) {
      throw new Exception("审核返回列表为空");
    }

    // 每一次批量提交的投标审核一定是针对同一个产品,因此取出第一条投标对应的产品,判断其状态,如果已经为还款中,则说明已经执行成功
    String eLoanNo = loanNos.get(0);
    List<CashStream> eCashStreams = cashStreamDao.findSuccessByActionAndLoanNo(-1, eLoanNo);
    CashStream eCashStream = eCashStreams.get(0);
    Submit eSubmit = submitDao.find(eCashStream.getSubmitId());
    Product product = productDao.find(eSubmit.getProductId());
    GovermentOrder order = orderDao.find(product.getGovermentorderId());

    if (Product.STATE_QUITFINANCING == product.getState()) {
      // 产品已经处于流标状态,说明针对本产品的购买审核已经执行完毕
      return;
    }

    for (String loanNo : loanNos) {
      List<CashStream> cashStreams = cashStreamDao.findSuccessByActionAndLoanNo(-1, loanNo);
      CashStream cashStream = cashStreams.get(0);

      if (cashStreams.size() == 2) {
        // 针对本个LoanNo,在平台上有两条执行成功的现金流与之对应,那肯定说明这次购买已经处理成功,一条冻结,一条流标解冻
        continue; // 重复的命令
      }

      try {
        Integer cashStreamId = null;
        cashStreamId =
            accountService.unfreezeLenderAccount(
                cashStream.getLenderAccountId(),
                cashStream.getChiefamount().negate(),
                cashStream.getSubmitId(),
                "流标");
        cashStreamDao.updateLoanNo(cashStreamId, loanNo, null);
      } catch (IllegalConvertException e) {
        e.printStackTrace();
      }
    }

    // 校验 Product实际流标解冻额=所有Lender的支付资金流之和
    CashStreamSum sum = cashStreamDao.sumProduct(product.getId(), CashStream.ACTION_UNFREEZE);
    if (sum.getChiefAmount().compareTo(product.getRealAmount()) != 0)
      throw new CheckException("流标解冻总金额与产品实际融资金额不符,查看是否有尚未审核完毕的投标");

    // 状态转换为流标,及一系列后续操作
    innerProductService.quitFinancing(product.getId());
  }