| | |
| | | boolean pm_flag = BuyAndSellUtils.isTransTime(pm_begin, pm_end); |
| | | log.info("是否在上午交易时间 = {} 是否在下午交易时间 = {}", Boolean.valueOf(am_flag), Boolean.valueOf(pm_flag)); |
| | | |
| | | // if (!am_flag && !pm_flag) { |
| | | // return ServerResponse.createByErrorMsg("下单失败,不在交易时段内"); |
| | | // } |
| | | if (!am_flag && !pm_flag) { |
| | | return ServerResponse.createByErrorMsg("下单失败,不在交易时段内"); |
| | | } |
| | | if (siteProduct.getHolidayDisplay()) { |
| | | return ServerResponse.createByErrorMsg("周末或节假日不能交易!"); |
| | | } |
| | |
| | | stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | } |
| | | |
| | | if (stockListVO.getNowPrice() == null) { |
| | | stockListVO.setNowPrice("0"); |
| | | if (stockListVO.getNowPrice() == null || new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) <= 0) { |
| | | // stockListVO.setNowPrice("0"); |
| | | stockListVO.setNowPrice(String.valueOf(position.getBuyOrderIdIndex())); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | // stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | nowPrice = stockListVO.getNowPrice(); |
| | | if (nowPrice == null) { |
| | | if(position.getBuyOrderIdIndex().compareTo(BigDecimal.ZERO) > 0){ |
| | | if (nowPrice == null || new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) <= 0) { |
| | | if(null != position.getBuyOrderIdIndex() && position.getBuyOrderIdIndex().compareTo(BigDecimal.ZERO) > 0){ |
| | | nowPrice = String.valueOf(position.getBuyOrderIdIndex()); |
| | | }else { |
| | | nowPrice = String.valueOf(position.getBuyOrderPrice()); |
| | |
| | | public void synchronizePrice(){ |
| | | Map<String,BigDecimal> priceMap = new HashMap<>(); |
| | | List<UserPosition> userPositions = this.userPositionMapper.synchronizePrice(); |
| | | log.info("-------------------同步收盘价,查询数据总量 {}个--------------",userPositions.size()); |
| | | int count = 0; |
| | | for (UserPosition position : userPositions) { |
| | | if(priceMap.containsKey(position.getStockGid())){ |
| | | BigDecimal newPrice = priceMap.get(position.getStockGid()); |
| | | position.setBuyOrderIdIndex(newPrice); |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | }else { |
| | | StockListVO stockListVO = new StockListVO(); |
| | | stockListVO = SinaStockApi.assembleLideStockListVO(LiDeDataUtils.getStock(position.getStockCode())); |
| | | if (ObjectUtils.isEmpty(stockListVO)) { |
| | | stockListVO = SinaStockApi.assembleStockListVO(SinaStockApi.getSinaStock(position.getStockGid())); |
| | | } |
| | | if(stockListVO.getNowPrice() == null){ |
| | | stockListVO.setNowPrice(String.valueOf(position.getBuyOrderPrice())); |
| | | if(stockListVO.getNowPrice() != null && new BigDecimal(stockListVO.getNowPrice()).compareTo(BigDecimal.ZERO) > 0){ |
| | | position.setBuyOrderIdIndex(new BigDecimal(stockListVO.getNowPrice())); |
| | | priceMap.put(position.getStockGid(),new BigDecimal(stockListVO.getNowPrice())); |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | } |
| | | position.setBuyOrderIdIndex(new BigDecimal(stockListVO.getNowPrice())); |
| | | priceMap.put(position.getStockGid(),new BigDecimal(stockListVO.getNowPrice())); |
| | | } |
| | | userPositionMapper.updateByPrimaryKey(position); |
| | | count++; |
| | | } |
| | | log.info("-------------------同步收盘价 {}个--------------"); |
| | | log.info("-------------------同步收盘价 {}个--------------",count); |
| | | } |
| | | } |
| | | |