zyy
2026-01-12 d243ceca02063628d03c3c637693a704e728ceff
src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -189,7 +189,6 @@
        user.setRegAddress(uadd);
        user.setIsLogin(Integer.valueOf(0));
        int insertCount = this.userMapper.insert(user);
        if (insertCount > 0) {
@@ -210,7 +209,7 @@
            if (user.getIsLogin().intValue() == 1) {
                return ServerResponse.createByErrorMsg("登录失败。账户锁定",request);
            }
            userAssetsServices.assetsByTypeAndUserId(EStockType.IN.getCode(),user.getId());
            userAssetsServices.assetsByTypeAndUserId(EStockType.JP.getCode(),user.getId());
            this.iSiteLoginLogService.saveLog(user, request);
            return ServerResponse.createBySuccess(user);
        }
@@ -320,7 +319,7 @@
    }
    public String leverSplit(String lever){
        String levers = "1/2/5/10";
        String levers = "1/2/4/6";
        String[] parts = levers.split("/");
        int index = Arrays.asList(parts).indexOf(lever);
        if (index != -1) {
@@ -508,9 +507,10 @@
            RUserAssets rUserAssets  = new RUserAssets();
            UserAssets userAssets = userAssetsList.get(i);
            // 浮动盈亏
            BigDecimal profitAndLose = userAssets.getProfitAndLoss();
            String profitAndLose = getProfitAndLose(userId).toString();
            BigDecimal amt = userAssets.getAvailableBalance();
            BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney());
            BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney()).add(new BigDecimal(profitAndLose)).subtract(userAssets.getHandlingChargeWritten());
//            BigDecimal totalAssets = userAssets.getAvailableBalance().add(userAssets.getFreezeMoney()).subtract(userAssets.getCumulativeProfitAndLoss()).add(profitAndLose);
            BigDecimal freeMoney = userAssets.getFreezeMoney();
            BigDecimal hMoney = userAssets.getHandlingCharge();
            BigDecimal hProfitAndLose = userAssets.getCumulativeProfitAndLoss();
@@ -524,8 +524,9 @@
            rUserAssets.setProfitAndLoss(profitAndLose.toString());
            rUserAssets.setIsZf(userAssets.getIsZf());
            rUserAssets.setAmountToBeCovered((userAssets.getAmountToBeCovered().add(userAssets.getHandlingChargeWritten()).toString()));
            rUserAssets.setHandlingChargeWritten(userAssets.getHandlingChargeWritten());
            BigDecimal rate = rateServices.currencyRate(
                    EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US);
                    EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.JP);
           BigDecimal  availableBalanceUSD = amt;
           if(amt.compareTo(BigDecimal.ZERO)>0){
@@ -539,7 +540,7 @@
            BigDecimal  totleMoneyUSD = totalAssets;
            if(totalAssets.compareTo(BigDecimal.ZERO)>0){
                totleMoneyUSD  = totleMoneyUSD.multiply(rate).subtract(new BigDecimal(rUserAssets.getHandlingCharge()));
                totleMoneyUSD  = totleMoneyUSD.multiply(rate);
            }
            BigDecimal  cumulativeProfitAndLossUSD = hProfitAndLose;
@@ -551,9 +552,9 @@
            if(hMoney.compareTo(BigDecimal.ZERO)>0){
                handlingChargeUSD  =hMoney.multiply(rate);
            }
            BigDecimal  profitAndLossUSD = profitAndLose;
            if(profitAndLose.compareTo(BigDecimal.ZERO)>0){
                profitAndLossUSD  =profitAndLose.multiply(rate);
            BigDecimal  profitAndLossUSD = new BigDecimal(profitAndLose);
            if(new BigDecimal(profitAndLose).compareTo(BigDecimal.ZERO)>0){
                profitAndLossUSD  =new BigDecimal(profitAndLose).multiply(rate);
            }
@@ -566,9 +567,9 @@
            rUserAssets.setCumulativeProfitAndLossUSD(cumulativeProfitAndLossUSD.setScale(s,BigDecimal.ROUND_UP).toString());
            rUserAssets.setHandlingChargeUSD(handlingChargeUSD.setScale(s,BigDecimal.ROUND_UP).toString());
            rUserAssets.setProfitAndLossUSD(profitAndLossUSD.setScale(s,BigDecimal.ROUND_UP).toString());
            rUserAssets.setProfitAndLoss(getProfitAndLose(userId).toString());
            BigDecimal decimal = new BigDecimal(rUserAssets.getTotalMoney()).add(new BigDecimal(rUserAssets.getProfitAndLoss()));
            rUserAssets.setTotalMoney(decimal.toString());
            rUserAssets.setProfitAndLoss(profitAndLose);
//            BigDecimal decimal = new BigDecimal(rUserAssets.getTotalMoney()).add(new BigDecimal(rUserAssets.getProfitAndLoss()));
//            rUserAssets.setTotalMoney(decimal.toString());
            AllProfitAndLose = AllProfitAndLose.add(profitAndLossUSD);
            allTotalAssets = allTotalAssets.add(totleMoneyUSD);
            allAmt = allAmt.add(availableBalanceUSD);
@@ -611,20 +612,13 @@
        userPositions = userPositionMapper.
                findMyPositionByCodeAndSpell(userId,
                        "","",
                        0, "IN");
                        0, "JP");
        List<UserPositionVO> userPositionVOS = Lists.newArrayList();
        if (userPositions.size() > 0) {
            for (UserPosition position : userPositions) {
                Stock stock = stockMapper.selectOne(new QueryWrapper<Stock>().eq("stock_code",position.getStockCode()));
                BigDecimal nowPrice = BigDecimal.ZERO;
                if(null != stock){
                    StockRealTimeBean stockRealTimeBean =  RedisKeyUtil.getCacheRealTimeStock(stock);
                    nowPrice = new BigDecimal(stockRealTimeBean.getLast());
                }
                UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,nowPrice);
                UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,priceServices.getNowPrice(position.getStockCode()));
                StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>()
                        .eq(StockSubscribe::getCode, userPositionVO.getStockCode()));
                if(position.getSellOrderId() == null){
@@ -775,7 +769,7 @@
            ServerResponse money = iUserService.getMoney(user.getId());
            List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData();
            RUserAssets rUserAssets = rUserAssetsList.stream()
                    .filter(stock -> "IN".equals(stock.getAccectType()))
                    .filter(stock -> "JP".equals(stock.getAccectType()))
                    .findFirst()
                    .orElse(null);
@@ -833,8 +827,8 @@
        int insertCount = this.userMapper.insert(user);
         dbUser = userMapper.selectOne(queryWrapper);
        userAssetsServices.getAvailableBalance(EStockType.IN.getCode(),dbUser.getId() );
        userAssetsServices.availablebalanceChange(EStockType.IN.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"","");
        userAssetsServices.getAvailableBalance(EStockType.JP.getCode(),dbUser.getId() );
        userAssetsServices.availablebalanceChange(EStockType.JP.getCode(),dbUser.getId(),EUserAssets.TOP_UP,new BigDecimal(amt),"","");
        if (insertCount > 0) {
            return ServerResponse.createBySuccessMsg("Success");
        }
@@ -859,7 +853,7 @@
            ServerResponse money = iUserService.getMoney(user.getId());
            List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData();
            RUserAssets rUserAssets = rUserAssetsList.stream()
                    .filter(stock -> "IN".equals(stock.getAccectType()))
                    .filter(stock -> "JP".equals(stock.getAccectType()))
                    .findFirst()
                    .orElse(null);