| | |
| | | @RequestParam("buyNum") Integer buyNum, |
| | | @RequestParam("buyType") Integer buyType, |
| | | @RequestParam("lever") Integer lever, |
| | | @RequestParam(value = "password",required = false) String password, |
| | | @RequestParam(value = "profitTarget",required = false) |
| | | BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) { |
| | | buyLock.lock(); |
| | |
| | | return ServerResponse.createByErrorMsg("当前下单人数过多,请稍后重试", request); |
| | | } |
| | | buyOrderCreated.set(true); |
| | | return this.iUserPositionService.buy(stockId, buyNum, buyType, lever,profitTarget,stopLoss, password,request,null); |
| | | return this.iUserPositionService.buy(stockId, buyNum, buyType, lever,profitTarget,stopLoss,request,null); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request); |
| | | } finally{ |
| | |
| | | |
| | | public interface IUserPositionService { |
| | | ServerResponse buy(Integer paramInteger1, Integer paramInteger2, Integer paramInteger3, |
| | | Integer paramInteger4,BigDecimal paramInteger5,BigDecimal paramInteger6,String password,HttpServletRequest paramHttpServletRequest,Integer userId) ; |
| | | Integer paramInteger4,BigDecimal paramInteger5,BigDecimal paramInteger6,HttpServletRequest paramHttpServletRequest,Integer userId) ; |
| | | |
| | | ServerResponse sell(String paramString, int paramInt); |
| | | ServerResponse sell(String paramString,Integer closeNumber, int paramInt, HttpServletRequest request); |
| | |
| | | |
| | | |
| | | @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); |
| | | |
| | |
| | | //购买 |
| | | Stock stock = stockMapper.findStockByCode(purchaseApplication.getStockCode()); |
| | | ServerResponse serverResponse = userPositionService.buy(stock.getId(),purchaseApplication.getBuyNum(), |
| | | purchaseApplication.getBuyType(),purchaseApplication.getLever(),purchaseApplication.getProfitTarget(),purchaseApplication.getStopTarget(), |
| | | "",request,purchaseApplication.getUserId()); |
| | | purchaseApplication.getBuyType(),purchaseApplication.getLever(),purchaseApplication.getProfitTarget(),purchaseApplication.getStopTarget(), request,purchaseApplication.getUserId()); |
| | | if(serverResponse.getStatus() == ResponseCode.SUCCESS.getCode()){ |
| | | this.purchaseApplicationMapper.updateById(purchaseApplication); |
| | | this.siteTaskLogMapper.insert(siteTaskLog); |