1
dd
2026-02-10 88db0094dae7ed1b4be1ee11194b1aef6e5d69c9
src/main/java/com/nq/service/impl/UserPositionServiceImpl.java
@@ -306,9 +306,9 @@
                .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("平仓失败, 订单已平仓");
        }
@@ -327,16 +327,21 @@
        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("平仓成功!");
    }
@@ -360,9 +365,9 @@
                .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())) {
@@ -444,20 +449,20 @@
        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);
    }