@Transactional(propagation = Propagation.REQUIRED, rollbackFor = java.lang.RuntimeException.class)
 public void middleManBidLoan(int middleManId, BizLoanTransferApply apply) {
   // 给理财人转钱
   CheckUtil.checkRateThrowException(apply.getInitTransferLoanRate());
   BigDecimal transferAmount =
       bizOriginalLoanService.calculateLoanAmount(
           apply.getOriginalLoanId(), apply.getInitTransferLoanRate());
   BizLenderHoldLoan lenderHoldLoan = bizLenderHoldLoanService.getById(apply.getLenderHoldId());
   LOG.info(
       "Middle man bin apply applyId:["
           + apply.getId()
           + "],orginalLoanId:["
           + apply.getOriginalLoanId()
           + "],transferRate:["
           + apply.getInitTransferLoanRate()
           + "],xsOrderId:["
           + lenderHoldLoan.getXsOrderId()
           + "],transferAmount:["
           + CalculateUtil.setScaleForBizAmount(transferAmount)
           + "]");
   String notes =
       "债权转让:金额["
           + CalculateUtil.setScaleForBizAmount(transferAmount)
           + "],原始债权ID:["
           + apply.getOriginalLoanId()
           + "]";
   busFinancePlanOrderService.backTransferLoanAmount(
       lenderHoldLoan.getXsOrderId(),
       transferAmount,
       middleManId,
       apply.getLenderUserId(),
       "ASSIGNMENT_TRANSFER",
       notes,
       apply.getOriginalLoanId());
   // 更新理财人持有记录
   bizLenderHoldLoanService.updateLoanFullTransferOut(
       apply.getLenderHoldId(),
       lenderHoldLoan.getVersion(),
       BigDecimal.ZERO,
       LenderHoldLoanStatus.TRANSFERED);
   // 添加居间人持有记录
   bizMiddleManHoldLoanService.createMiddleManHoldLoan(apply);
   BusFinancePlanOrder order = busFinancePlanOrderService.getById(lenderHoldLoan.getXsOrderId());
   BizOriginalLoan origLoan = bizOriginalLoanService.getById(apply.getOriginalLoanId());
   // 更新理财人发起的转让申请状态到“成功”
   bizLoanTransferApplyService.updateTransferApplySurplus(
       apply.getId(),
       BigDecimal.ZERO,
       BigDecimal.ZERO,
       TransferApplyStatus.SUCCESS,
       apply.getVersion());
   // 添加转让申请日志(new)
   BizLoanTransferLog transferLog = new BizLoanTransferLog();
   transferLog.setTransferApplyId(apply.getId());
   transferLog.setCreateDatetime(new Date());
   transferLog.setFinanceplanId(order.getFinancePlanId());
   transferLog.setLenderUserId(order.getUserId());
   transferLog.setMiddleManId(apply.getMiddleManId());
   transferLog.setOriginalLoanId(apply.getOriginalLoanId());
   transferLog.setProductId(origLoan.getProductId());
   transferLog.setTotalHoldLoanRate(origLoan.getTotalHoldLoanRate());
   transferLog.setTransferApplyDatetime(apply.getCreateDatetime());
   transferLog.setTransferCurrentAmount(transferAmount);
   transferLog.setTransferDirection(apply.getTransferDirection());
   transferLog.setTransferLoanRate(apply.getTransferLoanRate());
   transferLog.setTransferSuccessAmount(transferAmount);
   transferLog.setTransferSuccessRate(apply.getInitTransferLoanRate());
   transferLog.setXsOrderId(order.getOrderId());
   bizLoanTransferLogService.add(transferLog);
 }
 @Override
 public BizLoanTransferApply mapRow(ResultSet rs, int index) throws SQLException {
   BizLoanTransferApply apply = new BizLoanTransferApply();
   apply.setId(rs.getInt("id"));
   apply.setOriginalLoanId(rs.getInt("original_loan_id"));
   apply.setInitTransferLoanRate(rs.getBigDecimal("init_transfer_loan_rate"));
   apply.setTransferLoanRate(rs.getBigDecimal("transfer_loan_rate"));
   apply.setTransferDirection(TransferDirection.valueOf(rs.getString("transfer_direction")));
   if (StringUtils.isNotBlank(rs.getString("lender_user_id"))) {
     apply.setLenderUserId(rs.getInt("lender_user_id"));
   }
   if (StringUtils.isNotBlank(rs.getString("lender_hold_id"))) {
     apply.setLenderHoldId(rs.getInt("lender_hold_id"));
   }
   if (StringUtils.isNotBlank(rs.getString("middle_man_id"))) {
     apply.setMiddleManId(rs.getInt("middle_man_id"));
   }
   if (StringUtils.isNotBlank(rs.getString("middle_hold_id"))) {
     apply.setMiddleHoldId(rs.getInt("middle_hold_id"));
   }
   apply.setTransferCurrentAmount(rs.getBigDecimal("transfer_current_amount"));
   apply.setCreateDatetime(rs.getTimestamp("create_datetime"));
   apply.setLastUpdateDatetime(rs.getTimestamp("last_update_datetime"));
   apply.setTransferStatus(TransferApplyStatus.valueOf(rs.getString("transfer_status")));
   apply.setVersion(rs.getInt("version"));
   return apply;
 }