mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-06 20:47:46 +00:00
feat 微信通道添加单独的认证跳转地址
This commit is contained in:
@@ -1,4 +1,8 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
## [v3.0.0.beta2] 2024-11-08
|
||||||
|
- fix: 系统参数使用到MySQL8保留字
|
||||||
|
- fix: Mysql 脚本缺少 缺失 表pay_api_const
|
||||||
|
- fix: H5构建版本限制错误, 限制为最低为node20+
|
||||||
## [v3.0.0.beta1] 2024-10-24
|
## [v3.0.0.beta1] 2024-10-24
|
||||||
- 重构: JDK版本升级为21+, Spring Boot 版本升级为3.3.x, 前端组件升级为Antd Vue 4.x + Vite5
|
- 重构: JDK版本升级为21+, Spring Boot 版本升级为3.3.x, 前端组件升级为Antd Vue 4.x + Vite5
|
||||||
- 重构: 数据库更新为PostgreSQL + MySQL8.x 双版本支持
|
- 重构: 数据库更新为PostgreSQL + MySQL8.x 双版本支持
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# 单商户
|
# 单商户
|
||||||
## 3.0.0.bate2: 功能完善第二阶段
|
## 3.0.0.bate2: 功能完善第二阶段
|
||||||
- 优化:
|
- 优化:
|
||||||
- [ ] 增加首页驾驶舱功能
|
- [ ] 增加首页驾驶舱功能
|
||||||
- [ ] 分账功能
|
- [ ] 分账功能
|
||||||
- [x] 分账接收方配置
|
- [x] 分账接收方配置
|
||||||
- [ ] 分账单管理
|
- [ ] 分账单管理
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
- [ ] 同步回调页
|
- [ ] 同步回调页
|
||||||
- [ ] 商户应用增加启停用状态
|
- [ ] 商户应用增加启停用状态
|
||||||
- [ ] 商户应用应该要有一个类似删除的功能, 实现停用冻结, 但不影响数据的关联
|
- [ ] 商户应用应该要有一个类似删除的功能, 实现停用冻结, 但不影响数据的关联
|
||||||
- [ ] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
- [x] 微信通道添加单独的认证跳转地址, 处理它的特殊情况
|
||||||
|
|
||||||
## 任务池
|
## 任务池
|
||||||
- [ ] 定时同步任务频次不要太高, 预防产生过多的数据
|
- [ ] 定时同步任务频次不要太高, 预防产生过多的数据
|
||||||
|
@@ -34,6 +34,9 @@ public class WechatPayConfig implements ToResult<WechatPayConfigResult> {
|
|||||||
/** 是否启用 */
|
/** 是否启用 */
|
||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
|
/** 授权认证地址 */
|
||||||
|
private String authUrl;
|
||||||
|
|
||||||
/** 支付限额 */
|
/** 支付限额 */
|
||||||
private BigDecimal limitAmount;
|
private BigDecimal limitAmount;
|
||||||
|
|
||||||
|
@@ -38,6 +38,10 @@ public class WechatPayConfigParam {
|
|||||||
@Schema(description = "是否启用")
|
@Schema(description = "是否启用")
|
||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
|
/** 授权认证地址 */
|
||||||
|
@Schema(description = "授权认证地址")
|
||||||
|
private String authUrl;
|
||||||
|
|
||||||
/** 支付限额 */
|
/** 支付限额 */
|
||||||
@NotNull(message = "支付限额不可为空")
|
@NotNull(message = "支付限额不可为空")
|
||||||
@Schema(description = "支付限额")
|
@Schema(description = "支付限额")
|
||||||
|
@@ -33,6 +33,10 @@ public class WechatPayConfigResult {
|
|||||||
@Schema(description = "是否启用")
|
@Schema(description = "是否启用")
|
||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
|
/** 授权认证地址 */
|
||||||
|
@Schema(description = "授权认证地址")
|
||||||
|
private String authUrl;
|
||||||
|
|
||||||
/** 支付限额 */
|
/** 支付限额 */
|
||||||
@Schema(description = "支付限额")
|
@Schema(description = "支付限额")
|
||||||
private BigDecimal limitAmount;
|
private BigDecimal limitAmount;
|
||||||
|
@@ -37,16 +37,21 @@ public class WechatAuthService {
|
|||||||
* 构建微信oauth2授权的url连接
|
* 构建微信oauth2授权的url连接
|
||||||
*/
|
*/
|
||||||
public AuthUrlResult generateAuthUrl(GenerateAuthUrlParam param) {
|
public AuthUrlResult generateAuthUrl(GenerateAuthUrlParam param) {
|
||||||
WxMpService wxMpService = this.getWxMpService();
|
WechatPayConfig config = wechatPayConfigService.getWechatPayConfig();
|
||||||
|
WxMpService wxMpService = this.getWxMpService(config);
|
||||||
// 手段传输回调地址, 直接拼接不做处理
|
// 手段传输回调地址, 直接拼接不做处理
|
||||||
if (StrUtil.isNotBlank(param.getAuthRedirectUrl())){
|
if (StrUtil.isNotBlank(param.getAuthRedirectUrl())){
|
||||||
String url = wxMpService.getOAuth2Service()
|
String url = wxMpService.getOAuth2Service()
|
||||||
.buildAuthorizationUrl(param.getAuthRedirectUrl(), WxConsts.OAuth2Scope.SNSAPI_BASE, "");
|
.buildAuthorizationUrl(param.getAuthRedirectUrl(), WxConsts.OAuth2Scope.SNSAPI_BASE, "");
|
||||||
return new AuthUrlResult().setAuthUrl(url);
|
return new AuthUrlResult().setAuthUrl(url);
|
||||||
} else {
|
} else {
|
||||||
PlatformConfig platformConfig = platformsConfigService.getConfig();
|
String serverUrl = platformsConfigService.getConfig().getGatewayMobileUrl();
|
||||||
|
// 如果配置中有地址配置则使用, 没有的话使用平台地址进行拼接
|
||||||
|
if (StrUtil.isNotBlank(config.getAuthUrl())){
|
||||||
|
PlatformConfig platformConfig = platformsConfigService.getConfig();
|
||||||
|
serverUrl = platformConfig.getGatewayMobileUrl();
|
||||||
|
}
|
||||||
String queryCode = RandomUtil.randomString(10);
|
String queryCode = RandomUtil.randomString(10);
|
||||||
String serverUrl = platformConfig.getGatewayMobileUrl();
|
|
||||||
String redirectUrl = StrUtil.format("{}/wechat/auth/{}/{}/{}", serverUrl, param.getAppId(), param.getChannel(),queryCode);
|
String redirectUrl = StrUtil.format("{}/wechat/auth/{}/{}/{}", serverUrl, param.getAppId(), param.getChannel(),queryCode);
|
||||||
String authUrl = wxMpService.getOAuth2Service().buildAuthorizationUrl(redirectUrl, WxConsts.OAuth2Scope.SNSAPI_BASE, "");
|
String authUrl = wxMpService.getOAuth2Service().buildAuthorizationUrl(redirectUrl, WxConsts.OAuth2Scope.SNSAPI_BASE, "");
|
||||||
return new AuthUrlResult().setAuthUrl(authUrl).setQueryCode(queryCode);
|
return new AuthUrlResult().setAuthUrl(authUrl).setQueryCode(queryCode);
|
||||||
@@ -70,6 +75,12 @@ public class WechatAuthService {
|
|||||||
*/
|
*/
|
||||||
private WxMpService getWxMpService() {
|
private WxMpService getWxMpService() {
|
||||||
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig();
|
WechatPayConfig config = wechatPayConfigService.getAndCheckConfig();
|
||||||
|
return getWxMpService(config);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 获取微信公众号API的Service
|
||||||
|
*/
|
||||||
|
private WxMpService getWxMpService(WechatPayConfig config) {
|
||||||
WxMpService wxMpService = new WxMpServiceImpl();
|
WxMpService wxMpService = new WxMpServiceImpl();
|
||||||
WxMpDefaultConfigImpl wxMpConfig = new WxMpDefaultConfigImpl();
|
WxMpDefaultConfigImpl wxMpConfig = new WxMpDefaultConfigImpl();
|
||||||
wxMpConfig.setAppId(config.getWxAppId()); // 设置微信公众号的appid
|
wxMpConfig.setAppId(config.getWxAppId()); // 设置微信公众号的appid
|
||||||
|
Reference in New Issue
Block a user