| | |
| | | import cn.afterturn.easypoi.excel.entity.ExportParams; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.nq.common.ServerResponse; |
| | | import com.nq.pojo.TradeResultVO; |
| | | import com.nq.pojo.UserWithdraw; |
| | | import com.nq.service.IUserWithdrawService; |
| | | |
| | |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | @Controller |
| | | @RequestMapping({"/admin/withdraw/"}) |
| | |
| | | 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 |