| | |
| | | @Autowired |
| | | UserPositionCheckDzService userPositionCheckDzService; |
| | | |
| | | |
| | | @Autowired |
| | | UserPendingorderService userPendingorderService; |
| | | |
| | | @Transactional |
| | | public ServerResponse buy(Integer stockId, Integer buyNum, Integer buyType, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget, HttpServletRequest request) { |
| | |
| | | } |
| | | |
| | | @Transactional |
| | | public ServerResponse goldCrudeOilbuy(String name, Integer buyNum, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget, HttpServletRequest request) { |
| | | public ServerResponse goldCrudeOilbuy(String name, Integer buyNum, Integer buyType,Integer lever, BigDecimal profitTarget, BigDecimal stopTarget, HttpServletRequest request) { |
| | | |
| | | SiteProduct siteProduct = iSiteProductService.getProductSetting(); |
| | | |
| | |
| | | userPosition.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setBuyOrderTime(new Date()); |
| | | userPosition.setBuyOrderPrice(price); |
| | | userPosition.setOrderDirection("买涨"); |
| | | userPosition.setOrderDirection((buyType.intValue() == 0) ? "买涨" : "买跌"); |
| | | userPosition.setOrderNum(buyNum); |
| | | userPosition.setIsLock(Integer.valueOf(0)); |
| | | userPosition.setOrderLever(lever); |
| | |
| | | |
| | | public ServerResponse findMyPositionByCodeAndSpell(String stockCode, String stockSpell, |
| | | Integer state, HttpServletRequest request, |
| | | int pageNum, int pageSize, String stockType) { |
| | | int pageNum, int pageSize, String stockType,Integer pendingStatus) { |
| | | User user = this.iUserService.getCurrentUser(request); |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<UserPosition> userPositions = null; |
| | | if(state == 2){ |
| | | List<UserPendingorder> list = userPendingorderService.list(new LambdaQueryWrapper<>(UserPendingorder.class) |
| | | .eq(UserPendingorder::getUserId, user.getId()) |
| | | .eq(UserPendingorder::getStockGid,(null != stockCode && "HJYY".equals(stockCode)) ? stockCode : stockType) |
| | | .eq(UserPendingorder::getPositionType,pendingStatus) |
| | | ); |
| | | PageInfo pageInfo = new PageInfo(); |
| | | pageInfo.setList(list); |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | }else { |
| | | if (stockCode.equals("HJYY")) { |
| | | LambdaQueryWrapper<UserPosition> wrapper = getUserPositionLambdaQueryWrapper(stockCode, state, user); |
| | | userPositions = userPositionMapper.selectList(wrapper); |
| | | } else { |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(user.getId(), |
| | | stockCode, stockSpell, |
| | | state, stockType); |
| | | } |
| | | |
| | | |
| | | if(stockCode.equals("HJYY")){ |
| | | LambdaQueryWrapper<UserPosition> wrapper = getUserPositionLambdaQueryWrapper(stockCode, state, user); |
| | | userPositions = userPositionMapper.selectList(wrapper); |
| | | }else{ |
| | | userPositions = userPositionMapper. |
| | | findMyPositionByCodeAndSpell(user.getId(), |
| | | stockCode, stockSpell, |
| | | state, stockType); |
| | | } |
| | | |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | | if (userPositions.size() > 0) { |
| | | for (UserPosition position : userPositions) { |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | if(position.getStockSpell().equals("XAUUSD") || position.getStockSpell().equals("USOIL")){ |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(position.getStockSpell())); |
| | | }else{ |
| | | if(state == 0){ |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | }else{ |
| | | nowPrice = position.getSellOrderPrice(); |
| | | List<UserPositionVO> userPositionVOS = Lists.newArrayList(); |
| | | if (userPositions.size() > 0) { |
| | | for (UserPosition position : userPositions) { |
| | | BigDecimal nowPrice = BigDecimal.ZERO; |
| | | if (position.getStockSpell().equals("XAUUSD") || position.getStockSpell().equals("USOIL")) { |
| | | nowPrice = new BigDecimal(RedisShardedPoolUtils.get(position.getStockSpell())); |
| | | } else { |
| | | if (state == 0) { |
| | | nowPrice = priceServices.getNowPrice(position.getStockCode()); |
| | | } else { |
| | | nowPrice = position.getSellOrderPrice(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position,nowPrice); |
| | | userPositionVO.setOrderTotalPrice(userPositionVO.getOrderTotalPrice().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | UserPositionVO userPositionVO = UserPointUtil.assembleUserPositionVO(position, nowPrice); |
| | | userPositionVO.setOrderTotalPrice(userPositionVO.getOrderTotalPrice().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, userPositionVO.getStockCode())); |
| | | if(position.getSellOrderId() == null){ |
| | | if (null != stockSubscribe && DateUtil.date().before(stockSubscribe.getListDate())) { |
| | | userPositionVO.setProfitAndLose(BigDecimal.ZERO); |
| | | userPositionVO.setProfitAndLoseParent("0%"); |
| | | userPositionVO.setIsListed(false); |
| | | }else{ |
| | | userPositionVO.setIsListed(true); |
| | | StockSubscribe stockSubscribe = stockSubscribeMapper.selectOne(new LambdaQueryWrapper<StockSubscribe>() |
| | | .eq(StockSubscribe::getCode, userPositionVO.getStockCode())); |
| | | if (position.getSellOrderId() == null) { |
| | | if (null != stockSubscribe && DateUtil.date().before(stockSubscribe.getListDate())) { |
| | | userPositionVO.setProfitAndLose(BigDecimal.ZERO); |
| | | userPositionVO.setProfitAndLoseParent("0%"); |
| | | userPositionVO.setIsListed(false); |
| | | } else { |
| | | userPositionVO.setIsListed(true); |
| | | userPositionVO.setProfitAndLose(userPositionVO.getProfitAndLose().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | } |
| | | } else { |
| | | userPositionVO.setProfitAndLose(userPositionVO.getProfitAndLose().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | } |
| | | }else{ |
| | | userPositionVO.setProfitAndLose(userPositionVO.getProfitAndLose().multiply(new BigDecimal(userPositionVO.getOrderLever()))); |
| | | userPositionVOS.add(userPositionVO); |
| | | } |
| | | userPositionVOS.add(userPositionVO); |
| | | } |
| | | |
| | | PageInfo pageInfo = new PageInfo(userPositions); |
| | | pageInfo.setList(userPositionVOS); |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | |
| | | PageInfo pageInfo = new PageInfo(userPositions); |
| | | pageInfo.setList(userPositionVOS); |
| | | |
| | | return ServerResponse.createBySuccess(pageInfo); |
| | | } |
| | | |
| | | private static LambdaQueryWrapper<UserPosition> getUserPositionLambdaQueryWrapper(String stockCode, Integer state, User user) { |