-
-
Notifications
You must be signed in to change notification settings - Fork 9k
新增:微信支付多公众号关联配置支持 #3842
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
新增:微信支付多公众号关联配置支持 #3842
Conversation
Co-authored-by: binarywang <[email protected]>
Co-authored-by: binarywang <[email protected]>
Co-authored-by: binarywang <[email protected]>
|
auggie review |
🤖 Augment PR Summary总结:本 PR 为 变更点:
技术说明:多配置通过 🤖 Was this summary useful? React with 👍 or 👎 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| @@ -0,0 +1,2 @@ | |||
| org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| @Override | ||
| public void removeWxPayService(String configKey) { | ||
| services.remove(configKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
|
||
| // 使用 computeIfAbsent 实现线程安全的懒加载,避免使用 synchronized(this) 带来的性能问题 | ||
| return services.computeIfAbsent(configKey, key -> { | ||
| WxPaySingleProperties properties = wxPayMultiProperties.getConfigs().get(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
本 Pull Request 新增了 wx-java-pay-multi-spring-boot-starter 模块,为 WxJava 项目提供微信支付多公众号关联配置支持。该功能允许开发者在单个应用中为多个公众号配置独立的微信支付服务,解决了服务商或多公众号系统的支付场景需求。
主要变更包括:
- 新增支持多配置的 Spring Boot Starter 模块,提供基于 Map 的配置管理
- 实现懒加载服务创建机制,通过
ConcurrentHashMap.computeIfAbsent()保证线程安全 - 提供完整的配置示例、单元测试和使用文档
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| spring-boot-starters/pom.xml | 在父 POM 中添加新模块 wx-java-pay-multi-spring-boot-starter |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/pom.xml | 新模块的 Maven 配置,包含依赖和构建插件 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/config/WxPayMultiAutoConfiguration.java | Spring Boot 自动配置类,负责注册多服务管理器 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/properties/WxPayMultiProperties.java | 多配置属性类,定义配置前缀和存储结构 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/properties/WxPaySingleProperties.java | 单个公众号配置属性类,包含所有微信支付相关配置项 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/service/WxPayMultiServices.java | 多服务管理接口,定义获取和移除服务方法 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/java/com/binarywang/spring/starter/wxjava/pay/service/WxPayMultiServicesImpl.java | 多服务管理实现类,提供线程安全的懒加载服务创建 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories | Spring Boot 自动配置注册文件 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/test/java/com/binarywang/spring/starter/wxjava/pay/WxPayMultiServicesTest.java | 单元测试,验证配置加载和服务管理功能 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/src/test/java/com/binarywang/spring/starter/wxjava/pay/example/WxPayMultiExample.java | 详细的使用示例代码,涵盖常见支付场景 |
| spring-boot-starters/wx-java-pay-multi-spring-boot-starter/README.md | 完整的使用文档,包含配置说明、示例和常见问题 |
| import com.github.binarywang.wxpay.service.WxPayService; | ||
|
|
||
| /** | ||
| * 微信支付 {@link WxPayService} 所有实例存放类. |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
javadoc 注释不准确。此接口用于存放微信支付服务实例,而非企业微信。应改为"微信支付 {@link WxPayService} 所有实例存放类"而非"企业微信"。
| } | ||
|
|
||
| // 查询订单 | ||
| WxPayOrderQueryV3Result result = wxPayService.queryOrderV3(null, outTradeNo); |
Copilot
AI
Jan 9, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
示例代码中使用了 WxPayOrderQueryV3Result 类型,但在导入语句中缺少对应的 import 声明。应在文件开头的 import 部分添加:import com.github.binarywang.wxpay.bean.result.WxPayOrderQueryV3Result;
用户需要在单个应用中为多个公众号配置微信支付服务。现有的
wx-java-pay-spring-boot-starter仅支持单一配置。实现
新增
wx-java-pay-multi-spring-boot-starter模块,提供以下能力:WxPayMultiProperties支持基于 Map 的多公众号配置WxPayMultiServices接口根据 configKey 返回对应的WxPayService实例ConcurrentHashMap.computeIfAbsent()实现按需创建和缓存配置示例
使用方式
结构
WxPayMultiProperties/WxPaySingleProperties:配置属性类WxPayMultiServices/WxPayMultiServicesImpl:服务管理WxPayMultiAutoConfiguration:Spring Boot 自动配置Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.