当前位置:网站首页>新增订单如何防止重复提交
新增订单如何防止重复提交
2022-07-01 18:45:00 【墨着染霜华】
上篇文章写了幂等性防抖防止重复提交,可以有效阻止连续不停的点击提交,但是现在出现了一个情况,因为网络慢或者后台服务器慢导致提交的数据处理返回超时,等了大概1分钟甚至几分钟之后的提交,幂等性防抖就不起作用,订单生成多次。
为了解决这个问题,我在进入订单页面就请求了一个UUID,除非是重新进入该页面UUID不会变动,然后提交时候带着这个UUID去请求,如果REIDS中该UUID存在那么判断重复请求,不存在那么后台接受到了将UUID存入REDIS中,如果处理失败那么还是要移除这个KEY。
参考代码如下:
String key= MessageFormat.format("INSERT:HYKCZD:{0}:{1}",vo.getTenantId(),vo.getDjbh());
if(redisService.haskey(key)) throw new BusinessException("本页面请求已处理,请勿重复提交");
redisService.setCacheObject(key,vo.getZdr()+"-"+getDateTime(),7, TimeUnit.DAYS);
PosVipCzsz czsz=czszMapper.selectById(vo.getCzszId());
if(czsz.getType()==0){
vo.setJe1(czsz.getJe2());
vo.setJe2(czsz.getJe());
vo.setJe3(czsz.getJe1());
}else{
validObjectParam(vo, VpczdVO.class, "je2","je3");
Double je1=add(vo.getJe2(), vo.getJe3());
vo.setJe1(je1);
}
String host=getHost(),url="pos/vpczd/cz",json= JSON.toJSONString(vo);
JsonResult jsonResult= doGetJsonResult$post(host, url, json);
if(!jsonResult.isSuccess()) {
redisService.deleteObject(key);
throw new DataIntefaceException(jsonResult.getMsg());
}
return 1;边栏推荐
- 微信公众号开发相关流程及功能介绍
- Parallelism, concurrency and life cycle of threads
- H264编码profile & level控制
- Intensive cultivation of channels for joint development Fuxin and Weishi Jiajie held a new product training conference
- XML syntax, constraints
- wireshark报文分析tcp,ftp
- 论文阅读【Discriminative Latent Semantic Graph for Video Captioning】
- [untitled]
- Regular expression =regex=regular expression
- 利用win7漏洞进行系统登录密码破解
猜你喜欢

Salesmartly has some tricks for Facebook chat!

nacos启动失败问题解决与总结

Oracle物理体系结构

wireshark报文分析tcp,ftp

Test self-study people must see: how to find test items in software testing?
![Extensive reading of the paper [film: visual reasoning with a general condition layer]](/img/69/f4ba37a7eae34a7e698127c31b0161.png)
Extensive reading of the paper [film: visual reasoning with a general condition layer]
![[to.Net] C set class source code analysis](/img/59/4c7b910bc6505e5f81015ce80812fc.png)
[to.Net] C set class source code analysis

Audio and video, encoding and decoding related e-books, gadgets, packaged for free!

Flutter 实战-快速实现音视频通话应用

精耕渠道共謀發展 福昕攜手偉仕佳傑開展新產品培訓大會
随机推荐
SIP protocol of gb28181
Go Language Advanced
Extensive reading of the paper [film: visual reasoning with a general condition layer]
ffmpeg常用命令(二)
[to.Net] C set class source code analysis
ubuntu14安装MySQL并配置root账户本地与远程访问
Solidity - contract structure - error - ^0.8.4 NEW
P2433 【深基1-2】小学数学 N 合一
Methods of finding various limits
The intelligent epidemic prevention system provides safety guarantee for the resumption of work and production at the construction site
[English grammar] Unit1 articles, nouns, pronouns and numerals
物联网平台thingsboard搭建学习记录
pickle.load报错【AttributeError: Can‘t get attribute ‘Vocabulary‘ on <module ‘__main__‘】
音视频、编解码相关电子书、小工具,打包奉送!
Contos 7 搭建sftp之创建用户、用户组以及删除用户
ffmpeg AVFrame 转 cv::Mat
Shell advanced
Analysis of GetMessage underlying mechanism
ffmpeg 音频相关命令
商业智能BI开发和报表开发有什么本质区别?