| | |
| | | import com.nq.pojo.*; |
| | | import com.nq.pojo.reponse.RUserAssets; |
| | | import com.nq.service.*; |
| | | import com.nq.utils.UserPointUtil; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.SymmetricCryptoUtil; |
| | |
| | | import com.nq.vo.indexposition.IndexPositionVO; |
| | | import com.nq.vo.position.PositionProfitVO; |
| | | import com.nq.vo.position.PositionVO; |
| | | import com.nq.vo.position.UserPositionVO; |
| | | import com.nq.vo.stock.StockListVO; |
| | | import com.nq.vo.user.UserInfoVO; |
| | | |
| | |
| | | @Autowired |
| | | ISiteMessageService iSiteMessageService; |
| | | |
| | | @Autowired |
| | | private ApplyLeverMapper applyLeverMapper; |
| | | |
| | | @Autowired |
| | | private UserPositionMapper userPositionMapper; |
| | | |
| | | @Autowired |
| | | IPriceServices priceServices; |
| | | |
| | | |
| | | public ServerResponse reg(String yzmCode, String agentCode, String phone, String userPwd, HttpServletRequest request) { |
| | |
| | | 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); |
| | | } |
| | |
| | | String userJson = RedisShardedPoolUtils.get(loginToken); |
| | | User user = (User) JsonUtil.string2Obj(userJson, User.class); |
| | | User dbuser = this.userMapper.selectById(user.getId()); |
| | | |
| | | SiteSetting siteSetting = iSiteSettingService.getSiteSetting(); |
| | | UserInfoVO userInfoVO = assembleUserInfoVO(dbuser, siteSetting); |
| | | ApplyLever applyLever = applyLeverMapper.selectOne(new LambdaQueryWrapper<ApplyLever>() |
| | | .eq(ApplyLever::getUserId, user.getId()) |
| | | .eq(ApplyLever::getState, 1) |
| | | .orderByDesc(ApplyLever::getCreateTime) |
| | | .last(" limit 1")); |
| | | if(null == applyLever || applyLever.getLever().equals("1")){ |
| | | userInfoVO.setSiteLever("1"); |
| | | }else{ |
| | | userInfoVO.setSiteLever(leverSplit(applyLever.getLever())); |
| | | } |
| | | return ServerResponse.createBySuccess(userInfoVO); |
| | | } |
| | | |
| | | public String leverSplit(String lever){ |
| | | String levers = "1/2/5/10"; |
| | | String[] parts = levers.split("/"); |
| | | int index = Arrays.asList(parts).indexOf(lever); |
| | | if (index != -1) { |
| | | return String.join("/", Arrays.copyOfRange(parts, 0, index + 1)); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | rUserAssets.setCumulativeProfitAndLoss(hProfitAndLose.toString()); |
| | | rUserAssets.setHandlingCharge(hMoney.toString()); |
| | | rUserAssets.setProfitAndLoss(profitAndLose.toString()); |
| | | |
| | | rUserAssets.setIsZf(userAssets.getIsZf()); |
| | | rUserAssets.setAmountToBeCovered(userAssets.getAmountToBeCovered().toString()); |
| | | BigDecimal rate = rateServices.currencyRate( |
| | | EStockType.getEStockTypeByCode(userAssets.getAccectType()),EStockType.US); |
| | | |
| | |
| | | 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()); |
| | | AllProfitAndLose = AllProfitAndLose.add(profitAndLossUSD); |
| | | allTotalAssets = allTotalAssets.add(totleMoneyUSD); |
| | | allAmt = allAmt.add(availableBalanceUSD); |
| | |
| | | rUserAssetsList.add(rUserAssets); |
| | | |
| | | return ServerResponse.createBySuccess(rUserAssetsList); |
| | | } |
| | | |
| | | public BigDecimal getProfitAndLose(Integer userId){ |
| | | List<UserPosition> userPositions; |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(userId, |
| | | "","", |
| | | 0, "IN"); |
| | | |
| | | |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | | if (userPositions.size() > 0) { |
| | | for (UserPosition position : userPositions) { |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position, priceServices.getNowPrice(position.getStockCode())); |
| | | userPositionVOS.add(userPositionVO); |
| | | } |
| | | } |
| | | BigDecimal profitAndLose = BigDecimal.ZERO; |
| | | for (UserPositionVO f : userPositionVOS) { |
| | | profitAndLose = profitAndLose.add(f.getProfitAndLose()); |
| | | } |
| | | return profitAndLose; |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | 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"); |
| | | } |