Skip to content

feat: 拆分微信小店独立模块 - #4117

Open
binarywang wants to merge 1 commit into
developfrom
feature/issue-4004-store-module
Open

feat: 拆分微信小店独立模块#4117
binarywang wants to merge 1 commit into
developfrom
feature/issue-4004-store-module

Conversation

@binarywang

Copy link
Copy Markdown
Owner

变更内容

  • 新增独立 weixin-java-store SDK,Java 包名为 com.binarywang.wxjava.store.*,不依赖 weixin-java-channel
  • 新增 Spring Boot/Solon 的单账号、多账号 Store 集成模块,配置前缀为 wx.store
  • 保留原 weixin-java-channel 的小店服务和模型,行为不变,并统一标记为 @Deprecated
  • 移除新 Store 模块中的直播、Finder、联盟分销、留资、罗盘达人版等 Channel 专属能力。
  • 增加迁移指南与新旧 API 边界回归测试。

验证

  • mvn -pl weixin-java-channel,weixin-java-store,spring-boot-starters/wx-java-store-spring-boot-starter,spring-boot-starters/wx-java-store-multi-spring-boot-starter,solon-plugins/wx-java-store-solon-plugin,solon-plugins/wx-java-store-multi-solon-plugin -am test -Dmaven.test.skip=false
    • Channel:58 tests passed
    • Store:3 tests passed
  • git diff --check

Copilot AI lite review requested due to automatic review settings August 30, 2026 09:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-08-30T09:51:53.908397Z da31b5d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@augmentcode

augmentcode Bot commented Aug 30, 2026

Copy link
Copy Markdown

This pull request is too large for Augment to review. The PR exceeds the maximum size limit of 75000 tokens (approximately 300000 characters) for automated code review. Please consider breaking this PR into smaller, more focused changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

BOM 目前未对本 PR 新增的 Store Starter / Solon 插件 artifact 做版本托管,可能影响依赖 BOM 的用户集成与升级体验。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

该 PR 将“微信小店(Store)”能力从 weixin-java-channel 中拆分为独立的 weixin-java-store SDK,并新增对应的 Spring Boot / Solon 集成模块;同时对 weixin-java-channel 中保留的小店相关 API/模型进行 @Deprecated 标记,以引导用户迁移且保持既有行为不变。

Changes:

  • 新增 weixin-java-store 模块,并在根聚合构建中注册该模块。
  • 新增 Store 的 Spring Boot Starter(单账号/多账号)与 Solon 插件(单账号/多账号)的自动装配/插件声明资源。
  • weixin-java-channel 中对小店相关接口与大量请求/响应/模型类增加 @Deprecated 标记。
