From 579177ac64462d0fec885eb10af3097245134f80 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Tue, 02 Jun 2026 10:28:11 +0800
Subject: [PATCH] 1
---
trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiFuturesOrderController.java | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiFuturesOrderController.java b/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiFuturesOrderController.java
index f71f1d5..c3d6d61 100644
--- a/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiFuturesOrderController.java
+++ b/trading-order-admin/src/main/java/com/yami/trading/api/controller/ApiFuturesOrderController.java
@@ -2,6 +2,7 @@
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yami.trading.api.dto.FutureOpenAction;
@@ -9,6 +10,7 @@
import com.yami.trading.bean.future.domain.FuturesOrder;
import com.yami.trading.bean.future.domain.FuturesPara;
import com.yami.trading.bean.item.domain.Item;
+import com.yami.trading.bean.model.CapitaltWallet;
import com.yami.trading.bean.model.User;
import com.yami.trading.bean.model.Wallet;
import com.yami.trading.common.domain.Result;
@@ -19,6 +21,7 @@
import com.yami.trading.common.util.ThreadUtils;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.common.util.*;
+import com.yami.trading.service.CapitaltWalletService;
import com.yami.trading.service.SessionTokenService;
import com.yami.trading.service.WalletService;
import com.yami.trading.service.future.FuturesOrderService;
@@ -57,6 +60,8 @@
private FuturesOrderService futuresOrderService;
@Autowired
private FuturesParaService futuresParaService;
+ @Autowired
+ CapitaltWalletService capitaltWalletService;
/**
* 开仓页面参数
* <p>
@@ -70,7 +75,7 @@
Map<String, Object> data = new HashMap<>();
Item bySymbol = itemService.findBySymbol(symbol);
if(bySymbol == null){
- throw new YamiShopBindException("当前币对不存在");
+ throw new YamiShopBindException("Trading pair does not exist");
}
List<Map<String,Object>> futuresParas = new ArrayList<>();
for (FuturesPara para : this.futuresParaService.getBySymbolSort(symbol)) {
@@ -106,12 +111,17 @@
String partyId = SecurityUtils.getCurrentUserId();
if (StrUtil.isNotBlank(partyId) && futuresParas != null) {
Wallet wallet = this.walletService.findByUserId(partyId);
+ // 获取资金账户(capital)
+ CapitaltWallet capitaltWallet = capitaltWalletService.getOne(new LambdaQueryWrapper<>(CapitaltWallet.class)
+ .eq(CapitaltWallet::getUserId, partyId).last(" limit 1 "));
// 账户剩余资金
String session_token = this.sessionTokenService.savePut(partyId);
data.put("session_token", session_token);
data.put("amount", wallet.getMoney().longValue());
+ data.put("capitaltAmount", capitaltWallet.getMoney().longValue());
} else {
data.put("amount", 0);
+ data.put("capitaltAmount", 0);
}
data.put("open", MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType()));
return Result.succeed(data);
@@ -132,19 +142,19 @@
public Result<Map<String, String>> open(FutureOpenAction futureOpenAction) {
Item bySymbol = itemService.findBySymbol(futureOpenAction.getSymbol());
if(bySymbol == null){
- throw new YamiShopBindException("当前币对不存在");
+ throw new YamiShopBindException("Trading pair does not exist");
}
if (!itemService.isContractTrading(bySymbol)) {
- throw new YamiShopBindException("未开放合约交易");
+ throw new YamiShopBindException("Contract trading is not available");
}
- if (itemService.isSuspended(bySymbol.getSymbol())) {
- throw new YamiShopBindException("停牌禁止交易");
- }
+ /*if (itemService.isSuspended(bySymbol.getSymbol())) {
+ throw new YamiShopBindException("Trading suspended for this symbol");
+ }*/
boolean isOpen = MarketOpenChecker.isMarketOpenByItemCloseType(bySymbol.getOpenCloseType());
if(!isOpen){
- throw new YamiShopBindException("当前已经休市");
+ throw new YamiShopBindException("Market is closed");
}
String partyId = SecurityUtils.getUser().getUserId();
boolean lock = false;
@@ -153,7 +163,7 @@
Map<String, String> data = new HashMap<String, String>();
if (!FuturesLock.add(partyId)) {
- throw new YamiShopBindException("请稍后再试");
+ throw new YamiShopBindException("Please try again later");
}
lock = true;
@@ -165,7 +175,7 @@
throw new YamiShopBindException("User is locked");
}
if (null == object || !party.getUserId().equals((String) object)) {
- throw new BusinessException("请稍后再试");
+ throw new BusinessException("Please try again later");
}
FuturesOrder order = new FuturesOrder();
@@ -230,7 +240,7 @@
FuturesOrder order = this.futuresOrderService.cacheByOrderNo(order_no);
if (null == order) {
log.info("futuresOrder!get order_no:" + order_no + ", order null");
- throw new YamiShopBindException("订单不存在");
+ throw new YamiShopBindException("Order does not exist");
}
return Result.succeed(this.futuresOrderService.bulidOne(order));
}
--
Gitblit v1.9.3