| | |
| | | .eq(UserAssets::getUserId, userPosition.getUserId()) |
| | | .eq(UserAssets::getAccectType, "JP") |
| | | ); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | /*if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("用户待补资金未补齐,禁止平仓"); |
| | | } |
| | | }*/ |
| | | if (userPosition.getSellOrderId() != null) { |
| | | return ServerResponse.createByErrorMsg("平仓失败, 订单已平仓"); |
| | | } |
| | |
| | | BigDecimal sellOrderTotel = nowPrice.multiply(new BigDecimal(userPosition.getOrderNum())); |
| | | BigDecimal xsPrice = sellOrderTotel.multiply(siitteBuyFee); |
| | | userPositionMapper.updateById(userPosition); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, priceServices.getNowPrice(userPosition.getStockCode())); |
| | | /*userAssetsServices.availablebalanceChange(stock.getStockType(), userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", "");*/ |
| | | |
| | | //从保证金里计算盈亏 |
| | | BigDecimal returnAmt = userPosition.getOrderTotalPrice().add(profitVO.getAllProfitAndLose()); |
| | | |
| | | userAssetsServices.availablebalanceSell(stock.getStockType(), |
| | | userPosition.getUserId(), EUserAssets.CLOSE_POSITION_RETURN_SECURITY_DEPOSIT, |
| | | userPosition.getOrderTotalPrice(), "", ""); |
| | | returnAmt, userPosition.getOrderTotalPrice()); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userPosition.getUserId(), EUserAssets.HANDLING_CHARGE, |
| | | xsPrice, "", ""); |
| | | |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, priceServices.getNowPrice(userPosition.getStockCode())); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", ""); |
| | | return ServerResponse.createBySuccessMsg("平仓成功!"); |
| | | } |
| | | |
| | |
| | | .eq(UserAssets::getUserId, userPosition.getUserId()) |
| | | .eq(UserAssets::getAccectType, "JP") |
| | | ); |
| | | if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | /*if(userAssets.getAmountToBeCovered().compareTo(BigDecimal.ZERO) > 0){ |
| | | return ServerResponse.createByErrorMsg("请先缴清待补资金", request); |
| | | } |
| | | }*/ |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, userPosition.getStockCode())); |
| | | if (null != stockSubscribe && DateUtil.date().before(stockSubscribe.getListDate())) { |
| | |
| | | position.setId(null); |
| | | position.setPositionSn(KeyUtils.getUniqueKey()); |
| | | position.setOrderNum(number); |
| | | position.setOrderTotalPrice(position.getBuyOrderPrice().multiply(new BigDecimal(number))); |
| | | position.setOrderTotalPrice(position.getBuyOrderPrice().multiply(new BigDecimal(number)).divide(new BigDecimal(position.getOrderLever()), 5, RoundingMode.HALF_UP)); |
| | | position.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | //修改拆分订单手续费 |
| | | BigDecimal BuyFee = new BigDecimal(iStockConfigServices.queryByKey(EConfigKey.BUY_HANDLING_CHARGE.getCode()).getCValue()); |
| | | BigDecimal buyPrice = position.getBuyOrderPrice().multiply(new BigDecimal(position.getOrderNum())); |
| | | BigDecimal xsPrice = buyPrice.multiply(BuyFee); |
| | | BigDecimal xsPrice = position.getOrderTotalPrice().multiply(BuyFee); |
| | | position.setOrderFee(xsPrice); |
| | | |
| | | //修改原订单 |
| | | userPosition.setOrderNum(userPosition.getOrderNum()-number); |
| | | userPosition.setOrderTotalPrice(userPosition.getBuyOrderPrice().multiply(new BigDecimal(userPosition.getOrderNum()))); |
| | | userPosition.setOrderTotalPrice(userPosition.getBuyOrderPrice().multiply(new BigDecimal(userPosition.getOrderNum())).divide(new BigDecimal(position.getOrderLever()), 5, RoundingMode.HALF_UP)); |
| | | userPosition.setOrderFee(userPosition.getOrderFee().subtract(position.getOrderFee())); |
| | | userPositionMapper.insert(position); |
| | | userPositionMapper.updateById(userPosition); |
| | |
| | | BigDecimal xsPrice = sellOrderTotel.multiply(siitteBuyFee); |
| | | userPosition.setOrderFee(userPosition.getOrderFee().add(xsPrice)); |
| | | userPositionMapper.updateById(userPosition); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, priceServices.getNowPrice(userPosition.getStockCode())); |
| | | /*userAssetsServices.availablebalanceChange(stock.getStockType(), userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", "");*/ |
| | | |
| | | //从保证金里计算盈亏 |
| | | BigDecimal returnAmt = userPosition.getOrderTotalPrice().add(profitVO.getAllProfitAndLose()); |
| | | |
| | | userAssetsServices.availablebalanceSell(stock.getStockType(), |
| | | userPosition.getUserId(), |
| | | EUserAssets.CLOSE_POSITION_RETURN_SECURITY_DEPOSIT, |
| | | userPosition.getOrderTotalPrice(), "", ""); |
| | | returnAmt, userPosition.getOrderTotalPrice()); |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userPosition.getUserId(), EUserAssets.HANDLING_CHARGE, |
| | | xsPrice, "", ""); |
| | | |
| | | PositionProfitVO profitVO = UserPointUtil.getPositionProfitVO(userPosition, |
| | | priceServices.getNowPrice(userPosition.getStockCode())); |
| | | |
| | | userAssetsServices.availablebalanceChange(stock.getStockType(), |
| | | userPosition.getUserId(), EUserAssets.CLOSE_POSITION, |
| | | profitVO.getAllProfitAndLose(), "", ""); |
| | | return ServerResponse.createBySuccessMsg("平仓成功!", request); |
| | | } |
| | | |