| | |
| | | SiteSetting siteSetting = iSiteSettingService.getSiteSetting(); |
| | | StockRealTimeBean stockRealTimeBean = RedisKeyUtil.getCacheRealTimeStock(stock); |
| | | BigDecimal pcp = new BigDecimal(stockRealTimeBean.getPcp()); |
| | | SiteVipRob siteVipRob = iSiteVipRobService.getByStockCode(stock.getStockCode()); |
| | | // 检查VIP抢筹功能是否开启且用户符合条件 |
| | | if (null != siteVipRob && siteVipRob.getStatus() == 1 && pcp.compareTo(siteVipRob.getStockChg()) >= 0) { |
| | | // 检查密码是否为空 |
| | | if (StringUtils.isBlank(password)) { |
| | | return ServerResponse.createByErrorMsg("VIP抢筹秘钥错误", request); |
| | | } |
| | | // 检查交易数量是否达到最低要求 |
| | | if (buyNum < siteVipRob.getLowestTrade()) { |
| | | return ServerResponse.createByErrorMsg("VIP抢筹秘最低交易数量为" + siteVipRob.getLowestTrade(), request); |
| | | } |
| | | // 检查VIP密码是否正确 |
| | | if (!siteSetting.getVipPassword().equals(password)) { |
| | | return ServerResponse.createByErrorMsg("VIP抢筹秘钥错误", request); |
| | | } |
| | | } |
| | | // SiteVipRob siteVipRob = iSiteVipRobService.getByStockCode(stock.getStockCode()); |
| | | // // 检查VIP抢筹功能是否开启且用户符合条件 |
| | | // if (null != siteVipRob && siteVipRob.getStatus() == 1 && pcp.compareTo(siteVipRob.getStockChg()) >= 0) { |
| | | // // 检查密码是否为空 |
| | | // if (StringUtils.isBlank(password)) { |
| | | // return ServerResponse.createByErrorMsg("VIP抢筹秘钥错误", request); |
| | | // } |
| | | // // 检查交易数量是否达到最低要求 |
| | | // if (buyNum < siteVipRob.getLowestTrade()) { |
| | | // return ServerResponse.createByErrorMsg("VIP抢筹秘最低交易数量为" + siteVipRob.getLowestTrade(), request); |
| | | // } |
| | | // // 检查VIP密码是否正确 |
| | | // if (!siteSetting.getVipPassword().equals(password)) { |
| | | // return ServerResponse.createByErrorMsg("VIP抢筹秘钥错误", request); |
| | | // } |
| | | // } |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | |
| | |
| | | userPosition.setStockCode(stock.getStockCode()); |
| | | userPosition.setStockSpell(stock.getStockSpell()); |
| | | userPosition.setStockName(userStockSubscribe.getNewName()); |
| | | StringBuffer gid = new StringBuffer(); |
| | | gid.append(stockSubscribe.getStockType()!=null?stockSubscribe.getStockType():""); |
| | | gid.append(userStockSubscribe.getNewCode()!=null?userStockSubscribe.getNewCode():"stock code invaild"); |
| | | userPosition.setStockGid(gid.toString()); |
| | | userPosition.setStockGid(stock.getStockType()); |
| | | userPosition.setBuyOrderId(GeneratePosition.getPositionId()); |
| | | userPosition.setBuyOrderTime(new Date()); |
| | | userPosition.setBuyOrderPrice(userStockSubscribe.getBuyPrice()); |
| | |
| | | |
| | | 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) { |