File summaries
File Description
pom.xml 在根聚合模块中加入 weixin-java-store,纳入统一构建/发布链路。
wx-java-bom/pom.xml BOM 增加 weixin-java-store 的版本托管入口(但目前未覆盖 Store Starter/Solon 插件,见评论)。
spring-boot-starters/pom.xml 注册 Store 的 Spring Boot Starter 两个子模块。
spring-boot-starters/wx-java-store-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 声明 Store 单账号 Starter 的 AutoConfiguration 导入。
spring-boot-starters/wx-java-store-spring-boot-starter/src/main/resources/META-INF/spring.factories 兼容 Spring Boot 旧机制的自动装配声明。
spring-boot-starters/wx-java-store-multi-spring-boot-starter/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports 声明 Store 多账号 Starter 的 AutoConfiguration 导入。
spring-boot-starters/wx-java-store-multi-spring-boot-starter/src/main/resources/META-INF/spring.factories 兼容 Spring Boot 旧机制的自动装配声明。
solon-plugins/pom.xml 注册 Store 的 Solon 插件两个子模块。
solon-plugins/wx-java-store-solon-plugin/src/main/resources/META-INF/solon/wx-java-store-solon-plugin.properties 声明 Solon 插件入口与优先级。
solon-plugins/wx-java-store-solon-plugin/src/test/resources/app.yml Store Solon 插件测试资源(当前为空文件)。
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelKfService.java 将 Channel 内小店客服服务接口标记为 @Deprecated(建议补充迁移指引,见评论)。
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelAfterSaleService.java 将 Channel 内小店售后服务接口标记为 @Deprecated
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java 将 Channel 内小店商品服务接口标记为 @Deprecated
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/** 大量小店相关 Bean/Param/Response 增加 @Deprecated,用于迁移引导与边界划分。
Review details
  • Files reviewed: 299/1242 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread wx-java-bom/pom.xml
Comment on lines +60 to +64
<dependency>
<groupId>com.github.binarywang</groupId>
<artifactId>weixin-java-store</artifactId>
<version>${project.version}</version>
</dependency>
Comment on lines 7 to 9
/** 视频号小店商家客服服务。 */
@Deprecated
public interface WxChannelKfService {

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: da31b5dd85

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

private final WxStoreProperties properties;

@Bean
@ConditionalOnMissingBean(WxStoreProperties.class)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 修正 Spring 默认内存配置的 Bean 条件

使用默认配置或显式设置 wx.store.config-storage.type=memory 时,@EnableConfigurationProperties(WxStoreProperties.class) 已经注册了 WxStoreProperties,因此这里的条件恒为假,WxStoreConfig 不会创建;随后 WxStoreServiceAutoConfiguration@ConditionalOnBean(WxStoreConfig.class) 也不成立,文档承诺的两个自动注入对象均不可用。条件应检查缺少 WxStoreConfig,而不是缺少属性 Bean。

AGENTS.md reference: AGENTS.md:L57-L57

Useful? React with 👍 / 👎.

private final WxStoreProperties properties;

@Bean
@Condition(onMissingBean = WxStoreProperties.class)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 修正 Solon 默认内存配置的 Bean 条件

Solon 插件在 WxStorePluginImpl.start 中先执行 context.beanMake(WxStoreProperties.class),再加载此配置,所以默认 memory 场景下这里的 onMissingBean = WxStoreProperties.class 不成立,最终既没有 WxStoreConfig,也无法创建依赖它的 WxStoreService。应将缺失条件改为 WxStoreConfig.class

AGENTS.md reference: AGENTS.md:L57-L57

Useful? React with 👍 / 👎.

* @throws WxErrorException 异常
*/
protected String extractAccessToken(String resultContent) throws WxErrorException {
log.debug("access-token response: {}", resultContent);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 在调试日志中隐藏 access token

成功获取凭据时,resultContent 包含可直接调用微信接口的 access_token,开启 DEBUG 后这里会把完整凭据写入日志;同类泄露还发生在 executeInternal 记录带 access_token 查询参数的 uriWithAccessToken 时。请仅记录脱敏响应和不含凭据的请求地址。

AGENTS.md reference: AGENTS.md:L59-L59

Useful? React with 👍 / 👎.

@ConditionalOnMissingBean(WxStoreService.class)
@ConditionalOnBean(WxStoreConfig.class)
public WxStoreService wxStoreService(WxStoreConfig wxStoreConfig) {
WxStoreService wxStoreService = new WxStoreServiceImpl();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 让单账号 Starter 使用所配置的 HTTP 客户端

单账号 Spring Starter 无条件实例化 WxStoreServiceImpl,而该类继承 WxStoreServiceHttpClientImpl,所以 wx.store.config-storage.http-client-type 即使设置为默认属性值 HttpComponents 也不会选择 WxStoreServiceHttpComponentsImpl;Solon 单账号配置中也存在相同问题。需要像多账号配置一样根据 HttpClientType 创建对应实现,否则该公开配置项完全无效。

AGENTS.md reference: AGENTS.md:L56-L57

Useful? React with 👍 / 👎.

* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Configuration
@ConditionalOnProperty(prefix = WxStoreProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 接受文档声明的 redis_template 配置值

单账号 Starter 的 README 要求 wx.store.config-storage.type=redis_template,但该条件只匹配 redistemplate;使用文档配置时 RedisTemplate 配置类不会启用,显式值又会关闭默认 memory 配置,最终没有 WxStoreConfigWxStoreService。���统一条件值、枚举绑定和 README 中的配置键。

AGENTS.md reference: AGENTS.md:L89-L90

Useful? React with 👍 / 👎.

* @author <a href="https://github.com/lixize">Zeyes</a>
*/
@Configuration
@ConditionalOnProperty(prefix = WxStoreProperties.PREFIX + ".config-storage", name = "type", havingValue = "redistemplate")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 接受文档声明的 redis_template 配置值

单账号 Starter 的 README 要求 wx.store.config-storage.type=redis_template,但该条件只匹配 redistemplate;使用文档配置时 RedisTemplate 配置类不会启用,显式值又会关闭默认 memory 配置,最终没有 WxStoreConfigWxStoreService。请统一条件值、枚举绑定和 README 中的配置键。

AGENTS.md reference: AGENTS.md:L89-L90

Useful? React with 👍 / 👎.

Comment on lines +25 to +27
@JsonProperty("user_info")
@JacksonXmlProperty(localName = "order_info")
private UserInfo userInfo;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 将 XML 会员消息映射到 user_info

微信会员回调使用 XML 且包含 <user_info> 时,这里却从 <order_info> 读取,因此 UserInfoMessage.userInfo 会保持 null,手机号、等级和积分等数据全部丢失;同一字段的 @JsonProperty("user_info") 也确认了传输层名称。应把 JacksonXmlProperty.localName 改为 user_info 并增加 XML 回调回归测试。

AGENTS.md reference: AGENTS.md:L53-L54

Useful? React with 👍 / 👎.

Comment on lines +107 to +109
public Object route(final WxStoreMessage message, final String content, final String appId,
final WxStoreService service) {
return this.route(message, content, appId, new HashMap<>(2), service, new StandardSessionManager());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 复用默认消息会话管理器

通过常用的四参数 route 入口处理消息时,每次调用都会新建一个 StandardSessionManager,因此 handler 经 WxSessionManager 写入的会话数据在下一条回调到达前就会丢失,基于用户会话的多轮处理无法工作。应像 MP/MiniApp 路由器一样把默认 session manager 保存为路由器字段并跨调用复用,同时保留显式传入自定义 manager 的重载。

Useful? React with 👍 / 👎.

Comment on lines +83 to +84
RequestExecutor<StoreImageResponse, String> executor = StoreMediaDownloadRequestExecutor.create(shopService,
Files.createTempDirectory("wxjava-channel-" + appId).toFile());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 避免媒体下载长期占用临时磁盘

每次调用 getImg 都创建一个新的临时目录,下载文件仅通过 deleteOnExit 延迟到 JVM 退出时删除,而该目录本身从未清理;在长期运行且频繁下载图片的服务中,文件和目录会持续累积并可能耗尽磁盘或 inode。应复用受管理的临时目录,并为返回文件定义可执行的及时清理机制。

AGENTS.md reference: AGENTS.md:L107-L107

Useful? React with 👍 / 👎.

Comment on lines +47 to +48
this.executorService = new ThreadPoolExecutor(2, 100,
0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(), namedThreadFactory);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 为异步消息处理使用有界且可扩容的队列

默认所有路由规则都是异步的,但线程池使用 core size 2 和无界 LinkedBlockingQueue;该队列不会填满,所以执行器永远不会创建第 3 到第 100 个工作线程,突发或耗时回调只能由两个线程串行消化,并会在无界队列中持续积压任务和消息对象。应使用有界队列及明确拒绝策略,或将 core size 调整为实际期望的并发度。

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants