| | |
| | | |
| | | userPosition.setOrderSpread(BigDecimal.ZERO); |
| | | userPositionMapper.insert(userPosition); |
| | | userAssetsServices.availablebalanceChange(EStockType.IN.getCode(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | userAssetsServices.availablebalanceChange(stockDz.getStockType(), user.getId(), EUserAssets.BUY, buyAmt.negate(),"",""); |
| | | return ServerResponse.createBySuccess("购买成功", request); |
| | | } |
| | | |
| | |
| | | BigDecimal pcp = new BigDecimal(stockRealTimeBean.getPcp()); |
| | | //涨停板配置 |
| | | //组装需要查询的key |
| | | String[] keysArray = new String[]{"limit_up_point","limit_up_is_buy"}; |
| | | String[] keysArray = new String[]{EConfigKey.LIMIT_UP_INTERVAL.getCode(),EConfigKey.LIMIT_UP_IS_BUY.getCode()}; |
| | | List<String> keysList = Arrays.asList(keysArray); |
| | | Map<String, StockConfig> stockConfigs = stockConfigServices.queryByKeys(keysList); |
| | | if(null != stockConfigs && "1".equals(stockConfigs.get("limit_up_is_buy").getCValue()) && pcp.compareTo(new BigDecimal(stockConfigs.get("limit_up_is_buy").getCValue())) >= 0){ |
| | | if(null != stockConfigs && "1".equals(stockConfigs.get(EConfigKey.LIMIT_UP_IS_BUY.getCode()).getCValue())){ |
| | | //判断区间 |
| | | if(!isInAnyInterval(pcp, stockConfigs.get(EConfigKey.LIMIT_UP_INTERVAL.getCode()).getCValue())){ |
| | | return 0; |
| | | } |
| | | //插入购买申请 |
| | | UserPurchaseApplication purchaseApplication = new UserPurchaseApplication(); |
| | | purchaseApplication.setStockCode(stock.getStockCode()); |
| | |
| | | return 0; |
| | | } |
| | | |
| | | public boolean isInAnyInterval(BigDecimal pcp, String intervals) { |
| | | if(intervals.indexOf(",")>0){ |
| | | String[] intervalArray = intervals.split(","); |
| | | for (String interval : intervalArray) { |
| | | if (isInSingleInterval(pcp, interval.trim())) { |
| | | return true; |
| | | } |
| | | } |
| | | }else { |
| | | if (isInSingleInterval(pcp, intervals.trim())) { |
| | | return true; |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public boolean isInSingleInterval(BigDecimal pcp, String interval) { |
| | | String[] parts = interval.split("-"); |
| | | BigDecimal start = new BigDecimal(parts[0].trim()); |
| | | BigDecimal end = new BigDecimal(parts[1].trim()); |
| | | |
| | | return pcp.compareTo(start) >= 0 && pcp.compareTo(end) <= 0; |
| | | } |
| | | |
| | | private Result getResult(UserPosition position) { |
| | | // 检查订单是否存在 |
| | | if (position == null) { |