From 5ce072de78ae263b52dc0e2be5c7391b23c093cf Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Sun, 27 Apr 2025 18:29:22 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/controller/protol/UserController.java | 92 ++++++++++++++++++++++++++++++---------------
1 files changed, 61 insertions(+), 31 deletions(-)
diff --git a/src/main/java/com/nq/controller/protol/UserController.java b/src/main/java/com/nq/controller/protol/UserController.java
index 31cf362..dec81eb 100644
--- a/src/main/java/com/nq/controller/protol/UserController.java
+++ b/src/main/java/com/nq/controller/protol/UserController.java
@@ -1,16 +1,19 @@
package com.nq.controller.protol;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.google.common.collect.Maps;
import com.nq.common.ServerResponse;
+import com.nq.dao.StockConfigMapper;
import com.nq.enums.EStockType;
-import com.nq.pojo.ApplyLever;
-import com.nq.pojo.StockSubscribe;
-import com.nq.pojo.UserStockSubscribe;
+import com.nq.pojo.*;
import com.nq.service.*;
import com.nq.utils.PropertiesUtil;
import java.math.BigDecimal;
+import java.util.Collections;
+import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@@ -66,6 +69,9 @@
@Autowired
IApplyLeverServices iApplyLeverServices;
+
+ @Autowired
+ StockConfigMapper stockConfigMapper;
private static final ThreadLocal<Boolean> orderCreated = ThreadLocal.withInitial(() -> false);
private final Lock lock = new ReentrantLock();
@@ -147,7 +153,7 @@
return ServerResponse.createByErrorMsg("当前下单人数过多,请稍后重试", request);
}
buyOrderCreated.set(true);
- return this.iUserPositionService.goldCrudeOilbuy(name, buyNum,lever,profitTarget,stopLoss, request);
+ return this.iUserPositionService.goldCrudeOilbuy(name, buyNum,buyType,lever,profitTarget,stopLoss, request);
} catch (Exception e) {
e.printStackTrace();
return ServerResponse.createByErrorMsg("订单异常,请稍后重试", request);
@@ -188,54 +194,70 @@
}
}
-
-
-
-
//挂单操作-添加
@RequestMapping({"addOrder.do"})
@ResponseBody
- public ServerResponse addOrder(HttpServletRequest request,
- @RequestParam("stockId") String stockId,
+ public ServerResponse addOrder(@RequestParam("stockId") Integer stockId,
@RequestParam("buyNum") Integer buyNum,
@RequestParam("buyType") Integer buyType,
@RequestParam("lever") Integer lever,
- @RequestParam(value = "profitTarget",required = false) BigDecimal profitTarget,
- @RequestParam(value = "stopTarget",required = false) BigDecimal stopTarget,
- @RequestParam(value = "targetPrice",required = false) BigDecimal targetPrice) {
+ @RequestParam("targetPrice") String targetPrice,
+ @RequestParam(value = "profitTarget",required = false)
+ BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) {
ServerResponse serverResponse = null;
try {
- serverResponse = this.userPendingorderService.addOrder(stockId, buyNum, buyType, lever,profitTarget,stopTarget,targetPrice, request);
+ serverResponse = this.userPendingorderService.addOrder(stockId, buyNum, buyType, lever,profitTarget,stopLoss,targetPrice, request);
} catch (Exception e) {
log.error("挂单操作-添加 = {}", e);
}
return serverResponse;
}
- //挂单操作-列表
- @RequestMapping({"orderList.do"})
+
+ //挂单操作-添加
+ @RequestMapping({"hjyyAddOrder.do"})
@ResponseBody
- public ServerResponse orderList(HttpServletRequest request) {
+ public ServerResponse hjyyAddOrder(@RequestParam("name") String name,
+ @RequestParam("buyNum") Integer buyNum,
+ @RequestParam("buyType") Integer buyType,
+ @RequestParam("lever") Integer lever,
+ @RequestParam("targetPrice") String targetPrice,
+ @RequestParam(value = "profitTarget",required = false)
+ BigDecimal profitTarget,@RequestParam(value = "stopLoss",required = false) BigDecimal stopLoss, HttpServletRequest request) {
ServerResponse serverResponse = null;
try {
+ serverResponse = this.userPendingorderService.hjyyAddOrder(name, buyNum, buyType, lever,profitTarget,stopLoss,targetPrice, request);
+ } catch (Exception e) {
+ log.error("挂单操作-添加 = {}", e);
+ }
+ return serverResponse;
+ }
- serverResponse = this.userPendingorderService.orderList(request);
+ //挂单操作-撤销
+ @RequestMapping({"revocation.do"})
+ @ResponseBody
+ public ServerResponse revocation(@RequestParam("id") Integer id, HttpServletRequest request) {
+ try {
+ synchronized (id){
+ User user = this.iUserService.getCurrentRefreshUser(request);
+ if(ObjectUtil.isEmpty(user)){
+ return ServerResponse.createByErrorMsg("请重新登录,未找到用户!",request);
+ }
+ UserPendingorder userPendingorder = userPendingorderService.getOne(new LambdaQueryWrapper<>(UserPendingorder.class)
+ .eq(UserPendingorder::getUserId, user.getId())
+ .eq(UserPendingorder::getId, id)
+ );
+ if(ObjectUtil.isNotEmpty(userPendingorder)){
+ userPendingorder.setPositionType(2);
+ }
+ userPendingorderService.updateById(userPendingorder);
+ return ServerResponse.createBySuccess("撤销挂单成功",request);
+ }
} catch (Exception e) {
log.error("挂单操作-列表 = {}", e);
}
- return serverResponse;
+ return ServerResponse.createByErrorMsg("撤销挂单失败!",request);
}
- //挂单操作-删除
- @RequestMapping({"delOrder.do"})
- @ResponseBody
- public ServerResponse delOrder(HttpServletRequest request, @RequestParam("id") Integer id) {
- ServerResponse serverResponse = null;
- try {
- serverResponse = this.userPendingorderService.delOrder(id, request);
- } catch (Exception e) {
- log.error("挂单操作-删除 = {}", e);
- }
- return serverResponse;
- }
+
//用户追加保证金操作
@RequestMapping({"addmargin.do"})
@@ -374,6 +396,14 @@
}
+ @RequestMapping("usdtExchangeRate.do")
+ @ResponseBody
+ public ServerResponse usdtExchangeRate(HttpServletRequest request
+ ){
+ StockConfig stockConfig = stockConfigMapper.selectOne(new LambdaQueryWrapper<StockConfig>().eq(StockConfig::getCKey, "usdt_parities"));
+ return ServerResponse.createBySuccess(stockConfig.getCValue());
+ }
+
/**
* vip抢筹 (涨停板买入)
*
--
Gitblit v1.9.3