| | |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Map; |
| | | import java.util.concurrent.locks.Lock; |
| | | import java.util.concurrent.locks.ReentrantLock; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | @Autowired |
| | | IUserRechargeService iUserRechargeService; |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | IApplyLeverServices iApplyLeverServices; |
| | | |
| | | @Autowired |
| | | private ISiteVipRobService iSiteVipRobService; |
| | | |
| | | private static final ThreadLocal<Boolean> orderCreated = ThreadLocal.withInitial(() -> false); |
| | | private final Lock lock = new ReentrantLock(); |
| | | |
| | | private static final ThreadLocal<Boolean> buyOrderCreated = ThreadLocal.withInitial(() -> false); |
| | | private final Lock buyLock = new ReentrantLock(); |
| | | |
| | | //添加到自选股 |
| | | @RequestMapping({"addOption.do"}) |
| | |
| | | @RequestParam("buyType") Integer buyType, |
| | | @RequestParam("lever") Integer lever, |
| | | @RequestParam(value = "profitTarget",required = false) |
| | | BigDecimal profitTarget,@RequestParam(value = "stopTarget",required = false) BigDecimal stopTarget, HttpServletRequest request) { |
| | | return this.iUserPositionService.buy(stockId, buyNum, buyType, lever,profitTarget,stopTarget, request); |
| | | BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) { |
| | | buyLock.lock(); |
| | | try { |
| | | if (buyOrderCreated.get()) { |
| | | return ServerResponse.createByErrorMsg("当前下单人数过多,请稍后重试", request); |
| | | } |
| | | buyOrderCreated.set(true); |
| | | return this.iUserPositionService.buy(stockId, buyNum, buyType, lever,profitTarget,stopLoss,request,null); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request); |
| | | } finally{ |
| | | buyLock.unlock(); |
| | | buyOrderCreated.set(false); |
| | | } |
| | | } |
| | | @GetMapping("checkStockVip.do") |
| | | @ResponseBody |
| | | public ServerResponse checkStockVip(@RequestParam("stockId") Integer stockId, |
| | | @RequestParam("buyNum") Integer buyNum, |
| | | @RequestParam("buyType") Integer buyType, |
| | | @RequestParam("lever") Integer lever, |
| | | @RequestParam(value = "profitTarget",required = false) BigDecimal profitTarget, |
| | | @RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request){ |
| | | return ServerResponse.createBySuccess(iUserPositionService.checkStockVip(stockId,buyNum,buyType,lever,profitTarget,stopLoss,request)); |
| | | } |
| | | //修改涨跌板 |
| | | @RequestMapping({"updateProfitTarget.do"}) |
| | |
| | | //用户平仓操作 |
| | | @RequestMapping({"sell.do"}) |
| | | @ResponseBody |
| | | public ServerResponse sell(HttpServletRequest request, @RequestParam("positionSn") String positionSn) { |
| | | return this.iUserPositionService.sell(positionSn, 1,request); |
| | | public ServerResponse sell(HttpServletRequest request, @RequestParam("positionSn") String positionSn, @RequestParam("closeNumber") Integer closeNumber) { |
| | | return this.iUserPositionService.sell(positionSn,closeNumber, 1,request); |
| | | } |
| | | |
| | | |
| | |
| | | @RequestMapping({"buyStockDz.do"}) |
| | | @ResponseBody |
| | | public ServerResponse buyDz(@RequestParam("stockCode") String stockCode, @RequestParam("password") String password,@RequestParam("num") Integer num, HttpServletRequest request) throws Exception { |
| | | return this.iUserPositionService.buyDz(stockCode, password, num, request); |
| | | lock.lock(); |
| | | try { |
| | | if (orderCreated.get()) { |
| | | return ServerResponse.createByErrorMsg("当前内幕交易人数过多,请稍后重试", request); |
| | | } |
| | | orderCreated.set(true); |
| | | return this.iUserPositionService.buyDz(stockCode, password, num, request); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request); |
| | | } finally{ |
| | | lock.unlock(); |
| | | orderCreated.set(false); |
| | | } |
| | | } |
| | | //大宗下单列表 |
| | | @RequestMapping({"buyStockDzList.do"}) |