| | |
| | | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.sql.Timestamp; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | |
| | | return ServerResponse.createByErrorMsg("报价0,请稍后再试", request); |
| | | } |
| | | |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever), 5, RoundingMode.HALF_UP); |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | |
| | | BigDecimal fundratio = new BigDecimal(String.valueOf(user.getFundRatio().isEmpty() ? 100 : user.getFundRatio())).divide(new BigDecimal(100)); |
| | |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("平仓失败,用户不存在"); |
| | | } |
| | | UserAssets userAssets = userAssetsMapper.selectOne(new LambdaQueryWrapper<UserAssets>() |
| | | .eq(UserAssets::getUserId, userPosition.getUserId()) |
| | | .eq(UserAssets::getAccectType, "JP") |
| | | ); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("用户待补资金未补齐,禁止平仓"); |
| | | } |
| | | if (userPosition.getSellOrderId() != null) { |
| | | return ServerResponse.createByErrorMsg("平仓失败, 订单已平仓"); |
| | | } |