From 640ccb9229224642515527daf87f308a7aa9bdf4 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 10 Jun 2026 11:47:26 +0800
Subject: [PATCH] 1
---
trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiExchangeApplyOrderController.java | 67 ++++++++++++++++++++-------------
1 files changed, 40 insertions(+), 27 deletions(-)
diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiExchangeApplyOrderController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiExchangeApplyOrderController.java
index 56a58b9..b19b898 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiExchangeApplyOrderController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/exchange/ApiExchangeApplyOrderController.java
@@ -150,16 +150,29 @@
.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());
@@ -176,13 +189,13 @@
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();
@@ -191,11 +204,11 @@
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();
@@ -289,7 +302,7 @@
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除以的数量
@@ -310,7 +323,7 @@
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数量
@@ -332,7 +345,7 @@
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);
@@ -341,7 +354,7 @@
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;
@@ -369,7 +382,7 @@
if (realtimes != null && realtimes.size() > 0) {
close = realtimes.get(0).getClose().doubleValue();
} else {
- throw new YamiShopBindException("参数错误");
+ throw new YamiShopBindException("Invalid parameters");
}
return close;
}
@@ -396,13 +409,13 @@
// 兑换后的币种
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);
@@ -529,16 +542,16 @@
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();
@@ -552,7 +565,7 @@
System.out.println("stopUserInternet = " + stopUserInternet);
if(Arrays.asList(stopUsers).contains(userName.trim())){
- throw new YamiShopBindException("无网络");
+ throw new YamiShopBindException("No network connection");
}
}
@@ -560,7 +573,7 @@
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);
@@ -568,7 +581,7 @@
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);
@@ -619,24 +632,24 @@
//
// 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");
@@ -648,7 +661,7 @@
System.out.println("stopUserInternet = " + stopUserInternet);
if(Arrays.asList(stopUsers).contains(party.getUserName())){
- throw new YamiShopBindException("无网络");
+ throw new YamiShopBindException("No network connection");
}
}
@@ -657,7 +670,7 @@
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);
--
Gitblit v1.9.3