11
This commit is contained in:
1 parent
b220dc7e09
commit
aa9963bfe1
5 files changed
+48
-5
No files matched your search
+7
@@ -75,6 +75,13 @@ public class AppSocialUserController {
|
||||
return success(socialClientApi.getWxUrlScheme(path, json));
|
||||
}
|
||||
|
||||
@GetMapping("/wxa-url-link")
|
||||
@Operation(summary = "获取小程序 URL Link")
|
||||
@PermitAll
|
||||
public CommonResult<String> getWxUrlLink(@RequestParam String path, @RequestParam String json) {
|
||||
return success(socialClientApi.getWxUrlLink(path, json));
|
||||
}
|
||||
|
||||
@GetMapping("/get-subscribe-template-list")
|
||||
@Operation(summary = "获得微信小程订阅模板列表")
|
||||
@PermitAll
|
||||
|
||||
+5
@@ -49,6 +49,11 @@ public interface SocialClientApi {
|
||||
*/
|
||||
String getWxUrlScheme(String path, String json);
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link
|
||||
*/
|
||||
String getWxUrlLink(String path, String json);
|
||||
|
||||
/**
|
||||
* 获得小程序二维码
|
||||
*
|
||||
|
||||
+5
@@ -63,6 +63,11 @@ public class SocialClientApiImpl implements SocialClientApi {
|
||||
return socialClientService.getWxUrlScheme(path, json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWxUrlLink(String path, String json) {
|
||||
return socialClientService.getWxUrlLink(path, json);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
return socialClientService.getWxaQrcode(reqVO);
|
||||
|
||||
+5
@@ -62,6 +62,11 @@ public interface SocialClientService {
|
||||
*/
|
||||
String getWxUrlScheme(String path, String json);
|
||||
|
||||
/**
|
||||
* 获取小程序 URL Link
|
||||
*/
|
||||
String getWxUrlLink(String path, String json);
|
||||
|
||||
/**
|
||||
* 获得微信小程序的手机信息
|
||||
*
|
||||
|
||||
+26
-5
@@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.api.impl.WxMaServiceImpl;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaPhoneNumberInfo;
|
||||
import cn.binarywang.wx.miniapp.bean.WxMaSubscribeMessage;
|
||||
import cn.binarywang.wx.miniapp.bean.scheme.WxMaGenerateSchemeRequest;
|
||||
import cn.binarywang.wx.miniapp.bean.urllink.GenerateUrlLinkRequest;
|
||||
import cn.binarywang.wx.miniapp.config.impl.WxMaRedisBetterConfigImpl;
|
||||
import cn.binarywang.wx.miniapp.constant.WxMaConstants;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
@@ -55,8 +56,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -268,8 +268,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
*/
|
||||
@Override
|
||||
public String getWxUrlScheme(String path, String json) {
|
||||
long expireTime = LocalDateTime.now().toInstant(ZoneOffset.UTC).getEpochSecond();
|
||||
expireTime += 5 * 60 * 1000;
|
||||
long expireTime = Instant.now().getEpochSecond() + 5 * 60;
|
||||
WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
||||
try {
|
||||
String urlScheme = service.getWxMaSchemeService().generate(WxMaGenerateSchemeRequest.newBuilder()
|
||||
@@ -277,7 +276,7 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
// 正式版本-release
|
||||
// 体验版-trial
|
||||
// 开发版-develop
|
||||
WxMaGenerateSchemeRequest.JumpWxa.newBuilder().path(path).query(json).envVersion("trial").build()
|
||||
WxMaGenerateSchemeRequest.JumpWxa.newBuilder().path(path).query(json).envVersion("release").build()
|
||||
)
|
||||
.expireTime(expireTime)
|
||||
.expireType(0)
|
||||
@@ -291,6 +290,28 @@ public class SocialClientServiceImpl implements SocialClientService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 HTTPS 小程序 URL Link,用于不允许打开 weixin:// 协议的 WebView。
|
||||
*/
|
||||
@Override
|
||||
public String getWxUrlLink(String path, String json) {
|
||||
long expireTime = Instant.now().getEpochSecond() + 5 * 60;
|
||||
WxMaService service = getWxMaService(UserTypeEnum.MEMBER.getValue());
|
||||
try {
|
||||
return service.getLinkService().generateUrlLink(GenerateUrlLinkRequest.builder()
|
||||
.path(path)
|
||||
.query(json)
|
||||
.envVersion("release")
|
||||
.expireTime(expireTime)
|
||||
.expireType(0)
|
||||
.isExpire(true)
|
||||
.build());
|
||||
} catch (Exception e) {
|
||||
log.error("[getWxUrlLink][path({}) json({}) 获取小程序 URL Link 失败]", path, json, e);
|
||||
throw exception(SOCIAL_CLIENT_WEIXIN_MINI_APP_URL_SCHEME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public byte[] getWxaQrcode(SocialWxQrcodeReqDTO reqVO) {
|
||||
|
||||
Reference in new issue
Block a user