zj
2025-05-28 bcd36411feb0351347289476eb7ee9e5dd1c3b9d
src/main/java/project/project/web/admin/AdminContractOrderController.java
@@ -134,7 +134,8 @@
                  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(map.get("party_id").toString());
            double totleMoney = wallet.getMoney();
            profit = Arith.add(profit,totleMoney);
@@ -143,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();
@@ -305,22 +299,31 @@
            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);
            }
         }
      } catch (BusinessException e) {