Exemplo n.º 1
0
  /**
   * 风险备用金订单。
   *
   * @return
   */
  @Transactional(rollbackFor = {Exception.class, RuntimeException.class})
  public AccountOrder creRiskFundFeesOrder(
      ClaimPayPlan claimPayPlan, Long payAccountSequence, Investment investment) {
    BigDecimal thirdPaymentIdBalance = BigDecimal.ZERO;
    // P2P平台管理费
    ThirdPaymentAccount thirdPaymentAccount =
        accountThirdRepository.findByAccountSequence(claimPayPlan.getPayAccountSequence());
    if (thirdPaymentAccount != null) {
      thirdPaymentIdBalance = thirdPaymentAccount.getThirdPaymentIdBalance();
    }
    // 风险备用金
    BigDecimal claimPayPlanRiskFee = claimPayPlan.getClaimPayPlanRiskFee();

    Long p2pGatherAccount = null;
    List<ThirdPaymentAccount> thirdPaymentAccountList =
        accountThirdRepository.findByThirdPaymentIdType(
            ThirdPaymentAccountTypeEnum.P2P_RISK_ACCOUNT.getCode());
    if (CollectionUtil.isEmpty(thirdPaymentAccountList)) {
      p2pGatherAccount = 0000L;
    } else {
      p2pGatherAccount = thirdPaymentAccountList.get(0).getAccountSequence();
    }

    // 新增订单
    AccountOrder accountOrder = new AccountOrder();
    accountOrder.setTradeDate(new Date());
    accountOrder.setOrderStatus(OrderStatusEnum.PAYING.getCode()); // 订单状态
    accountOrder.setTradeType(TradeTypeEnum.P2P_ACCOUNT_RISK_RESERVE_FUND.getCode()); // 交易类型
    accountOrder.setTradeAmount(claimPayPlanRiskFee);
    accountOrder.setCommodityTablePrimaryKeyValue(claimPayPlan.getClaimPayPlanSequence());
    accountOrder.setPayAccountSequence(payAccountSequence);
    accountOrder.setGatherAccountSequence(p2pGatherAccount);

    accountOrder.setTradeDescription(investment.getInvestmentName());
    accountOrder.setCashFlowId(P2pUtil.generate20Random(OrderIDRuleEnum.FEE));
    accountOrder.setPayerThirdPaymentIdBalance(thirdPaymentIdBalance);
    accountOrder.setGatherThirdPaymentIdBalance(BigDecimal.ZERO);
    accountOrder.setOrderEditDate(new Date());
    accountOrder.setRecordStatus(RecStatusEnum.UNTREATED.getCode());
    accountOrder = accountOrderRepository.save(accountOrder);
    // 生成用户订单状态历史
    AccountOrderHistory accountOrderHistory = new AccountOrderHistory();
    accountOrderHistory.setAccountOrderSequence(accountOrder.getAccountOrderSequence());
    accountOrderHistory.setOrderStatus(OrderStatusEnum.PAYING.getCode());
    accountOrderHistory.setOrderStatusChangeDate(new Date());
    accountOrderHistory = accountOrderHistoryRepository.save(accountOrderHistory);

    return accountOrder;
  }
Exemplo n.º 2
0
  /**
   * 平台管理费订单。
   *
   * @param claimPayPlan 债券还款计划
   * @param payAccountSequence 付款用户账号
   * @return {@link AccountOrder}
   */
  @Transactional(rollbackFor = {Exception.class, RuntimeException.class})
  public AccountOrder crePlatformManagementFeesOrder(
      ClaimPayPlan claimPayPlan,
      Long payAccountSequence,
      Long p2pPfAccount,
      Investment investment,
      BigDecimal pmFee) {
    BigDecimal thirdPaymentIdBalance = BigDecimal.ZERO;
    // P2P平台管理费
    ThirdPaymentAccount thirdPaymentAccount =
        accountThirdRepository.findByAccountSequence(claimPayPlan.getPayAccountSequence());
    if (thirdPaymentAccount != null) {
      thirdPaymentIdBalance = thirdPaymentAccount.getThirdPaymentIdBalance();
    }

    // 新增订单
    AccountOrder accountOrder = new AccountOrder();
    accountOrder.setTradeDate(new Date());
    accountOrder.setOrderStatus(OrderStatusEnum.PAYING.getCode()); // 订单状态
    accountOrder.setTradeType(TradeTypeEnum.P2P_ACCOUNT_SERVICE.getCode()); // 交易类型
    accountOrder.setTradeAmount(pmFee);
    accountOrder.setCommodityTablePrimaryKeyValue(claimPayPlan.getClaimPayPlanSequence());
    accountOrder.setPayAccountSequence(payAccountSequence);
    accountOrder.setGatherAccountSequence(p2pPfAccount);

    accountOrder.setTradeDescription(investment.getInvestmentName());
    accountOrder.setCashFlowId(P2pUtil.generate20Random(OrderIDRuleEnum.FEE));
    accountOrder.setPayerThirdPaymentIdBalance(thirdPaymentIdBalance);
    accountOrder.setGatherThirdPaymentIdBalance(BigDecimal.ZERO);
    accountOrder.setOrderEditDate(new Date());
    accountOrder.setRecordStatus(RecStatusEnum.UNTREATED.getCode());
    accountOrder = accountOrderRepository.save(accountOrder);
    // 生成用户订单状态历史
    AccountOrderHistory accountOrderHistory = new AccountOrderHistory();
    accountOrderHistory.setAccountOrderSequence(accountOrder.getAccountOrderSequence());
    accountOrderHistory.setOrderStatus(OrderStatusEnum.PAYING.getCode());
    accountOrderHistory.setOrderStatusChangeDate(new Date());
    accountOrderHistory = accountOrderHistoryRepository.save(accountOrderHistory);

    return accountOrder;
  }