| | |
| | | .eq(PurchaseRecord::getUserId, user.getUserId())); |
| | | if(ObjectUtil.isNotEmpty(purchaseRecord)){ |
| | | PurchaseRecordDto purchaseRecordDto = ConverterUtil.convert(purchaseRecord, PurchaseRecordDto.class); |
| | | Item item = itemService.getOne(new LambdaQueryWrapper<Item>().eq(Item::getName, "CLK/USDT")); |
| | | if (item != null) { |
| | | WalletExtend walletExtend = walletExtendService.getOne(new LambdaQueryWrapper<>(WalletExtend.class) |
| | | .eq(WalletExtend::getWallettype, item.getSymbol()) |
| | | .eq(WalletExtend::getPartyId, user.getUserId()) |
| | | .last(" limit 1")); |
| | | if (walletExtend != null) { |
| | | purchaseRecordDto.setPurchaseQuantity(BigDecimal.valueOf(walletExtend.getAmount()).setScale(4,RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | |
| | | purchaseRecordDto.setCurrentPrice(close); |
| | | //持仓市值 |
| | | purchaseRecordDto.setPositionvalue(close.multiply(purchaseRecordDto.getPurchaseQuantity())); |
| | | purchaseRecordDto.setPositionvalue(close.multiply(purchaseRecordDto.getPurchaseQuantity()).setScale(4, RoundingMode.HALF_UP)); |
| | | //均价总额 |
| | | BigDecimal currentTotalPrice = purchaseRecordDto.getPurchaseQuantity().multiply(purchaseRecord.getPurchasePrice()); |
| | | BigDecimal profit = purchaseRecordDto.getPositionvalue().subtract(currentTotalPrice); |
| | | purchaseRecordDto.setProfit(profit.setScale(4, RoundingMode.HALF_UP)); |
| | | BigDecimal profitPercent = (purchaseRecordDto.getPositionvalue().subtract(currentTotalPrice)).divide(currentTotalPrice,4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | purchaseRecordDto.setProfitPercent(profitPercent); |
| | | purchaseRecordDto.setLockingTime(LocalDate.of(2026, 2, 9)); |
| | | if (currentTotalPrice.compareTo(BigDecimal.ZERO) != 0) { |
| | | BigDecimal profitPercent = (purchaseRecordDto.getPositionvalue().subtract(currentTotalPrice)).divide(currentTotalPrice,4,RoundingMode.HALF_UP).multiply(new BigDecimal("100")).setScale(2, RoundingMode.HALF_UP); |
| | | purchaseRecordDto.setProfitPercent(profitPercent); |
| | | } |
| | | purchaseRecordDto.setLockingTime(LocalDate.of(2026, 2, 4)); |
| | | return Result.succeed(purchaseRecordDto); |
| | | } |
| | | return Result.succeed(new PurchaseRecordDto()); |
| | |
| | | String volume_temp = request.getParameter("volume"); |
| | | if (StringUtils.isNullOrEmpty(volume_temp) |
| | | || !StringUtils.isDouble(volume_temp) || Double.valueOf(volume_temp) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid currency amount"); |
| | | } |
| | | double volume = Double.valueOf(volume_temp); |
| | | String symbol = request.getParameter("symbol"); |
| | | String symbol_to = request.getParameter("symbol_to"); |
| | | if (symbol.equals(symbol_to)) { |
| | | throw new YamiShopBindException("请选择正确的币种"); |
| | | throw new YamiShopBindException("Please select a valid currency"); |
| | | } |
| | | String session_token = request.getParameter("session_token"); |
| | | String partyId = SecurityUtils.getUser().getUserId(); |
| | |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | log.info("sessionToken{}", object); |
| | | System.out.println("sessionToken " + object); |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用!"); |
| | | throw new YamiShopBindException("User is disabled!"); |
| | | } |
| | | symbol = symbol.toLowerCase(); |
| | | symbol_to = symbol_to.toLowerCase(); |
| | |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | double symbol_to_price = realtime.getClose().doubleValue(); |
| | | // usdt除以的数量 |
| | |
| | | if (realtime_list.size() > 0) { |
| | | realtime = realtime_list.get(0); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | double symbol_price = realtime.getClose().doubleValue(); |
| | | // 对应usdt数量 |
| | |
| | | realtime = realtime_list.get(0); |
| | | symbol_price = realtime.getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | // 获取币种最新价格 |
| | | List<Realtime> realtime_list_to = this.dataService.realtime(symbol_to); |
| | |
| | | realtime_to = realtime_list_to.get(0); |
| | | symbol_to_price = realtime_to.getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("系统错误,请稍后重试"); |
| | | throw new YamiShopBindException("System error, please try again later"); |
| | | } |
| | | if (symbol_to_price == 0) { |
| | | symbol_to_price = 1; |
| | |
| | | if (realtimes != null && realtimes.size() > 0) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | return close; |
| | | } |
| | |
| | | // 兑换后的币种 |
| | | String symbol_to = request.getParameter("symbol_to"); |
| | | if (symbol.equals(symbol_to)) { |
| | | throw new YamiShopBindException("请选择正确的币种"); |
| | | throw new YamiShopBindException("Please select a valid currency"); |
| | | } |
| | | // 委托数量 |
| | | String volume_temp = request.getParameter("volume"); |
| | | if (StringUtils.isNullOrEmpty(volume_temp) |
| | | || !StringUtils.isDouble(volume_temp) || Double.valueOf(volume_temp) < 0) { |
| | | throw new YamiShopBindException("请输入正确的兑换数量"); |
| | | throw new YamiShopBindException("Please enter a valid exchange amount"); |
| | | } |
| | | Map<String, Object> parities = parities(symbol, symbol_to, volume_temp); |
| | | return Result.succeed(parities); |
| | |
| | | if (StringUtils.isNullOrEmpty(volume) |
| | | || !StringUtils.isDouble(volume) |
| | | || Double.valueOf(volume) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid currency amount"); |
| | | } |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用"); |
| | | throw new YamiShopBindException("User is disabled"); |
| | | } |
| | | |
| | | String userName = party.getUserName(); |
| | |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(userName.trim())){ |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("No network connection"); |
| | | } |
| | | } |
| | | |
| | |
| | | RealNameAuthRecord party_kyc = realNameAuthRecordService.getByUserId(partyId); |
| | | if (party_kyc != null) { |
| | | if (!(party_kyc.getStatus() == 2) && "true".equals(sysparaService.find("exchange_by_kyc").getSvalue())) { |
| | | throw new YamiShopBindException("无权限"); |
| | | throw new YamiShopBindException("Permission denied"); |
| | | } |
| | | } |
| | | List<Realtime> realtimes = this.dataService.realtime(symbol); |
| | |
| | | if (realtimes != null) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | ExchangeApplyOrder order = new ExchangeApplyOrder(); |
| | | order.setPartyId(partyId); |
| | |
| | | |
| | | // |
| | | // if(symbol.equals("pendleusdt") && !isAfterFebruary9th2026()){ |
| | | // throw new YamiShopBindException("此币还没有发行时间"); |
| | | // throw new YamiShopBindException("This coin has no issue time yet"); |
| | | // } |
| | | |
| | | |
| | | if (StringUtils.isNullOrEmpty(volume) |
| | | || !StringUtils.isDouble(volume) |
| | | || Double.valueOf(volume) <= 0) { |
| | | throw new YamiShopBindException("请输入正确的货币数量"); |
| | | throw new YamiShopBindException("Please enter a valid currency amount"); |
| | | } |
| | | lock = true; |
| | | Object object = this.sessionTokenService.cacheGet(session_token); |
| | | this.sessionTokenService.del(session_token); |
| | | if ((object == null) || (!partyId.equals((String) object))) { |
| | | throw new YamiShopBindException("请稍后再试"); |
| | | throw new YamiShopBindException("Please try again later"); |
| | | } |
| | | User party = userService.getById(partyId); |
| | | if (!party.isEnabled()) { |
| | | throw new YamiShopBindException("用户已禁用"); |
| | | throw new YamiShopBindException("User is disabled"); |
| | | } |
| | | |
| | | Syspara syspara = sysparaService.find("stop_user_internet"); |
| | |
| | | System.out.println("stopUserInternet = " + stopUserInternet); |
| | | |
| | | if(Arrays.asList(stopUsers).contains(party.getUserName())){ |
| | | throw new YamiShopBindException("无网络"); |
| | | throw new YamiShopBindException("No network connection"); |
| | | } |
| | | } |
| | | |
| | |
| | | if (realtimes != null) { |
| | | close = realtimes.get(0).getClose().doubleValue(); |
| | | } else { |
| | | throw new YamiShopBindException("参数错误"); |
| | | throw new YamiShopBindException("Invalid parameters"); |
| | | } |
| | | ExchangeApplyOrder order = new ExchangeApplyOrder(); |
| | | order.setPartyId(partyId); |