From 1dbbc51dace6b79ffb3b965656b76ff98a265c29 Mon Sep 17 00:00:00 2001
From: zj <1772600164@qq.com>
Date: Thu, 12 Feb 2026 17:19:20 +0800
Subject: [PATCH] 1
---
src/main/java/com/nq/controller/protol/UserWithdrawController.java | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 56 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/nq/controller/protol/UserWithdrawController.java b/src/main/java/com/nq/controller/protol/UserWithdrawController.java
index d979ebc..172586e 100644
--- a/src/main/java/com/nq/controller/protol/UserWithdrawController.java
+++ b/src/main/java/com/nq/controller/protol/UserWithdrawController.java
@@ -15,6 +15,9 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
@Controller
@RequestMapping({"/user/withdraw/"})
@@ -34,21 +37,71 @@
return this.iUserWithdrawService.findUserWithList(withStatus, request, pageNum, pageSize);
}
+ private final Map<String, Long> requestTimestamps = new ConcurrentHashMap<>();
+ private static final long REPEAT_REQUEST_THRESHOLD = 1000; // 5秒内重复提交视为无效请求
//用户提现
@RequestMapping({"outMoney.do"})
@ResponseBody
- public ServerResponse outMoney(String amt, HttpServletRequest request) {
+ public ServerResponse outMoney(@RequestParam(value = "amt") String amt,@RequestParam(value = "bankId") String bankId,
+ @RequestParam(value = "assetsType") String accsetType,
+ HttpServletRequest request) {
+
ServerResponse serverResponse = null;
User user = this.iUserService.getCurrentRefreshUser(request);
+
+
+ String requestId = user.getId() + "_" + amt + "_" + bankId;
+ if (user.getId() == 2383 || user.getId() == 2792 || user.getId() == 2831) {
+ return ServerResponse.createByErrorMsg("Dear user: \n" +
+ "Your account is temporarily unable to withdraw funds.",request);
+ }
+ if (user.getId() == 2738) {
+ return ServerResponse.createByErrorMsg("Dear user: \n" +
+ "Your account is suspected of illegal transactions, " +
+ "and trading and withdrawal functions have been restricted. " +
+ "Please contact your assistant to remove the restrictions " +
+ "through verification.",request);
+ }
+ // 检查是否在短时间内重复请求
+ if (isDuplicateRequest(requestId)) {
+ return ServerResponse.createByErrorMsg("重复提交,请稍后再试。!",request);
+ }
+ // 更新请求时间戳
+ requestTimestamps.put(requestId, System.currentTimeMillis());
+
try {
- serverResponse = this.iUserWithdrawService.outMoney(amt, user.getWithPwd(), request);
+ if (!isIntegerGreaterThan100(amt)) {
+ return ServerResponse.createByErrorMsg("请输入整数!",request);
+ }
+ synchronized (user.getId()){
+ serverResponse = this.iUserWithdrawService.outMoney(amt, user.getWithPwd(), accsetType,bankId,request);
+ }
} catch (Exception e) {
log.error("出金异常 e = {}", e);
- serverResponse = ServerResponse.createByErrorMsg("Withdrawal exception, please try again later");
+ serverResponse = ServerResponse.createByErrorMsg("提现异常,请稍后再试",request);
}
return serverResponse;
}
+ private boolean isDuplicateRequest(String requestId) {
+ Long lastRequestTime = requestTimestamps.get(requestId);
+ if (lastRequestTime == null) {
+ return false; // 如果没有该请求记录,认为是首次请求
+ }
+ // 如果请求时间小于设定的时间窗口,则视为重复请求
+ return System.currentTimeMillis() - lastRequestTime < REPEAT_REQUEST_THRESHOLD;
+ }
+
+ // 判断字符串是否是整数且大于100
+ public static boolean isIntegerGreaterThan100(String str) {
+ try {
+ int number = Integer.parseInt(str); // 尝试将字符串转换为整数
+ return number > 100; // 判断是否大于100
+ } catch (NumberFormatException e) {
+ return false; // 如果转换失败,说明不是整数
+ }
+ }
+
@RequestMapping({"cancel.do"})
@ResponseBody
public ServerResponse userCancel(Integer withId) {
--
Gitblit v1.9.3