| | |
| | | import com.nq.dao.*; |
| | | import com.nq.pojo.*; |
| | | import com.nq.service.*; |
| | | import com.nq.utils.DateTimeUtil; |
| | | import com.nq.utils.timeutil.DateTimeUtil; |
| | | import com.nq.utils.PropertiesUtil; |
| | | import com.nq.utils.redis.JsonUtil; |
| | | import com.nq.utils.redis.RedisShardedPoolUtils; |
| | |
| | | User user = this.iUserService.getCurrentRefreshUser(request); |
| | | |
| | | if (user == null) { |
| | | return ServerResponse.createByErrorMsg("Please log in first"); |
| | | return ServerResponse.createByErrorMsg("Please log in first",request); |
| | | } |
| | | SiteSetting siteSetting = this.iSiteSettingService.getSiteSetting(); |
| | | if (buyNum.intValue() < siteSetting.getBuyMinNum().intValue()) { |
| | | return ServerResponse.createByErrorMsg("The pending order failed, and the purchased quantity was less than" + siteSetting |
| | | .getBuyMinNum() + "stocks"); |
| | | .getBuyMinNum() + "stocks",request); |
| | | } |
| | | if (buyNum.intValue() > siteSetting.getBuyMaxNum().intValue()) { |
| | | return ServerResponse.createByErrorMsg("The pending order failed because the purchased quantity was greater than" + siteSetting |
| | | .getBuyMaxNum() + "stocks"); |
| | | .getBuyMaxNum() + "stocks",request); |
| | | } |
| | | UserPendingorder userPendingorder = userPendingorderMapper.selectOne(new QueryWrapper<UserPendingorder>().eq("user_id", user.getId()).eq("stock_id", stockId).eq("status", 0)); |
| | | if (userPendingorder != null) { |
| | | return ServerResponse.createByErrorMsg("Please do not repeat the order"); |
| | | String lang = request.getHeader("lang"); |
| | | if(lang.equals("ja")){ |
| | | String msg = "繰り返しの送信はご遠慮ください"; |
| | | return ServerResponse.createByErrorMsg(msg); |
| | | }else{ |
| | | return ServerResponse.createByErrorMsg("Please do not repeat the order",request); |
| | | } |
| | | } |
| | | |
| | | userPendingorder = new UserPendingorder(); |
| | |
| | | userPendingorder.setStatus(0); |
| | | int ret = userPendingorderMapper.insert(userPendingorder); |
| | | if (ret > 0) { |
| | | return ServerResponse.createBySuccessMsg("If the pending order is successfully added, the order will be automatically placed if the order conditions are met"); |
| | | String lang = request.getHeader("lang"); |
| | | if(lang.equals("ja")){ |
| | | String msg = "注文が成功しました。取引時間内に自動的に約定されます。"; |
| | | return ServerResponse.createBySuccessMsg(msg); |
| | | }else{ |
| | | return ServerResponse.createBySuccessMsg("If the pending order is successfully added, the order will be automatically placed if the order conditions are met",request); |
| | | } |
| | | } |
| | | return ServerResponse.createByErrorMsg("Add failure"); |
| | | return ServerResponse.createByErrorMsg("Add failure",request); |
| | | |
| | | } |
| | | |
| | |
| | | log.info("当前有挂单的用户数量 为 {}", Integer.valueOf(userPendingorders.size())); |
| | | for (int i = 0; i < userPendingorders.size(); i++) { |
| | | Integer userId = (Integer) userPendingorders.get(i).getUserId(); |
| | | User user = this.userMapper.selectByPrimaryKey(userId); |
| | | User user = this.userMapper.selectById(userId); |
| | | if (user == null) { |
| | | continue; |
| | | } |
| | |
| | | continue; |
| | | } |
| | | log.info("用户id = {} 姓名 = {} 已挂单数: {}", new Object[]{userId, user.getRealName(), Integer.valueOf(userPendingorders.size())}); |
| | | BigDecimal enable_user_amt = user.getEnableAmt(); |
| | | BigDecimal all_freez_amt = new BigDecimal("0"); |
| | | String nowPrice = ""; |
| | | String code = ""; |
| | |
| | | SiteTaskLog siteTaskLog = new SiteTaskLog(); |
| | | siteTaskLog.setTaskType("股票挂单转持仓"); |
| | | String accountType = (user.getAccountType() == 0) ? "正式用户" : "模拟用户"; |
| | | String taskcnt = accountType + "-" + user.getRealName() + "挂单[达到目标价格] 用户id = " + user.getId() + ", 可用资金 = " + enable_user_amt + "冻结保证金 = " + all_freez_amt + ", 目标价格 = " + userPendingorder.getTargetPrice() + ",现价" + nowPrice + ", 涨跌:" + (userPendingorder.getBuyType().intValue() == 0 ? "涨" : "跌"); |
| | | siteTaskLog.setTaskCnt(taskcnt); |
| | | String tasktarget = "此次挂单买入id:" + userPendingorder.getId(); |
| | | siteTaskLog.setTaskTarget(tasktarget); |
| | | siteTaskLog.setAddTime(new Date()); |
| | |
| | | SiteTaskLog siteTaskLog = new SiteTaskLog(); |
| | | siteTaskLog.setTaskType("指数挂单转持仓"); |
| | | String accountType = (user.getAccountType() == 0) ? "正式用户" : "模拟用户"; |
| | | String taskcnt = accountType + "-" + user.getRealName() + "挂单[达到目标价格] 用户id = " + user.getId() + ", 可用资金 = " + enable_user_amt + "冻结保证金 = " + all_freez_amt + ", 目标价格 = " + userPendingorder.getTargetPrice() + ",现价" + nowPrice + ", 涨跌:" + (userPendingorder.getBuyType().intValue() == 0 ? "涨" : "跌"); |
| | | siteTaskLog.setTaskCnt(taskcnt); |
| | | String tasktarget = "此次挂单买入id:" + userPendingorder.getId(); |
| | | siteTaskLog.setTaskTarget(tasktarget); |
| | | siteTaskLog.setAddTime(new Date()); |
| | |
| | | User user = (User) JsonUtil.string2Obj(userJson, User.class); |
| | | UserPendingorder userPendingorder = this.userPendingorderMapper.selectById(id); |
| | | if (userPendingorder == null) { |
| | | return ServerResponse.createByErrorMsg("The pending order does not exist"); |
| | | return ServerResponse.createByErrorMsg("The pending order does not exist",request); |
| | | } |
| | | if (user.getId().intValue() != userPendingorder.getUserId().intValue()) { |
| | | return ServerResponse.createByErrorMsg("The pending order does not belong to you"); |
| | | return ServerResponse.createByErrorMsg("The pending order does not belong to you",request); |
| | | } |
| | | int delCount = this.userPendingorderMapper.deleteById(id); |
| | | if (delCount > 0) { |
| | | return ServerResponse.createByErrorMsg("Successfully deleted"); |
| | | return ServerResponse.createByErrorMsg("Successfully deleted",request); |
| | | } |
| | | return ServerResponse.createByErrorMsg("Deletion failure"); |
| | | return ServerResponse.createByErrorMsg("Deletion failure",request); |
| | | } |
| | | |
| | | return ServerResponse.createByErrorMsg("Please log in"); |
| | | return ServerResponse.createByErrorMsg("Please log in",request); |
| | | } |
| | | |
| | | |