peter
2025-10-30 854aa5b79d3906b335524f09581f3a567a7bad49
src/main/java/com/nq/controller/backend/AdminWithDrawController.java
@@ -23,6 +23,8 @@
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Controller
@RequestMapping({"/admin/withdraw/"})
@@ -72,13 +74,33 @@
                                      HttpServletRequest request, HttpServletResponse response) {
        ServerResponse serverResponse = null;
        try {
            serverResponse = this.iUserWithdrawService.updateState(withId, state, authMsg,request,response);
            String requestId = withId + "_" + state;
            // 检查是否在短时间内重复请求
            if (isDuplicateRequest(requestId)) {
                return ServerResponse.createByErrorMsg("重复提交,请稍后再试。");
            }
            // 更新请求时间戳
            requestTimestamps.put(requestId, System.currentTimeMillis());
            synchronized (withId){
                serverResponse = this.iUserWithdrawService.updateState(withId, state, authMsg,request,response);
            }
        } catch (Exception e) {
            log.error("admin修改充值订单状态出错 ,异常 = {}", e);
            return ServerResponse.createByErrorMsg("操作失败");
        }
        return serverResponse;
    }
    private final Map<String, Long> requestTimestamps = new ConcurrentHashMap<>();
    private static final long REPEAT_REQUEST_THRESHOLD = 1000;  // 5秒内重复提交视为无效请求
    private boolean isDuplicateRequest(String requestId) {
        Long lastRequestTime = requestTimestamps.get(requestId);
        if (lastRequestTime == null) {
            return false;  // 如果没有该请求记录,认为是首次请求
        }
        // 如果请求时间小于设定的时间窗口,则视为重复请求
        return System.currentTimeMillis() - lastRequestTime < REPEAT_REQUEST_THRESHOLD;
    }
    @RequestMapping({"deleteWithdraw.do"})
    @ResponseBody