| | |
| | | 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.*; |
| | |
| | | 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; |
| | | 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.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | IFileUploadService iFileUploadService; |
| | | |
| | | @Autowired |
| | | IUserIndexPositionService iUserIndexPositionService; |
| | | |
| | | @Autowired |
| | | IUserFuturesPositionService iUserFuturesPositionService; |
| | | |
| | | @Autowired |
| | | IUserStockSubscribeService iUserStockSubscribeService; |
| | | @Autowired |
| | | IStockSubscribeService iStockSubscribeService; |
| | |
| | | IRateServices rateServices; |
| | | |
| | | @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(); |
| | |
| | | return serverResponse; |
| | | } |
| | | |
| | | /** |
| | | * 新股列表 |
| | | * @param pageNum |
| | | * @param pageSize |
| | | * @param request |
| | | * @return |
| | | */ |
| | | @RequestMapping({"getStockSubscribeList.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getStockSubscribeList(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | HttpServletRequest request) { |
| | | return this.iStockSubscribeService.listPageInfo(pageNum, pageSize, request); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 用户新股列表 |
| | |
| | | /*新股申购-用户新股申购数据*/ |
| | | @RequestMapping({"getOneSubscribeByUserId.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getOneSubscribeByUserId(@RequestParam(value ="type",required = false)String type, HttpServletRequest request) { |
| | | return this.iUserStockSubscribeService.getOneSubscribeByUserId(type,request); |
| | | public ServerResponse getOneSubscribeByUserId(@RequestParam(value ="type",required = false)String type, |
| | | @RequestParam(value ="status",required = false)Integer status, |
| | | HttpServletRequest request) { |
| | | return this.iUserStockSubscribeService.getOneSubscribeByUserId(type, status, request); |
| | | } |
| | | |
| | | /*新股申购-用户新股申购数据分页*/ |
| | | @RequestMapping({"getOneSubscribeByUserIdPage.do"}) |
| | | @ResponseBody |
| | | public ServerResponse getOneSubscribeByUserIdPage(@RequestParam(value = "pageNum", defaultValue = "1") int pageNum, |
| | | @RequestParam(value = "pageSize", defaultValue = "5") int pageSize, |
| | | @RequestParam(value ="type",required = false)String type, |
| | | @RequestParam(value ="status",required = false)Integer status, |
| | | HttpServletRequest request) { |
| | | return this.iUserStockSubscribeService.getOneSubscribeByUserIdPage(pageNum, pageSize, type, status, request); |
| | | } |
| | | |
| | | /*新股申购-用户提交金额*/ |
| | |
| | | @ResponseBody |
| | | public ServerResponse transfer(@RequestParam("fromType") String fromType, @RequestParam("toType") String toType, |
| | | @RequestParam("amt") String amt, HttpServletRequest request) { |
| | | if (fromType.equals(toType)) { |
| | | return ServerResponse.createByErrorMsg("货币类型不能相同", request); |
| | | } |
| | | return iUserService.transfer(fromType, toType, amt,request); |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping({"thirdPartyRecharge.do"}) |
| | | @ResponseBody |
| | | public ServerResponse thirdPartyRecharge(@RequestParam("tradeAmoun") String tradeAmoun,HttpServletRequest request) { |
| | | public ServerResponse thirdPartyRecharge(@RequestParam("tradeAmoun") String tradeAmoun,@RequestParam("type") Integer type,HttpServletRequest request) { |
| | | payLock.lock(); |
| | | try { |
| | | if (payCreated.get()) { |
| | | return ServerResponse.createByErrorMsg("当前充值人数过多,请稍后重试", request); |
| | | } |
| | | if (!isIntegerGreaterThan100(tradeAmoun)) { |
| | | return ServerResponse.createByErrorMsg("请输入整数!",request); |
| | | } |
| | | if(null == type){ |
| | | 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); |
| | | return payService.thirdPartyRecharge(request,tradeAmoun,type); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return ServerResponse.createByErrorMsg("获取充值链接异常,请稍后重试", request); |
| | |
| | | payCreated.set(false); |
| | | } |
| | | } |
| | | |
| | | // 判断字符串是否是整数且大于100 |
| | | public static boolean isIntegerGreaterThan100(String str) { |
| | | try { |
| | | int number = Integer.parseInt(str); // 尝试将字符串转换为整数 |
| | | return number > 100; // 判断是否大于100 |
| | | } catch (NumberFormatException e) { |
| | | return false; // 如果转换失败,说明不是整数 |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 充值异步接收地址 |
| | | * 充值1异步接收地址 |
| | | */ |
| | | @PostMapping({"rechargeCallback.do"}) |
| | | public void rechargeCallback(PaymentResponse vo, HttpServletResponse response) throws IOException { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 代付回调通知 |
| | | * 充值2异步接收地址 |
| | | */ |
| | | @PostMapping({"noticePayment.do"}) |
| | | public void noticePayment(TradeResultVO vo,HttpServletResponse response) throws IOException { |
| | | iUserWithdrawService.noticePayment(vo,response); |
| | | @PostMapping({"rechargeCallbackTwo.do"}) |
| | | public void rechargeCallbackTwo(TransactionStatusVo vo, HttpServletResponse response) throws IOException { |
| | | payService.rechargeCallbackTwo(vo,response); |
| | | } |
| | | } |