| | |
| | | public Result buyDz(String dzId, String password, double num, String partyId, Boolean isAdmin) { |
| | | try { |
| | | if (num <= 0) { |
| | | throw new YamiShopBindException("请输入"); |
| | | return Result.failed("请购买最小数量"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | return Result.failed("用户已禁用"); |
| | | } |
| | | Syspara syspara = sysparaService.find("stop_user_internet"); |
| | | /*Syspara syspara = sysparaService.find("stop_user_internet"); |
| | | String stopUserInternet = syspara.getSvalue(); |
| | | if (org.apache.commons.lang3.StringUtils.isNotEmpty(stopUserInternet)) { |
| | | String[] stopUsers = stopUserInternet.split(","); |
| | | if (Arrays.asList(stopUsers).contains(party.getUserName())) { |
| | | throw new YamiShopBindException("无网络"); |
| | | } |
| | | } |
| | | }*/ |
| | | |
| | | StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("uuid", dzId)); |
| | | if (stockDz == null) { |
| | | throw new YamiShopBindException("大宗不存在"); |
| | | return Result.failed("大宗数据错误"); |
| | | } |
| | | if (StringUtils.isNotEmpty(stockDz.getPassword()) && !Objects.equals(stockDz.getPassword(), password)) { |
| | | throw new YamiShopBindException("密码错误"); |
| | | return Result.failed("密码错误"); |
| | | } |
| | | if (stockDz.getIsLock() != null && stockDz.getIsLock() != 0) { |
| | | throw new YamiShopBindException("股票被锁定,不能购买"); |
| | | return Result.failed("股票被锁定"); |
| | | } |
| | | |
| | | if(stockDz.getStartTime().getTime() > new Date().getTime() || stockDz.getEndTime().getTime() < new Date().getTime()){ |
| | |
| | | BigDecimal nowPrice = stockDz.getNowPrice(); |
| | | |
| | | if (nowPrice.compareTo(new BigDecimal("0")) == 0) { |
| | | throw new YamiShopBindException("股票价格0,请重试"); |
| | | return Result.failed("大宗数据错误"); |
| | | } |
| | | boolean isETF = stockDz.getStockType().equalsIgnoreCase(Item.indices); |
| | | if (isETF) { |
| | |
| | | if(stockDz.getSwitchType() == 1) { |
| | | order.setState(ExchangeApplyOrderDz.STATE_SUBMITTED); |
| | | exchangeApplyOrderDzMapper.insert(order); |
| | | return Result.succeed("购买成功,等待审核"); |
| | | return Result.succeed("购买成功"); |
| | | } |
| | | |
| | | order.setState(ExchangeApplyOrderDz.STATE_POSITION); |
| | |
| | | try { |
| | | ExchangeApplyOrderDz order = exchangeApplyOrderDzMapper.selectById(id); |
| | | if (order == null) { |
| | | throw new YamiShopBindException("订单不存在"); |
| | | return Result.failed("失败"); |
| | | } |
| | | if (!order.getState().equals(ExchangeApplyOrderDz.STATE_POSITION)) { |
| | | throw new YamiShopBindException("订单不能平仓"); |
| | | return Result.failed("订单不能平仓"); |
| | | } |
| | | if (num == null) { //不传默认平全部 |
| | | num = order.getSymbolValue(); |
| | | } |
| | | if (num < 0 || num > order.getSymbolValue()) { |
| | | throw new YamiShopBindException("数量错误"); |
| | | return Result.failed("数量错误"); |
| | | } |
| | | if (partyId == null) { |
| | | partyId = order.getPartyId(); |
| | |
| | | |
| | | StockDz stockDz = this.stockDzMapper.selectOne(new QueryWrapper<StockDz>().eq("uuid", order.getDzId())); |
| | | if (stockDz == null) { |
| | | throw new YamiShopBindException("大宗不存在"); |
| | | return Result.failed("大宗数据错误"); |
| | | } |
| | | |
| | | BigDecimal nowPrice; |
| | |
| | | nowPrice = stockDz.getNowPrice(); |
| | | } |
| | | if (nowPrice.compareTo(new BigDecimal("0")) == 0) { |
| | | throw new YamiShopBindException("股票价格0,请重试"); |
| | | return Result.failed("大宗数据错误"); |
| | | } |
| | | |
| | | |