@Override
 @Transactional(propagation = Propagation.REQUIRED, rollbackFor = java.lang.RuntimeException.class)
 public void autoApply(BizOrderExitApply waitApply) {
   Assert.notNull(waitApply, "waitApply must not null.");
   BusFinancePlanOrder order = busFinancePlanOrderService.getById(waitApply.getXsOrderId());
   Assert.notNull(order, "order must not null.");
   BusFinancePlan plan = busFinancePlanService.getById(waitApply.getFinanceplanId());
   Assert.notNull(plan, "plan must not null.");
   BusUser user = busUserService.queryUser(waitApply.getUserId());
   Assert.notNull(user, "user must not null.");
   // 订单状态必须是“TRANSFERING”
   Assert.isTrue(
       BusOrderStatus.TRANSFERING.equals(order.getOrderStatus()),
       "order must is [TRANSFERING] status");
   // 理财计划配置必须是“NONFIXED_FINANCEPLAN” or “MOBILE_FINANCEPLAN” or
   // “XS_FINANCEPLAN” or “PROFITS_ADVANCE_FINANCEPLAN”
   Assert.isTrue(
       BusFinancePlanConfigType.ORDER_EXIT_NEED_APPLY_FINANCEPLANS.contains(
           plan.getFinancePlanConfigType()),
       "finance plan config type check error.");
   bizOrderExitApplyService.updateOrderExitApply(
       waitApply.getId(),
       waitApply.getVersion(),
       "system",
       new Date(),
       "system task auto apply",
       OrderExitApplyStatus.APPLY_SUCCESS);
 }
 @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);
 }