亲测全套支付可用(微信支付宝)复制粘贴即可跑

news/2024/11/29 22:28:45/

亲测全套支付可用(微信支付宝包括退款)复制粘贴即可跑

/*** @Auther: tjr* @Date: 2020/9/30 15:11* @Description: 支付宝后台接口*/
@Slf4j
@RestController
@RequestMapping(value = "/pay")
@Api(value="支付", tags="支付模块")
public class PayController {@AutowiredAliPayService aliPayService;@AutowiredWxPayService wxPayService;@AutowiredCouOrderService couOrderService;@AutowiredCouOrderMapper couOrderMapper;@AutowiredCouUserMapper couUserMapper;@ApiOperation(value = "统一微信公众号支付接口")@PostMapping("/jspaPay")public CommonResult jspaPay(@RequestBody Request<AliWxPayEntity> request, HttpServletRequest httpServletRequest) {if (request == null) {return CommonResult.validateFailed();}AliWxPayEntity entity = JSON.parseObject(JSON.toJSONString(request.getData()), AliWxPayEntity.class);if (entity.getMoney() == null|| entity.getPayStatus() == null ) {}if (entity.getMoney() == null || entity.getPayStatus() == null) {return CommonResult.validateFailed();}if (entity.getPayStatus() == 1) {WxPayEntity wxPayEntity = new WxPayEntity();String ip = HttpUtils.getRemoteHost(httpServletRequest);wxPayEntity.setOrderNo(entity.getOdd());wxPayEntity.setTotalMoney(entity.getMoney());wxPayEntity.setIp(ip);CouUser couUser = couUserMapper.selectById(entity.getUserId());if (couUser==null){return CommonResult.failed("找不到该用户");}if (StringUtil.isBlank(couUser.getOpenId())){return CommonResult.failed("该用户暂未绑定微信,没有openid");}wxPayEntity.setOpenid(couUser.getOpenId());//微信支付ResultMap resultMap = wxPayService.JSAPIPay(wxPayEntity);PayEntity payEntity = new PayEntity();payEntity.setNum(entity.getOdd());payEntity.setResultMap(resultMap);return CommonResult.success(payEntity);}return CommonResult.failed("下单失败");}/*** app支付接口-统一下单支付接口** @return* @throws AlipayApiException*/@ApiOperation(value = "统一app支付接口")@PostMapping("/appPay")public CommonResult appPay(@RequestBody Request<AliWxPayEntity> request, HttpServletRequest httpServletRequest) {if (request == null) {return CommonResult.validateFailed();}AliWxPayEntity entity = JSON.parseObject(JSON.toJSONString(request.getData()), AliWxPayEntity.class);if (entity.getMoney() == null|| entity.getPayStatus() == null ) {}if (entity.getMoney() == null || entity.getPayStatus() == null) {return CommonResult.validateFailed();}if (entity.getPayStatus() == 2) {//发起支付,支付宝PayOrderNo payOrderNo = new PayOrderNo();payOrderNo.setTotalFee(String.valueOf((entity.getMoney().multiply(new BigDecimal(100)).intValue())));//分//设置订单号payOrderNo.setOrderNo(entity.getOdd());//获取支付AlipayTradeAppPayResponse response = aliPayService.tradeAppPay(payOrderNo);if (response.isSuccess()) {log.debug("调用成功" + response.getBody());PayEntity payEntity = new PayEntity();payEntity.setNum(entity.getOdd());payEntity.setPay(response.getBody());return CommonResult.success(payEntity);} else {log.error("调用失败" + response.getBody());return CommonResult.failed(response.getBody());}}if (entity.getPayStatus() == 1) {WxPayEntity wxPayEntity = new WxPayEntity();String ip = HttpUtils.getRemoteHost(httpServletRequest);wxPayEntity.setOrderNo(entity.getOdd());wxPayEntity.setTotalMoney(entity.getMoney());wxPayEntity.setIp(ip);//微信支付ResultMap resultMap = wxPayService.unifiedOrder(wxPayEntity);PayEntity payEntity = new PayEntity();payEntity.setNum(entity.getOdd());payEntity.setResultMap(resultMap);return CommonResult.success(payEntity);}return CommonResult.failed("下单失败");}/***   支付网站扫码支付接口-统一下单支付接口方法* @author tujr* @createTime 2020/8/27 0027 10:09**/@ApiOperation(value="统一网站支付接口")@PostMapping("/nativePay")public CommonResult nativePay(@RequestBody Request<AliWxPayEntity> request, HttpServletRequest httpServletRequest, HttpServletResponse response) throws Exception {if (request==null){return CommonResult.validateFailed();}AliWxPayEntity entity = JSON.parseObject(JSON.toJSONString(request.getData()), AliWxPayEntity.class);if (entity.getMoney()==null ||entity.getPayStatus()==null||entity.getPayStatus()<1||entity.getPayStatus()>2){return CommonResult.validateFailed();}if (entity.getPayStatus()==2) {AliPayEntity aliPayEntity = new AliPayEntity();aliPayEntity.setMoney(entity.getMoney());aliPayEntity.setOrderNo(entity.getOdd());aliPayService.alipayPay(aliPayEntity,response);}if (entity.getPayStatus()==1){WxPayEntity wxPayEntity = new WxPayEntity();String ip = HttpUtils.getRemoteHost(httpServletRequest);wxPayEntity.setOrderNo(entity.getOdd());wxPayEntity.setTotalMoney(entity.getMoney());wxPayEntity.setIp(ip);//微信支付wxPayService.nativePay(wxPayEntity,httpServletRequest,response);}return CommonResult.failed("下单失败");}@ApiOperation(value="轮询查状态接口")@PostMapping("/selectPayStatus")public CommonResult selectPayStatus(@RequestBody Request<AliPayStatusEntity> request) {return aliPayService.selectPayStatus(request);}}

代码地址

https://download.csdn.net/download/weixin_43285931/12849640


http://www.ppmy.cn/news/487215.html

相关文章

台式机组装日志

目录 经验教训价格调研我的购买 经验教训 敲黑板&#xff0c;本次装机遇到一些问题&#xff0c;这是积累下来的知识点&#xff1a; 1、小心点&#xff0c;不要把CPU针脚搞弯了&#xff0c;搞弯一个都可能导致点不亮 2、硅胶不要粘到主板的孔上&#xff0c;如果粘了&#xff0…

华为POE交换机重置密码

console登录 然后重启ctrlb 缺省情况下&#xff0c;BootLoad菜单密码为Adminhuawei.com&#xff0c;从历史版本升级到新版本的设备&#xff0c;此密码可能为huawei https://support.huawei.com/hedex/hdx.do?docidEDOC1100126532&idZH-CN_TASK_0177100304&langzh 改…

最新-安装Windows与Ubuntu双系统

安装双系统 零.前言一.准备工作1.磁盘类型与引导类型2.制作启动盘①下载镜像与软碟通软件②.制作启动盘 3.系统设置①.分配内存②.安全模式③.设置bios模式 二.安装ubuntu三.设置Ubuntu1.启动项2.修改时间 四.继续处理Windows 零.前言 距离第一次写的安装已经过去了&#xff0…

尝试manjar20.03、fedora32、ubuntu20.04作为主力操作系统

编写日期&#xff1a;2020年7月23日19点09分 本篇为连载文章 修改日期&#xff1a;2020年8月3日星期一 9:44 首先manjaro是从搜索引擎上搜到友好的linux桌面发行版搜到的&#xff0c;之前就有想要放弃windows转向linux桌面版 曾经尝试过很多发行版&#xff08;opensuse、centos…

html5 crosshair,嘿,纯正ROG血统 CROSSHAIR VIII IMPACT (开箱篇)最终版

本帖最后由 twfox 于 2019-9-8 14:56 编辑 C8I啊C8I纯正的ROG血统的ITX&#xff0c;虽然它并不是100%的完美&#xff0c;但是在M8I之后&#xff0c;ROG ITX断档如此之久的情况下&#xff0c;C8I的横空出世确实给我们带来了出乎意料的惊喜。 得ITX者得天下&#xff0c;ASUS把最大…

自费访问学者如何申请?

在公派访问学者选拔之初&#xff0c;还未有自费访问学者一说。近几年之所以会持续升温&#xff0c;主要是基于公派访问学者申请的限制性名额及硬性条件规定&#xff0c;同时外加自费留学潮的影响&#xff0c;其已无法满足持续增长的高申请需求。 那么目前访问学者申请面临哪些…

npm 异常报告

Unknown file extension ".css" for D:\xxxx\node_modules\.pnpm\element-plus2.3.6_vue3.3.4\node_modules\element-plus\theme-chalk\base.css 解决方法是&#xff1a; vite.cofig.ts 在noExternal里把安装的包加进去 ssr: {// TODO: workaround until they supp…

unity--前端架构基础版

目录 1.MVC&#xff08;Model-View-Controller&#xff09;模式 1.1示例一&#xff1a; 1.2示例2: 2.ECS (Entity-Component-System&#xff09;模式 2.1示例1: 2.2示例二&#xff1a; 3.MVVM&#xff08;Model-View-ViewModel&#xff09;模式&#xff1a; 1.MVC&#xf…