1
zj
2024-07-20 09760b27383aea4d485fd3d9d5ea0491a88105b5
src/main/java/project/project/web/admin/AdminContractOrderController.java
@@ -1,6 +1,7 @@
package project.project.web.admin;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
@@ -109,6 +110,19 @@
               String roleName = map.get("rolename").toString();
               map.put("roleNameDesc", Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
            }
            double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
            // 计算仓位总价
            double positionValue = Double.parseDouble(map.get("deposit_open").toString()) * Double.parseDouble(map.get("lever_rate").toString());
            // 计算数量
            double quantity = positionValue / currentPrice;
            // 得到强平价格
            double liquidationPrice = currentPrice + (110 / quantity);
            DecimalFormat df = new DecimalFormat("#.#####");
            String formattedPrice = df.format(liquidationPrice);
            map.put("qiangPing",formattedPrice);
         }
         List<Item> items = this.itemService.cacheGetAll();
@@ -200,6 +214,19 @@
               String roleName = map.get("rolename").toString();
               map.put("roleNameDesc", Constants.ROLE_MAP.containsKey(roleName) ? Constants.ROLE_MAP.get(roleName) : roleName);
            }
            double currentPrice = Double.parseDouble(map.get("trade_avg_price").toString());
            // 计算仓位总价
            double positionValue = Double.parseDouble(map.get("deposit_open").toString()) * Double.parseDouble(map.get("lever_rate").toString());
            // 计算数量
            double quantity = positionValue / currentPrice;
            // 得到强平价格
            double liquidationPrice = currentPrice + (110 / quantity);
            DecimalFormat df = new DecimalFormat("#.#####");
            String formattedPrice = df.format(liquidationPrice);
            map.put("qiangPing",formattedPrice);
         }
      } catch (BusinessException e) {