| | |
| | | |
| | | |
| | | @Transactional |
| | | public ServerResponse buy(Integer stockId, Integer buyNum, Integer buyType, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget,String password, HttpServletRequest request,Integer userId) { |
| | | public ServerResponse buy(Integer stockId, Integer buyNum, Integer buyType, Integer lever, BigDecimal profitTarget, BigDecimal stopTarget, HttpServletRequest request,Integer userId) { |
| | | |
| | | SiteProduct siteProduct = iSiteProductService.getProductSetting(); |
| | | |
| | |
| | | if (nowPrice.compareTo(new BigDecimal("0")) == 0) { |
| | | return ServerResponse.createByErrorMsg("报价0,请稍后再试", request); |
| | | } |
| | | //vip抢筹 |
| | | 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); |
| | | } |
| | | } |
| | | // //vip抢筹 |
| | | // 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); |
| | | // } |
| | | // } |
| | | BigDecimal buyAmt = nowPrice.multiply(new BigDecimal(buyNum)).divide(new BigDecimal(lever)); |
| | | BigDecimal orderFree = siteSettingBuyFee.multiply(buyAmt); |
| | | |