Skip to content

feat(channel): 支持微信小店商家客服 API - #4105

Merged
binarywang merged 6 commits into
developfrom
feature/3991-channel-kf
Aug 22, 2026
Merged

feat(channel): 支持微信小店商家客服 API#4105
binarywang merged 6 commits into
developfrom
feature/3991-channel-kf

Conversation

@binarywang

Copy link
Copy Markdown
Owner

关联

Closes #3991

本 PR 替代 #4037

变更

  • 新增商家客服服务入口,支持媒体上传与客服消息发送。
  • 完整建模 text、image、video、file、product_share、order_share 六类消息。
  • 使用官方 commkf API 路径,并覆盖 multipart 字段、JSON 映射、响应解析和服务缓存。
  • 将离线 TestNG 回归测试纳入模块套件;新增设计与执行记录。

兼容性

  • 保持 Java 8 兼容,未新增依赖。
  • WxChannelService#getKfService() 为 default 方法,避免破坏既有自定义实现。

验证

  • mvn -pl weixin-java-channel -am test(构建成功;父 POM 配置使 Surefire 跳过测试)
  • TestNG 模块套件:26 passed, 0 failed, 0 skipped
  • git diff --check github/develop...HEAD

@augmentcode

augmentcode Bot commented Aug 22, 2026

Copy link
Copy Markdown
🤖 Augment PR Summary

摘要:本 PR 为 weixin-java-channel 增加微信小店商家客服 API 支持。

变更:

  • 新增 WxChannelKfService 及其实现,并通过 WxChannelService#getKfService() 暴露入口。
  • 新增客服媒体上传和消息发送的官方 commkf URL 常量。
  • 上传接口通过 multipart 传递 fileopen_idmsg_type
  • 新增 text、image、video、file、product_share、order_share 六类消息请求模型。
  • 新增上传响应的 cos_url 与发送响应的 msg_id 映射。
  • 服务入口采用懒加载缓存,接口方法使用 Java 8 default 方法以兼容既有自定义实现。
  • 新增 TestNG 测试,覆盖 JSON 编解码、服务 URL、表单字段、响应解析及服务缓存。
  • 将新增测试类登记到频道模块的 testng.xml 套件。
  • 补充了本次实现的设计、计划和测试执行记录。
技术说明:实现复用频道模块既有 JSON、响应解码、鉴权和通用 multipart 上传机制,未新增依赖。

🤖 Was this summary useful? React with 👍 or 👎

@augmentcode augmentcode 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.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

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

上传流不可重放,重试可能发送空媒体;请修复并增加回归测试。

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

Pull request overview

weixin-java-channel 新增微信小店商家客服 API,支持媒体上传、消息发送及六类消息模型。

Changes:

  • 新增客服服务入口、API 实现及官方接口常量。
  • 增加请求/响应模型、JSON 映射和 multipart 上传。
  • 纳入 TestNG 回归测试,并补充设计与执行记录。

Review finding: WxChannelKfServiceImpl.java 存在中等问题(2 votes):重试会复用已消费并关闭的上传流,需改为可重放上传并补充回归测试。

File summaries
File Description
weixin-java-channel/src/test/resources/testng.xml 纳入客服测试套件
weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/kf/WxChannelKfBeanTest.java 测试客服消息模型 JSON 映射
weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelKfServiceImplTest.java 测试服务调用与缓存
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java 新增客服 API 地址
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/kf/WxChannelKfSendMsgResponse.java 新增发送响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/kf/WxChannelKfSendMsgParam.java 新增六类消息请求模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/kf/WxChannelKfCosUploadResponse.java 新增上传响应模型
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java 暴露客服服务入口
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelKfService.java 定义客服 API
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelKfServiceImpl.java 实现媒体上传与消息发送
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java 缓存客服服务实例
docs/superpowers/specs/2026-08-22-channel-merchant-kf-design.md 记录 API 设计
docs/superpowers/plans/2026-08-22-channel-merchant-kf.md 记录实现计划
.superpowers/sdd/task-2-report.md 记录服务实现与验证
.superpowers/sdd/task-1-report.md 记录模型实现与验证
Review details

Suppressed comments (1)

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelKfServiceImpl.java:39

  • 该调用会进入 BaseWxChannelServiceImpl.executeInternal,默认在 DEBUG 日志中记录完整请求;DataUtils 仅脱敏 openid,不会脱敏本请求使用的 open_id,客服文本及商品/订单标识也会随请求体输出。请让客服消息请求使用安全的日志策略或扩展统一脱敏逻辑。
    String responseJson = channelService.post(SEND_MSG_URL, param);
  • Files reviewed: 15/15 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

@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: 23046bae60

ℹ️ 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".

Comment thread .superpowers/sdd/task-1-report.md Outdated
@binarywang
binarywang force-pushed the feature/3991-channel-kf branch from 4b0d569 to 939bb14 Compare August 22, 2026 12:46
@binarywang
binarywang merged commit 0122878 into develop Aug 22, 2026
1 check passed
@binarywang
binarywang deleted the feature/3991-channel-kf branch August 22, 2026 12:56
@binarywang binarywang added this to the 4.8.6 milestone Aug 22, 2026
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.

[Feature] 新增商家客服模块支持

2 participants