(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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章