| | |
| | | stock.setStockName(stockFutures.getFuturesName()); |
| | | stock.setIsLock(0); |
| | | } |
| | | } else if(code.contains("sh") || code.contains("sz")){ |
| | | return ServerResponse.createByErrorMsg("添加失败,指数不支持自选"); |
| | | // StockIndex stockIndex = this.stockIndexMapper.selectIndexByCode(stockcode); |
| | | // if(stockIndex != null){ |
| | | // stock.setId(stockIndex.getId()); |
| | | // stock.setStockCode(stockIndex.getIndexCode()); |
| | | // stock.setStockGid(stockIndex.getIndexGid()+"zs"); |
| | | // stock.setStockName(stockIndex.getIndexName()); |
| | | // stock.setIsLock(0); |
| | | // } |
| | | } else { |
| | | stock = this.stockMapper.findStockByCode(code); |
| | | stock = this.stockMapper.findStockByCode(stockcode); |
| | | if (stock == null && !code.equals(stockcode)) { |
| | | stock = this.stockMapper.findStockByCode(code); |
| | | } |
| | | } |
| | | if (stock == null) { |
| | | return ServerResponse.createByErrorMsg("添加失败,股票不存在"); |
| | |
| | | return ServerResponse.createBySuccess(userInfoVO); |
| | | } |
| | | |
| | | @Override |
| | | public void syncUserCache(HttpServletRequest request) { |
| | | if (request == null) { |
| | | return; |
| | | } |
| | | String cookieName = PropertiesUtil.getProperty("user.cookie.name"); |
| | | String loginToken = request.getHeader(cookieName); |
| | | if (StringUtils.isBlank(loginToken)) { |
| | | return; |
| | | } |
| | | String userJson = RedisShardedPoolUtils.get(loginToken); |
| | | User cached = (User) JsonUtil.string2Obj(userJson, User.class); |
| | | if (cached == null || cached.getId() == null) { |
| | | return; |
| | | } |
| | | User dbUser = this.userMapper.selectByPrimaryKey(cached.getId()); |
| | | if (dbUser != null) { |
| | | RedisShardedPoolUtils.setEx(loginToken, JsonUtil.obj2String(dbUser), 9999); |
| | | } |
| | | } |
| | | |
| | | public ServerResponse updatePwd(String oldPwd, String newPwd, HttpServletRequest request) { |
| | | if (StringUtils.isBlank(oldPwd) || StringUtils.isBlank(newPwd)) { |
| | |
| | | BigDecimal allProfitAndLose = positionVO.getAllProfitAndLose(); |
| | | userInfoVO.setAllProfitAndLose(allProfitAndLose); |
| | | |
| | | // BigDecimal userAllAmt = user.getUserAmt(); |
| | | BigDecimal userAllAmt = user.getEnableAmt(); |
| | | userAllAmt = userAllAmt.add(allProfitAndLose); |
| | | |
| | | // 账户总资产 = 两融可用 + 冻结保证金 + 浮动盈亏 |
| | | // 浮动盈亏里已扣过买入手续费,而买入手续费下单时已从 enableAmt 扣除,此处加回 openBuyFees 避免总资产「少扣手续费」 |
| | | BigDecimal allFreezAmt = positionVO.getAllFreezAmt() == null ? BigDecimal.ZERO : positionVO.getAllFreezAmt(); |
| | | BigDecimal enableAmt = user.getEnableAmt() == null ? BigDecimal.ZERO : user.getEnableAmt(); |
| | | BigDecimal openBuyFees = BigDecimal.ZERO; |
| | | List<UserPosition> openPositions = this.iUserPositionService.findPositionByUserIdAndSellIdIsNull(user.getId()); |
| | | if (openPositions != null) { |
| | | for (UserPosition position : openPositions) { |
| | | if (position.getOrderFee() != null) { |
| | | openBuyFees = openBuyFees.add(position.getOrderFee()); |
| | | } |
| | | } |
| | | } |
| | | BigDecimal userAllAmt = enableAmt.add(allFreezAmt).add(allProfitAndLose).add(openBuyFees); |
| | | |
| | | userInfoVO.setEnableIndexAmt(user.getEnableIndexAmt()); |
| | | userInfoVO.setEnaleWithdrawAmt(user.getEnaleWithdrawAmt()); |
| | |
| | | } |
| | | } |
| | | userInfoVO.setBuyAmtAutual(buyAmtAutual); |
| | | userAllAmt = userAllAmt.add(buyAmtAutual); |
| | | userInfoVO.setUserAmt(userAllAmt); |
| | | userInfoVO.setUserAmt(userAllAmt.setScale(2, RoundingMode.HALF_UP)); |
| | | |
| | | List<UserPosition> userPositions = this.userPositionMapper.findMyPositionByCodeAndSpell(user.getId(), "", "", 2); |
| | | |