| | |
| | | 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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | @Controller |
| | |
| | | @Autowired |
| | | IUserRechargeService iUserRechargeService; |
| | | |
| | | |
| | | @Autowired |
| | | PayServiceImpl payService; |
| | | |
| | | @Autowired |
| | | IApplyLeverServices iApplyLeverServices; |
| | | |
| | | @Autowired |
| | | IUserWithdrawService iUserWithdrawService; |
| | | |
| | | 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"}) |
| | |
| | | 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(); |
| | |
| | | //用户平仓操作 |
| | | @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); |
| | | } |
| | | |
| | | |
| | |
| | | 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); |
| | | } |
| | | if(new BigDecimal(tradeAmoun).compareTo(new BigDecimal("1000")) < 0){ |
| | | return ServerResponse.createByErrorMsg("请重新输入,最低充值金额:1000", request); |
| | | } |
| | | payCreated.set(true); |
| | | return payService.thirdPartyRecharge(request,tradeAmoun); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ServerResponse.createByErrorMsg("获取充值链接异常,请稍后重试", request); |
| | | } finally{ |
| | | payLock.unlock(); |
| | | payCreated.set(false); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 充值异步接收地址 |
| | | */ |
| | | @PostMapping({"rechargeCallback.do"}) |
| | | public void rechargeCallback(PaymentResponse vo, HttpServletResponse response) throws IOException { |
| | | payService.rechargeCallback(vo,response); |
| | | } |
| | | |
| | | /** |
| | | * 代付回调通知 |
| | | */ |
| | | @PostMapping({"noticePayment.do"}) |
| | | public void noticePayment(TradeResultVO vo,HttpServletResponse response) throws IOException { |
| | | iUserWithdrawService.noticePayment(vo,response); |
| | | } |
| | | } |