| | |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | 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.redis.*; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.SymmetricCryptoUtil; |
| | | import com.nq.utils.ip.IpUtils; |
| | | import com.nq.utils.ip.JuheIpApi; |
| | | import com.nq.utils.redis.CookieUtils; |
| | | import com.nq.utils.redis.JsonUtil; |
| | | import com.nq.utils.redis.RedisShardedPoolUtils; |
| | | import com.nq.utils.stock.sina.StockApi; |
| | | import com.nq.vo.agent.AgentUserListVO; |
| | | import com.nq.vo.futuresposition.FuturesPositionVO; |
| | |
| | | IUserService iUserService; |
| | | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd,HttpServletRequest request) { |
| | | public ServerResponse reg( String agentCode, String phone, String userPwd,HttpServletRequest request) { |
| | | if (StringUtils.isBlank(agentCode) || StringUtils.isBlank(phone) || |
| | | StringUtils.isBlank(userPwd) || StringUtils.isBlank(yzmCode)) { |
| | | StringUtils.isBlank(userPwd)) { |
| | | return ServerResponse.createByErrorMsg("注册失败。该参数不能为空",request); |
| | | } |
| | | |
| | | |
| | | String redis_yzm = RedisShardedPoolUtils.get(phone); |
| | | |
| | | log.info("redis_yzm = {},yzmCode = {}", redis_yzm, yzmCode); |
| | | if (!yzmCode.equals(redis_yzm)) { |
| | | return ServerResponse.createByErrorMsg("由于验证码不正确,注册失败。", request); |
| | | } |
| | | |
| | | AgentUser agentUser = this.iAgentUserService.findByCode(agentCode); |
| | | if (agentUser == null) { |
| | | return ServerResponse.createByErrorMsg("由于代理不存在,注册失败",request); |
| | |
| | | return ServerResponse.createByErrorMsg("登录失败。账户锁定",request); |
| | | } |
| | | userAssetsServices.assetsByTypeAndUserId(EStockType.ST.getCode(),user.getId()); |
| | | QueryWrapper<UserAssets> usdtQueryWrapper = new QueryWrapper<>(); |
| | | usdtQueryWrapper.eq("accect_type","USD"); |
| | | usdtQueryWrapper.eq("user_id",user.getId()); |
| | | UserAssets usdtUserAssets = userAssetsServices.getOne(usdtQueryWrapper); |
| | | System.out.println("=========usdtUserAssets======"+JSON.toJSONString(usdtUserAssets)); |
| | | if(usdtUserAssets == null){ |
| | | usdtUserAssets = new UserAssets(); |
| | | usdtUserAssets.setAccectType("USD"); |
| | | usdtUserAssets.setUserId(user.getId()); |
| | | userAssetsServices.save(usdtUserAssets); |
| | | } |
| | | this.iSiteLoginLogService.saveLog(user, request); |
| | | return ServerResponse.createBySuccess(user); |
| | | } |
| | |
| | | public ServerResponse getMoney(Integer userId) { |
| | | List<UserAssets> userAssetsList = userAssetsServices.assetsByUserId(userId); |
| | | List<RUserAssets> rUserAssetsList = new ArrayList<>(); |
| | | int s= 4; |
| | | int s= 2; |
| | | /** |
| | | * 浮动盈亏 |
| | | * */ |
| | |
| | | BigDecimal hMoney = userAssets.getHandlingCharge(); |
| | | BigDecimal hProfitAndLose = userAssets.getCumulativeProfitAndLoss(); |
| | | rUserAssets.setId(userAssets.getId()); |
| | | rUserAssets.setTotalMoney((totalAssets.toString())); |
| | | rUserAssets.setTotalMoney((totalAssets.setScale(s,BigDecimal.ROUND_DOWN).toString())); |
| | | rUserAssets.setAccectType(userAssets.getAccectType()); |
| | | rUserAssets.setAvailableBalance(amt.toString()); |
| | | rUserAssets.setFreezeMoney(freeMoney.toString()); |
| | | rUserAssets.setCumulativeProfitAndLoss(hProfitAndLose.toString()); |
| | | rUserAssets.setHandlingCharge(hMoney.toString()); |
| | | rUserAssets.setProfitAndLoss(profitAndLose.toString()); |
| | | rUserAssets.setAvailableBalance(amt.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setFreezeMoney(freeMoney.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setCumulativeProfitAndLoss(hProfitAndLose.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setHandlingCharge(hMoney.setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setProfitAndLoss(new BigDecimal(profitAndLose.toString()).setScale(s,BigDecimal.ROUND_DOWN).toString()); |
| | | rUserAssets.setIsZf(userAssets.getIsZf()); |
| | | rUserAssets.setAmountToBeCovered((userAssets.getAmountToBeCovered().add(userAssets.getHandlingChargeWritten()).toString())); |
| | | rUserAssets.setHandlingChargeWritten(userAssets.getHandlingChargeWritten()); |
| | | rUserAssets.setAmountToBeCovered((userAssets.getAmountToBeCovered().add(userAssets.getHandlingChargeWritten()).setScale(s,BigDecimal.ROUND_DOWN).toString())); |
| | | rUserAssets.setHandlingChargeWritten(userAssets.getHandlingChargeWritten().setScale(s,BigDecimal.ROUND_DOWN)); |
| | | BigDecimal rate = rateServices.currencyRate( |
| | | EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US); |
| | | |
| | |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | | if (userPositions.size() > 0) { |
| | | for (UserPosition position : userPositions) { |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,priceServices.getNowPrice(position.getStockCode())); |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | if(position.getStockGid().equals("ST")){ |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | }else{ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(RedisKeyConstant.getRedisKey(position.getStockName()))); |
| | | } |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,nowPrice); |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, userPositionVO.getStockCode())); |
| | | if(position.getSellOrderId() == null){ |