| | |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | BigDecimal needBuyAmt = buyAmt.add(orderFree); |
| | | //资金校验 |
| | | if (!stock.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | /*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(needBuyAmt) < 0) { |
| | |
| | | |
| | | BigDecimal newBuyAmt = buyAmt; |
| | | //如果不是默认货币需要转换金额 |
| | | if (!stock.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | /*if (!stock.getStockType().equals(EStockType.getDefault().getCode())) { |
| | | newBuyAmt = userAssetsServices.exchangeAmountByRate(stock.getStockType(), buyAmt); |
| | | } |
| | | }*/ |
| | | if(newBuyAmt.compareTo(userAssets.getAvailableBalance()) > 0){ |
| | | return ServerResponse.createByErrorMsg("可用余额不足" + userAssets.getAvailableBalance(), request); |
| | | } |
| | |
| | | UserPosition userPosition = getUserPosition(dzId,num, user, stockDz, nowPrice, stock, buyAmt); |
| | | userPositionMapper.insert(userPosition); |
| | | BigDecimal buy_fee_amt = siteSettingBuyFee.multiply(newBuyAmt); |
| | | //已经转化 直接传默认类型 |
| | | userAssetsServices.availablebalanceChange(EStockType.getDefault().getCode(), user.getId(), EUserAssets.BUY, newBuyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(EStockType.getDefault().getCode(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), user.getId(), EUserAssets.BUY, newBuyAmt.negate(),"",""); |
| | | iUserAssetsServices.availablebalanceChange(stock.getStockType(), userAssets.getUserId(), EUserAssets.HANDLING_CHARGE, buy_fee_amt, "", ""); |
| | | return ServerResponse.createBySuccess("购买成功", request); |
| | | } catch (Exception e) { |
| | | log.error("大宗下单异常{}", e.getMessage()); |