| | |
| | | package com.nq.service.impl; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | 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.*; |
| | | 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; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.nq.vo.user.UserOut; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | ISiteIndexSettingService iSiteIndexSettingService; |
| | | @Autowired |
| | | StockPoll stockPoll; |
| | | |
| | | @Autowired |
| | | IUserService iUserService; |
| | | |
| | | @Resource |
| | | MoneyLogMapper mapper; |
| | |
| | | @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); |
| | | } |
| | |
| | | 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, "JP"); |
| | | |
| | | |
| | | 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"); |
| | | } |
| | |
| | | |
| | | public ServerResponse listByAdmin(String realName, String phone, Integer agentId, Integer accountType, int pageNum, int pageSize, HttpServletRequest request) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | |
| | | List<User> users = this.userMapper.listByAdmin(realName, phone, agentId, accountType); |
| | | |
| | | PageInfo pageInfo = new PageInfo(users); |
| | | List<UserOut> userOuts = new ArrayList<>(); |
| | | |
| | | // 获取用户资产信息并构建返回结果 |
| | | Map<Integer, UserOut> userOutMap = new HashMap<>(); |
| | | for (User user : users) { |
| | | ServerResponse money = iUserService.getMoney(user.getId()); |
| | | List<RUserAssets> rUserAssetsList = (List<RUserAssets>) money.getData(); |
| | | RUserAssets rUserAssets = rUserAssetsList.stream() |
| | | .filter(stock -> "JP".equals(stock.getAccectType())) |
| | | .findFirst() |
| | | .orElse(null); |
| | | |
| | | UserOut userOut = Convert.convert(UserOut.class, user); |
| | | if (rUserAssets != null) { |
| | | userOut.setTotalMoney(rUserAssets.getTotalMoney().equals("0E-8") ? "0" : rUserAssets.getTotalMoney()); |
| | | userOut.setFreezeMoney(rUserAssets.getFreezeMoney().equals("0E-8") ? "0" : rUserAssets.getFreezeMoney()); |
| | | userOut.setAvailableBalance(rUserAssets.getAvailableBalance().equals("0E-8") ? "0" : rUserAssets.getAvailableBalance()); |
| | | userOut.setAmountToBeCovered(new BigDecimal(rUserAssets.getAmountToBeCovered())); |
| | | } |
| | | userOutMap.put(user.getId(), userOut); |
| | | userOuts.add(userOut); |
| | | } |
| | | |
| | | PageInfo pageInfo = new PageInfo(users); |
| | | pageInfo.setList(userOuts); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | |