正文:
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