From dc9bd22833255bc602dd42c7f603ecb50842ab35 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Mon, 23 Jun 2025 19:11:16 +0800
Subject: [PATCH] 1

---
 src/main/java/project/project/web/api/ContractApplyOrderController.java |   93 +++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 82 insertions(+), 11 deletions(-)

diff --git a/src/main/java/project/project/web/api/ContractApplyOrderController.java b/src/main/java/project/project/web/api/ContractApplyOrderController.java
index a58022f..9c42910 100644
--- a/src/main/java/project/project/web/api/ContractApplyOrderController.java
+++ b/src/main/java/project/project/web/api/ContractApplyOrderController.java
@@ -1,4 +1,4 @@
-package project.project.web.api;
+package project.web.api;
 
 import java.io.IOException;
 import java.math.BigDecimal;
@@ -11,6 +11,7 @@
 
 import javax.servlet.http.HttpServletRequest;
 
+import kernel.web.ApplicationUtil;
 import org.apache.commons.lang3.ObjectUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -94,8 +95,8 @@
 			data.put("amount", item.getUnit_amount());
 			data.put("fee", item.getUnit_fee());
 			
-//			List<ItemLever> list = this.itemService.findLever(item.getId().toString());
-//			data.put("lever", list);
+			List<ItemLever> list = this.itemService.findLever(item.getId().toString());
+			data.put("lever", list);
 			
 			String partyId = this.getLoginPartyId();
 			if (!StringUtils.isNullOrEmpty(partyId)) {
@@ -222,6 +223,7 @@
 		String stop_price_loss = request.getParameter("stop_price_loss");
 		String price_type = request.getParameter("price_type");
 
+
 		ResultObject resultObject = new ResultObject();
 		resultObject = this.readSecurityContextFromSession(resultObject);
 		if (!"0".equals(resultObject.getCode())) {
@@ -244,13 +246,13 @@
 				throw new BusinessException("请稍后再试");
 			}
 			List<Map<String, Object>> list = this.contractOrderService.findSubmittedRedis(partyId, symbol);
-			if(ObjectUtils.isNotEmpty(list)) {
-				for(Map<String, Object> map :list) {
-					if(!direction.equals(map.get("direction"))) {
-						throw new BusinessException("同一币种不允许多空双开");
-					}
-				}
-			}
+//			if(ObjectUtils.isNotEmpty(list)) {
+//				for(Map<String, Object> map :list) {
+//					if(!direction.equals(map.get("direction"))) {
+//						throw new BusinessException("同一币种不允许多空双开");
+//					}
+//				}
+//			}
 			if (StringUtils.isNullOrEmpty(lever_rate)) {
 				lever_rate = "1";
 			}
@@ -267,6 +269,8 @@
 			}
 			
 			double amount_double = Double.valueOf(request.getParameter("amount")).doubleValue();
+			//只有航天这一套需要这样子,部署其他的时候吧这个注释
+//			double amount_double = Double.valueOf(amount) / Double.valueOf(lever_rate);
 			double lever_rate_double = Double.valueOf(lever_rate).doubleValue();
 			double price_double = Double.valueOf(request.getParameter("price")).doubleValue();
 			double stop_price_profit_double = Double.valueOf(stop_price_profit).doubleValue();
@@ -287,7 +291,8 @@
 //			if (amount_double > contract_open_limit_max) {
 //				throw new BusinessException("开仓金额不得大于开仓最大限额");
 //			}
-
+			int amountInt = (int) amount_double;
+			amount_double = amountInt;
 			ContractApplyOrder order = new ContractApplyOrder();
 			order.setPartyId(partyId);
 			order.setSymbol(symbol);
@@ -323,6 +328,72 @@
 	}
 
 	/**
+	 * 修改止盈止损
+	 */
+	@RequestMapping(action + "stopProfitAndLoss.action")
+	public Object stopProfitAndLoss(HttpServletRequest request) throws IOException {
+		String session_token = request.getParameter("session_token");
+		String order_no = request.getParameter("order_no");
+		String stop_price_profit = request.getParameter("stop_price_profit");
+		String stop_price_loss = request.getParameter("stop_price_loss");
+
+		ResultObject resultObject = new ResultObject();
+		resultObject = this.readSecurityContextFromSession(resultObject);
+		if (!"0".equals(resultObject.getCode())) {
+			return resultObject;
+		}
+		String partyId = this.getLoginPartyId();
+		boolean lock = false;
+
+		try {
+
+			if (!ContractLock.add(partyId)) {
+				throw new BusinessException("请稍后再试");
+			}
+
+			lock = true;
+
+			ContractOrder order = contractOrderService.findByOrderNo(order_no);
+			if (order == null || !"submitted".equals(order.getState()) || !partyId.equals(order.getPartyId().toString())) {
+				return resultObject;
+			}
+
+			if (StringUtils.isNullOrEmpty(stop_price_profit)) {
+				stop_price_profit = "0";
+			}
+			if (StringUtils.isNullOrEmpty(stop_price_loss)) {
+				stop_price_loss = "0";
+			}
+
+			double stop_price_profit_double = Double.valueOf(stop_price_profit).doubleValue();
+			double stop_price_loss_double = Double.valueOf(stop_price_loss).doubleValue();
+
+			Party party = this.partyService.cachePartyBy(partyId, false);
+			if (!party.getEnabled()) {
+				resultObject.setCode("506");
+				resultObject.setMsg("用户已锁定");
+				return resultObject;
+			}
+
+			order.setStop_price_profit(stop_price_profit_double);
+			order.setStop_price_loss(stop_price_loss_double);
+
+			this.contractOrderService.update(order);
+
+		} catch (Exception e) {
+			resultObject.setCode("1");
+			resultObject.setMsg(e.getMessage());
+		} finally {
+			if (lock) {
+				ThreadUtils.sleep(100);
+				ContractLock.remove(partyId);
+			}
+		}
+
+		return resultObject;
+	}
+
+	/**
 	 * 平仓
 	 * 
 	 * symbol 币种

--
Gitblit v1.9.3