| | |
| | | package com.nq.controller.protol; |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.google.common.collect.Maps; |
| | | import com.google.gson.Gson; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.enums.EStockType; |
| | | import com.nq.pojo.ApplyLever; |
| | | import com.nq.pojo.StockSubscribe; |
| | | import com.nq.pojo.UserStockSubscribe; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.*; |
| | | import com.nq.service.impl.PayServiceImpl; |
| | | import com.nq.utils.PropertiesUtil; |
| | | |
| | | import java.io.IOException; |
| | | 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.HttpServletResponse; |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | import com.nq.utils.translate.GoogleTranslateUtil; |
| | | import com.nq.vo.stock.UserStockSubscribeAddIn; |
| | | import org.apache.ibatis.annotations.Property; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | @Autowired |
| | | IUserRechargeService iUserRechargeService; |
| | | |
| | | |
| | | @Autowired |
| | | PayServiceImpl payService; |
| | | |
| | | @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(); |
| | | |
| | | private static final ThreadLocal<Boolean> payCreated = ThreadLocal.withInitial(() -> false); |
| | | private final Lock payLock = new ReentrantLock(); |
| | | |
| | | //添加到自选股 |
| | | @RequestMapping({"addOption.do"}) |
| | |
| | | @RequestParam("lever") Integer lever, |
| | | @RequestParam(value = "profitTarget",required = false) |
| | | BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) { |
| | | return this.iUserPositionService.buy(stockId, buyNum, buyType, lever,profitTarget,stopLoss, 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"}) |
| | |
| | | //用户平仓操作 |
| | | @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("number") Integer number) { |
| | | return this.iUserPositionService.sell(positionSn,1,number,request); |
| | | } |
| | | |
| | | |
| | |
| | | @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"}) |
| | |
| | | return iApplyLeverServices.applyLever(applyLever,request); |
| | | } |
| | | |
| | | /** |
| | | * 充值第三方支付 |
| | | */ |
| | | @RequestMapping({"thirdPartyRecharge.do"}) |
| | | @ResponseBody |
| | | public ServerResponse thirdPartyRecharge(@RequestParam("tradeAmoun") String tradeAmoun,HttpServletRequest request) { |
| | | payLock.lock(); |
| | | try { |
| | | if (payCreated.get()) { |
| | | return ServerResponse.createByErrorMsg("当前充值人数过多,请稍后重试", request); |
| | | } |
| | | payCreated.set(true); |
| | | return payService.thirdPartyRecharge(request,tradeAmoun); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ServerResponse.createByErrorMsg("获取充值链接异常,请稍后重试", request); |
| | | } finally{ |
| | | payLock.unlock(); |
| | | payCreated.set(false); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充值异步接收地址 |
| | | */ |
| | | @RequestMapping({"rechargeCallback.do"}) |
| | | @ResponseBody |
| | | public void rechargeCallback(HttpServletResponse response,RechargeCallbackVo rechargeCallbackVo) throws IOException { |
| | | payService.rechargeCallback(response,rechargeCallbackVo); |
| | | } |
| | | } |