1
zj
2025-07-22 52df45c5210c72fd6f89939780041a4482e41618
src/main/java/com/nq/service/impl/UserServiceImpl.java
@@ -16,6 +16,7 @@
import com.nq.pojo.reponse.RUserAssets;
import com.nq.service.*;
import com.nq.utils.UserPointUtil;
import com.nq.utils.redis.RedisKeyUtil;
import com.nq.utils.timeutil.DateTimeUtil;
import com.nq.utils.PropertiesUtil;
import com.nq.utils.SymmetricCryptoUtil;
@@ -188,7 +189,6 @@
        user.setRegAddress(uadd);
        user.setIsLogin(Integer.valueOf(0));
        int insertCount = this.userMapper.insert(user);
        if (insertCount > 0) {
@@ -209,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);
        }
@@ -507,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();
@@ -522,9 +523,10 @@
            rUserAssets.setHandlingCharge(hMoney.toString());
            rUserAssets.setProfitAndLoss(profitAndLose.toString());
            rUserAssets.setIsZf(userAssets.getIsZf());
            rUserAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().toString());
            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){
@@ -550,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);
            }
@@ -565,16 +567,15 @@
            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);
            AllHProfitAndLose = AllHProfitAndLose.add(handlingChargeUSD);
            allFreeMoney = allFreeMoney.add(freezeMoneyUSD);
            allHMoney = allHMoney.add(handlingChargeUSD);
@@ -611,14 +612,13 @@
        userPositions = userPositionMapper.
                findMyPositionByCodeAndSpell(userId,
                        "","",
                        0, "IN");
                        0, "JP");
        List<UserPositionVO> userPositionVOS = Lists.newArrayList();
        if (userPositions.size() > 0) {
            for (UserPosition position : userPositions) {
                UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position, priceServices.getNowPrice(position.getStockCode()));
                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){
@@ -769,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);
@@ -827,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");
        }
@@ -853,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);