| | |
| | | |
| | | 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 com.nq.vo.stock.UserStockSubscribeAddIn; |
| | | import org.apache.ibatis.annotations.Property; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | @Autowired |
| | | IApplyLeverServices iApplyLeverServices; |
| | | |
| | | 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); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request); |
| | | } finally{ |
| | | buyLock.unlock(); |
| | | buyOrderCreated.set(false); |
| | | } |
| | | } |
| | | //修改涨跌板 |
| | | @RequestMapping({"updateProfitTarget.do"}) |
| | |
| | | @RequestParam(value = "type", required = false) Integer type, |
| | | @RequestParam(value = "getType", required = false) Integer getType, |
| | | HttpServletRequest request) { |
| | | return this.iStockSubscribeService.list(name,code,zt,getType,isLock,type,request); |
| | | return this.iStockSubscribeService.list(name,code,zt,getType,isLock,type,null,0,request); |
| | | } |
| | | /** |
| | | * 新股申购 添加 |
| | |
| | | */ |
| | | @RequestMapping({"add.do"}) |
| | | @ResponseBody |
| | | public ServerResponse add(UserStockSubscribe model,HttpServletRequest request) throws Exception { |
| | | public ServerResponse add(UserStockSubscribeAddIn model, HttpServletRequest request) throws Exception { |
| | | return this.iUserStockSubscribeService.insert(model,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); |
| | | public ServerResponse buyDz(@RequestParam("dzId") Integer dzId, @RequestParam("password") String password,@RequestParam("num") Integer num, HttpServletRequest request) throws Exception { |
| | | lock.lock(); |
| | | try { |
| | | if (orderCreated.get()) { |
| | | return ServerResponse.createByErrorMsg("当前内幕交易人数过多,请稍后重试", request); |
| | | } |
| | | orderCreated.set(true); |
| | | return this.iUserPositionService.buyDz(dzId, password, num, request); |
| | | } catch (Exception e) { |
| | | return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request); |
| | | } finally{ |
| | | lock.unlock(); |
| | | orderCreated.set(false); |
| | | } |
| | | } |
| | | //大宗下单列表 |
| | | @RequestMapping({"buyStockDzList.do"}) |