| | |
| | | import com.yami.trading.common.util.ThreadUtils; |
| | | import com.yami.trading.security.common.util.SecurityUtils; |
| | | import com.yami.trading.service.MarketOpenChecker; |
| | | import com.yami.trading.service.RealNameAuthRecordService; |
| | | import com.yami.trading.service.SessionTokenService; |
| | | import com.yami.trading.service.WalletService; |
| | | import com.yami.trading.service.contract.ContractApplyOrderService; |
| | |
| | | private SessionTokenService sessionTokenService; |
| | | @Autowired |
| | | TipService tipService; |
| | | @Autowired |
| | | private RealNameAuthRecordService realNameAuthRecordService; |
| | | // @Autowired |
| | | // private ExchangeRateService exchangeRateService; |
| | | |
| | |
| | | RLock rLock = null; |
| | | boolean lockResult = false; |
| | | try { |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | | String partyId = SecurityUtils.getCurrentUserId(); |
| | | rLock = redissonClient.getLock("contract_open_" + partyId); |
| | | |
| | | lockResult = rLock.tryLock(5, TimeUnit.SECONDS); |
| | |
| | | if (!user.isEnabled()) { |
| | | throw new YamiShopBindException("用户已锁定"); |
| | | } |
| | | validateTradePermission(user); |
| | | realNameAuthRecordService.requireApproved(user, true); |
| | | |
| | | Syspara syspara = sysparaService.find("stop_user_internet"); |
| | | String stopUserInternet = syspara.getSvalue(); |
| | | if(org.apache.commons.lang3.StringUtils.isNotEmpty(stopUserInternet)) { |
| | | String[] stopUsers = stopUserInternet.split(","); |
| | | |
| | | System.out.println("userName = " + user.getUserName()); |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(user.getUserName())){ |
| | | throw new YamiShopBindException("无网络"); |
| | |
| | | if (!user.isEnabled()) { |
| | | throw new YamiShopBindException("用户已锁定"); |
| | | } |
| | | validateTradePermission(user); |
| | | |
| | | Syspara syspara = sysparaService.find("stop_user_internet"); |
| | | String stopUserInternet = syspara.getSvalue(); |
| | | if(org.apache.commons.lang3.StringUtils.isNotEmpty(stopUserInternet)) { |
| | | String[] stopUsers = stopUserInternet.split(","); |
| | | |
| | | System.out.println("userName = " + user.getUserName()); |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(user.getUserName())){ |
| | | throw new YamiShopBindException("无网络"); |
| | |
| | | order.setPartyId(partyId); |
| | | order.setSymbol(closeAction.getSymbol()); |
| | | order.setDirection(closeAction.getDirection()); |
| | | order.setOffset(ContractApplyOrder.OFFSET_OPEN); |
| | | order.setOffset(ContractApplyOrder.OFFSET_CLOSE); |
| | | order.setVolume(closeAction.getAmount()); |
| | | order.setVolumeOpen(closeAction.getAmount()); |
| | | order.setPrice(closeAction.getPrice()); |
| | |
| | | map.put("amount", order.getVolume().multiply(order.getUnitAmount()).setScale(4, RoundingMode.FLOOR)); |
| | | map.put("amount_open", order.getVolumeOpen().multiply(order.getUnitAmount())); |
| | | map.put("fee", order.getFee()); |
| | | map.put("funding_fee", order.getFundingFee()); |
| | | map.put("deposit", order.getDeposit()); |
| | | return Result.succeed(map); |
| | | } |
| | |
| | | dateN.put("count", count); |
| | | return Result.ok(dateN); |
| | | } |
| | | |
| | | private void validateTradePermission(User user) { |
| | | if (user == null) { |
| | | throw new YamiShopBindException("用户不存在"); |
| | | } |
| | | // 模拟账户不做二步校验限制 |
| | | if (user.getAccountType() != null && user.getAccountType() == 1) { |
| | | return; |
| | | } |
| | | } |
| | | } |