| | |
| | | |
| | | |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | BigDecimal finalBuyAmt = buyAmt; |
| | | //如果不是墨西哥币需要转换金额 |
| | | if (!stock.getStockType().equals(EStockType.MX.getCode())) { |
| | | buyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt); |
| | | } |
| | | //手续费 |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | |
| | | BigDecimal needBuyAmt = buyAmt.add(orderFree); |
| | | //资金校验 |
| | | if (!stock.getStockType().equals(EStockType.MX.getCode())) { |
| | | needBuyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt); |
| | | } |
| | | BigDecimal fundratio = new BigDecimal(user.getFundRatio()).divide(new BigDecimal(100)); |
| | | BigDecimal availableBalance = fundratio.multiply(userAssets.getAvailableBalance()); |
| | | if (availableBalance.compareTo(buyAmt.add(orderFree)) < 0) { |
| | | if (availableBalance.compareTo(needBuyAmt) < 0) { |
| | | return ServerResponse.createByErrorMsg("订单失败,配资不足", request); |
| | | } |
| | | UserPosition userPosition = new UserPosition(); |
| | |
| | | } |
| | | userPosition.setIsLock(Integer.valueOf(0)); |
| | | userPosition.setOrderLever(lever); |
| | | userPosition.setOrderTotalPrice(finalBuyAmt); |
| | | userPosition.setOrderTotalPrice(buyAmt); |
| | | // 手续费 |
| | | |
| | | userPosition.setOrderFee(orderFree); |