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