From bcd36411feb0351347289476eb7ee9e5dd1c3b9d Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Wed, 28 May 2025 02:18:06 +0800
Subject: [PATCH] 修改充值地址

---
 src/main/java/project/project/web/api/ContractOrderController.java |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/main/java/project/project/web/api/ContractOrderController.java b/src/main/java/project/project/web/api/ContractOrderController.java
index 029f37b..cc86b9b 100644
--- a/src/main/java/project/project/web/api/ContractOrderController.java
+++ b/src/main/java/project/project/web/api/ContractOrderController.java
@@ -216,25 +216,29 @@
 				if (map.get("direction") != null) {
 					String direction = map.get("direction").toString();
 					double liquidationPrice;
-					double deposit = depositOpen + profit;
+					double deposit =  profit;
+
 					if(leverRate == 1){
 						liquidationPrice = 0;
 					}else {
 						if ("sell".equals(direction)) {
-							liquidationPrice = tradeAvgPrice + (deposit / div);
+							double lossPercentage = deposit / Double.parseDouble(map.get("amount").toString());
+							double priceIncrease = lossPercentage * tradeAvgPrice;
+							liquidationPrice = tradeAvgPrice + priceIncrease;
 						} else {
-							liquidationPrice = (mul * tradeAvgPrice) / (deposit + mul);
+							double lossPercentage = deposit / Double.parseDouble(map.get("amount").toString());
+							double priceDrop = lossPercentage * tradeAvgPrice;
+							liquidationPrice = tradeAvgPrice - priceDrop;
 						}
 					}
-
 					DecimalFormat dfs = new DecimalFormat("#.#####");
 					String formattedPrice = dfs.format(liquidationPrice);
+					// 检查是否为负数
+					if (Double.parseDouble(formattedPrice) < 0) {
+						formattedPrice = "0";
+					}
 					map.put("qiangPing", formattedPrice);
 				}
-
-
-
-
 				// 标记价格
 				Realtime realtime = realtimeMap.get(map.get("symbol"));
 				if (null == realtime) {

--
Gitblit v1.9.3