/** * 利息和罚息误差记录。 * * @param claimPayPlan 债券还款计划 * @return null */ @Transactional(rollbackFor = {Exception.class, RuntimeException.class}) public void creBalanceOrder( ClaimPayPlan claimPayPlan, Investment investment, BigDecimal pmFee, Long payAccountSequence, Long gatherAccountSequence) { // 新增订单 AccountOrder balanceOrder = new AccountOrder(); balanceOrder.setTradeDate(new Date()); balanceOrder.setOrderStatus(OrderStatusEnum.PAYMENT_SUCCESS.getCode()); // 订单状态 balanceOrder.setTradeType(TradeTypeEnum.DEFAULT_INTEREST_BALANCE.getCode()); // 交易类型 balanceOrder.setTradeAmount(pmFee); balanceOrder.setCommodityTablePrimaryKeyValue(claimPayPlan.getClaimPayPlanSequence()); balanceOrder.setPayAccountSequence(payAccountSequence); balanceOrder.setGatherAccountSequence(gatherAccountSequence); balanceOrder.setTradeDescription(investment.getInvestmentName()); balanceOrder.setCashFlowId(P2pUtil.generate20Random(OrderIDRuleEnum.FEE)); balanceOrder.setPayerThirdPaymentIdBalance(BigDecimal.ZERO); balanceOrder.setGatherThirdPaymentIdBalance(BigDecimal.ZERO); balanceOrder.setOrderEditDate(new Date()); balanceOrder.setRecordStatus(RecStatusEnum.UNTREATED.getCode()); accountOrderRepository.save(balanceOrder); }
/** * 风险备用金订单。 * * @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; }
/** * 平台管理费订单。 * * @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; }