(JAVA)获取支付宝二维码 带参数

正文:

前端文档  后台文档

public Vo aliSmall() throws AdminException,AlipayApiException {
        SysUser user = shiroService.getUser();
        WxUser wxUser = dao.get(WxUser.class,user.getId());
        AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.url,AlipayConfig.app_id,AlipayConfig.private_key,AlipayConfig.format,AlipayConfig.charset,AlipayConfig.public_key,AlipayConfig.signtype);
        AlipayOpenAppQrcodeCreateRequest request = new AlipayOpenAppQrcodeCreateRequest();
        AlipayOpenAppQrcodeCreateModel model = new AlipayOpenAppQrcodeCreateModel();
        model.setUrlParam("pages/index/index");
        model.setDescribe("小程序个人推广分享二维码");
        model.setQueryParam("code="+wxUser.getShareCode());
        request.setBizModel(model);
        AlipayOpenAppQrcodeCreateResponse response = alipayClient.execute(request);
        if(response.isSuccess()){
            SysConfig sysConfig  = sysConfigRepository.findByConfigKeyAndDeletedFalse(SysConfigValue.SHARE_TEXT);
            Map map = new HashMap();
            map.put("shareText",sysConfig.getConfigValue());map.put("shareCode",response.getQrCodeUrl());
            return new Vo(map);
        } else {
            throw new AdminException("获取推广码失败");
        }
    }

只需要三个参数:

1.urlParam:小程序页面

2.描述,没用的话可以直接为空3.参数:格式为xx=xx&xx=xx

发布了17 篇原创文章 · 获赞 35 · 访问量 3万+

猜你喜欢

转载自blog.csdn.net/weixin_42359392/article/details/105595223
今日推荐