| | |
| | | @Transactional |
| | | @Override |
| | | public void RealTimeDataProcess(EStockType eStockType, StockRealTimeBean timeBean) { |
| | | QueryWrapper<UserPosition> upQuery = new QueryWrapper<>(); |
| | | upQuery.eq("stock_code",timeBean.getPid()); |
| | | upQuery.isNotNull("sell_order_id"); |
| | | // 查询未平仓的价格 |
| | | List<UserPosition> userPositionList = userPositionMapper.selectList(upQuery); |
| | | for (int i = 0; i <userPositionList.size() ; i++) { |
| | | UserPosition userPosition = userPositionList.get(i); |
| | | BigDecimal bigDecimal = new BigDecimal(timeBean.getLast()).subtract(userPosition.getBuyOrderPrice()) |
| | | .multiply(new BigDecimal(userPosition.getOrderNum())); |
| | | if(!userPosition.getOrderDirection().equals("买涨")){ |
| | | bigDecimal = bigDecimal.negate(); |
| | | } |
| | | userPosition.setProfitAndLose(bigDecimal); |
| | | userPosition.setAllProfitAndLose(bigDecimal); |
| | | userPositionMapper.updateById(userPosition); |
| | | } |
| | | |
| | | |
| | | RedisKeyUtil.setCacheRealTimeStock(eStockType,timeBean); |
| | | |
| | | } |
| | | } |