| | |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import kernel.web.ApplicationUtil; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 修改止盈止损 |
| | | */ |
| | | @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 币种 |