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/admin/AdminContractOrderController.java | 75 +++++++++++++++++--------------------
1 files changed, 35 insertions(+), 40 deletions(-)
diff --git a/src/main/java/project/project/web/admin/AdminContractOrderController.java b/src/main/java/project/project/web/admin/AdminContractOrderController.java
index 58c4475..816eac1 100644
--- a/src/main/java/project/project/web/admin/AdminContractOrderController.java
+++ b/src/main/java/project/project/web/admin/AdminContractOrderController.java
@@ -1,4 +1,4 @@
-package project.project.web.admin;
+package project.web.admin;
import java.math.BigDecimal;
import java.text.DecimalFormat;
@@ -11,6 +11,7 @@
import javax.servlet.http.HttpServletRequest;
+import db.util.QpUtil;
import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -126,15 +127,16 @@
* 计算全仓收益 保证金
*/
double profit = 0;
- List<ContractOrder> contractOrders = contractOrderService.findSubmitted(this.getLoginPartyId(), null, null);
+ List<ContractOrder> contractOrders = contractOrderService.findSubmitted(map.get("party_id").toString(), null, null);
for (int f = 0; f < contractOrders.size(); f++) {
ContractOrder close_line = contractOrders.get(f);
if(close_line.getProfit() > 0){
profit = Arith.add(profit, Arith.add(close_line.getProfit(), close_line.getDeposit()));
}else{
profit = Arith.add(profit, close_line.getDeposit());
- } }
- Wallet wallet = this.walletService.saveWalletByPartyId(this.getLoginPartyId());
+ }
+ }
+ Wallet wallet = this.walletService.saveWalletByPartyId(map.get("party_id").toString());
double totleMoney = wallet.getMoney();
profit = Arith.add(profit,totleMoney);
@@ -142,36 +144,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 / (Arith.mul(Double.parseDouble(map.get("volume").toString()), Double.parseDouble(map.get("unit_amount").toString())));
+ double priceIncrease = lossPercentage * tradeAvgPrice;
+ liquidationPrice = tradeAvgPrice + priceIncrease;
} else {
- liquidationPrice = (mul * tradeAvgPrice) / (deposit + mul);
+ double lossPercentage = deposit / (Arith.mul(Double.parseDouble(map.get("volume").toString()), Double.parseDouble(map.get("unit_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);
}
-
-// double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
-//
-// double leve = Double.parseDouble(map.get("lever_rate").toString());
-// //得到强平价格
-// if(null != map.get("direction")){
-// double liquidationPrice;
-// if(map.get("direction").equals("sell")){
-// liquidationPrice = currentPrice * (1 + (1 / leve));
-// }else{
-// liquidationPrice = currentPrice * (1 - 1 / leve);
-// }
-// DecimalFormat df = new DecimalFormat("#.#####");
-// String formattedPrice = df.format(liquidationPrice);
-// map.put("qiangPing",formattedPrice);
-// }
}
List<Item> items = this.itemService.cacheGetAll();
@@ -289,38 +284,45 @@
* 计算全仓收益 保证金
*/
double profit = 0;
- List<ContractOrder> contractOrders = contractOrderService.findSubmitted(this.getLoginPartyId(), null, null);
+ List<ContractOrder> contractOrders = contractOrderService.findSubmitted(map.get("party_id").toString(), null, null);
for (int f = 0; f < contractOrders.size(); f++) {
ContractOrder close_line = contractOrders.get(f);
if(close_line.getProfit() > 0){
profit = Arith.add(profit, Arith.add(close_line.getProfit(), close_line.getDeposit()));
}else{
profit = Arith.add(profit, close_line.getDeposit());
- }
- }
- Wallet wallet = this.walletService.saveWalletByPartyId(this.getLoginPartyId());
+ } }
+ Wallet wallet = this.walletService.saveWalletByPartyId(map.get("party_id").toString());
double totleMoney = wallet.getMoney();
profit = Arith.add(profit,totleMoney);
-
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 / (Arith.mul(Double.parseDouble(map.get("volume").toString()), Double.parseDouble(map.get("unit_amount").toString())));
+ double priceIncrease = lossPercentage * tradeAvgPrice;
+ liquidationPrice = tradeAvgPrice + priceIncrease;
} else {
- liquidationPrice = (mul * tradeAvgPrice) / (deposit + mul);
+ double lossPercentage = deposit / (Arith.mul(Double.parseDouble(map.get("volume").toString()), Double.parseDouble(map.get("unit_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);
}
+
}
@@ -357,10 +359,7 @@
try {
- if (!StringUtils.isNullOrEmpty(this.getLoginPartyId())) {
- throw new BusinessException("无权限");
- }
-
+
Realtime realtime = this.dataService.realtime(symbol).get(0);
Item item = this.itemService.cacheBySymbol(symbol, false);
@@ -410,10 +409,6 @@
try {
- if (!StringUtils.isNullOrEmpty(this.getLoginPartyId())) {
- throw new BusinessException("无权限");
- }
-
String error = this.verif(type, value);
if (!StringUtils.isNullOrEmpty(error)) {
throw new BusinessException(error);
--
Gitblit v1.9.3