zyy
2025-08-08 340fe577cf354439af1b9429b7c2d37a2773ec23
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -177,20 +177,20 @@
                    return ServerResponse.createByErrorMsg("报价0,请稍后再试", request);
                }
                BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever));
                BigDecimal finalBuyAmt = buyAmt;
                //如果不是默认货币需要转换金额
                if (!stock.getStockType().equals(EStockType.getDefault().getCode())) {
                    buyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt);
                }
                //手续费
                BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt);
                BigDecimal needBuyAmt = buyAmt.add(orderFree);
                //资金校验
                if (!stock.getStockType().equals(EStockType.getDefault().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();
                if (profitTarget != null && profitTarget.compareTo(new BigDecimal("0")) > 0) {
                    userPosition.setProfitTargetPrice(profitTarget);
@@ -217,7 +217,7 @@
                }
                userPosition.setIsLock(Integer.valueOf(0));
                userPosition.setOrderLever(lever);
                userPosition.setOrderTotalPrice(finalBuyAmt);
                userPosition.setOrderTotalPrice(buyAmt);
                // 手续费
                userPosition.setOrderFee(orderFree);