Skip to content

feat(channel): 新增视频号小店商家客服 API(cosupload/sendmsg)#4037

Open
Copilot wants to merge 2 commits into
developfrom
copilot/add-kf-service-module
Open

feat(channel): 新增视频号小店商家客服 API(cosupload/sendmsg)#4037
Copilot wants to merge 2 commits into
developfrom
copilot/add-kf-service-module

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

当前 weixin-java-channel 缺少商家客服能力,无法覆盖微信小店官方文档中的两项基础接口:上传多媒体资源与发送客服消息。该变更补齐服务入口、请求/响应模型与 API 常量,实现对 cosuploadsendmsg 的标准化调用。

  • 变更概览

    • 新增商家客服服务接口 WxChannelKfService 与实现 WxChannelKfServiceImpl
    • WxChannelService / BaseWxChannelServiceImpl 中接入 getKfService(),保持与现有子服务一致的使用方式
    • 新增商家客服 API 常量:
      • https://api.weixin.qq.com/channels/ec/commkf/cosupload
      • https://api.weixin.qq.com/channels/ec/commkf/sendmsg
  • 请求与响应模型

    • 新增上传响应模型:WxChannelKfCosUploadResponsecos_url
    • 新增发送消息请求模型:WxChannelKfSendMsgParam
      • 支持官方定义消息体:text / image / video / file / product_share / order_share
      • 映射官方字段:request_idopen_idmsg_type
    • 新增发送消息响应模型:WxChannelKfSendMsgResponsemsg_id
  • 接口设计要点

    • 上传接口提供字节数组重载,内部统一走 multipart 上传,并附带 open_idmsg_type 表单字段
    • 发送接口直接接收结构化参数对象,避免 Object content 的弱类型与字段漂移风险
WxChannelKfService kfService = wxChannelService.getKfService();

String cosUrl = kfService.uploadMedia(openId, "image", "img.jpg", imageBytes);

WxChannelKfSendMsgParam param = new WxChannelKfSendMsgParam();
param.setOpenId(openId);
param.setMsgType("image");
param.setImage(new WxChannelKfSendMsgParam.CosUrlMessage(cosUrl));

WxChannelKfSendMsgResponse resp = kfService.sendMessage(param);
String msgId = resp.getMsgId();

Copilot AI changed the title [WIP] Add merchant customer service module support feat(channel): 新增视频号小店商家客服 API(cosupload/sendmsg) Jun 1, 2026
@binarywang binarywang marked this pull request as ready for review June 1, 2026 01:55
Copilot AI review requested due to automatic review settings June 1, 2026 01:55
Copy link
Copy Markdown

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

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: c7e4e8b03a

ℹ️ 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 on lines +224 to +226
String COS_UPLOAD_URL = "https://api.weixin.qq.com/channels/ec/commkf/cosupload";
/** 发送消息 */
String SEND_MSG_URL = "https://api.weixin.qq.com/channels/ec/commkf/sendmsg";
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 Use the documented KF endpoints

When clients call either new KF method, these constants send the request to /channels/ec/commkf/..., but the WeChat store KF APIs are exposed under /channels/ec/kf/cosupload and /channels/ec/kf/sendmsg. As written, both upload and send-message calls are routed to the wrong API path and will fail before the new request/response models can be used.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

该 PR 为 weixin-java-channel 新增视频号小店商家客服能力,补齐多媒体上传与客服消息发送两个基础 API 的服务入口、模型与常量。

Changes:

  • 新增商家客服服务接口及实现,并接入 WxChannelService#getKfService()
  • 新增 cosupload / sendmsg API 常量及对应请求、响应模型。
  • 新增 Bean 序列化与反序列化测试,覆盖客服消息参数和响应字段映射。

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.

Show a summary per file
File Description
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java 新增商家客服相关 API 地址常量。
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 定义上传媒体与发送客服消息接口。
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java 懒加载并返回客服服务实现。
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelKfServiceImpl.java 实现 multipart 上传与消息发送调用。
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/bean/kf/WxChannelKfSendMsgResponse.java 新增发送消息响应模型。
weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/kf/WxChannelKfBeanTest.java 新增客服相关 Bean JSON 映射测试。

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] 新增商家客服模块支持

3 participants