Skip to content

feat(channel): 新增微信小店电子面单服务模块与16个官方接口接入#4036

Open
Copilot wants to merge 2 commits into
developfrom
copilot/feature-add-ewaybill-module-support
Open

feat(channel): 新增微信小店电子面单服务模块与16个官方接口接入#4036
Copilot wants to merge 2 commits into
developfrom
copilot/feature-add-ewaybill-module-support

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 31, 2026

当前 weixin-java-channel 缺少电子面单能力,无法覆盖模板管理、账号查询、面单取号、子件追加与打印回传等完整链路。该变更按微信小店官方电子面单文档接入 16 个服务端接口,并统一纳入 WxChannelService 能力域。

  • 服务层接入(API 能力暴露)

    • 新增 WxChannelEwaybillService 接口与 WxChannelEwaybillServiceImpl 实现。
    • WxChannelService 增加 getEwaybillService()
    • BaseWxChannelServiceImpl 中完成 Ewaybill 服务懒加载接入,保持与现有模块一致的获取方式。
  • 官方接口常量补全(16个)

    • WxChannelApiUrlConstants 新增 Ewaybill 常量分组。
    • 覆盖模板、账号、订单、打印四类接口:template/*account/getdelivery/getorder/*print/get
  • 数据模型与参数封装

    • 新增电子面单请求/响应模型包 bean.ewaybill
    • 对模板ID、运单ID、批量运单ID提供明确参数对象(TemplateIdParamWaybillIdParamWaybillIdsParam)。
    • 对文档中结构复杂且易演进的字段采用动态参数容器(AbstractEwaybillRequest / AbstractEwaybillResponse),保证“按官方字段透传”与向后兼容。
  • 单元测试补充

    • 新增 WxChannelEwaybillBeanTest:覆盖关键参数序列化与动态响应反序列化。
    • 新增 WxChannelEwaybillServiceAccessorTest:覆盖服务入口可用性(getEwaybillService())。

示例(新增服务调用):

WxChannelEwaybillService ewaybillService = channelService.getEwaybillService();

TemplateCreateRequest req = new TemplateCreateRequest();
req.addParam("delivery_id", "YTO");
req.addParam("template_name", "默认面单模板");

TemplateIdResponse resp = ewaybillService.createTemplate(req);

Copilot AI changed the title [WIP] Add support for ewaybill module feat(channel): 新增微信小店电子面单服务模块与16个官方接口接入 Jun 1, 2026
@binarywang binarywang marked this pull request as ready for review June 1, 2026 02:19
Copilot AI review requested due to automatic review settings June 1, 2026 02:19
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: 89da6f1782

ℹ️ 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 static final long serialVersionUID = 4213577159985597237L;

private Map<String, Object> params = new LinkedHashMap<>();
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 Avoid serializing the params backing map

When any dynamic ewaybill request is populated with addParam, Lombok's @Data also exposes this field as getParams(), while @JsonAnyGetter emits the same entries at the top level. The actual POST body therefore includes both the documented fields and an extra params object (for example {"params":{"order_id":"o_1"},"order_id":"o_1"}), which the new API wrappers send to WeChat and can be rejected as an invalid request; the test only checks that the top-level substrings exist. Please hide this backing map from Jackson or avoid generating a public getter for it.

Useful? React with 👍 / 👎.


@Override
public TemplateInfoResponse getTemplate(String templateId) throws WxErrorException {
String resJson = shopService.post(GET_TEMPLATE_URL, new TemplateIdParam(templateId));
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 template_code for template lookup

For the .../biz/template/get endpoint, the request parameter is the standard template code, while template_id is used by the separate getbyid endpoint below. As written, callers of getTemplate(...) will always post {"template_id":...} to the code-based endpoint, so looking up a standard template returned by getTemplateConfig() fails even with a valid code.

Useful? React with 👍 / 👎.


@Override
public PrintContentResponse getPrintContent(String waybillId) throws WxErrorException {
String resJson = shopService.post(GET_PRINT_CONTENT_URL, new WaybillIdParam(waybillId));
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 Send waybill_ids when fetching print content

The print-content endpoint takes a list field named waybill_ids (and optional template_id), but this wrapper posts a single waybill_id. Any caller using getPrintContent(...) will therefore omit the required array parameter and be unable to retrieve print payloads; this needs a request object/list form matching the endpoint contract.

Useful? React with 👍 / 👎.

public class WaybillIdsParam implements Serializable {
private static final long serialVersionUID = -9030594599179993010L;

@JsonProperty("waybill_id_list")
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 Serialize batch IDs as waybill_ids

The batch print notification API expects the array field waybill_ids, but this shared parameter object serializes it as waybill_id_list. As a result, batchPrintOrder(...) sends a body with the wrong key and the server will treat the required list as missing for otherwise valid batches.

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 模块中新增微信小店电子面单(Ewaybill)能力,按官方文档接入 16 个服务端接口,并按现有 channel 模块的服务注册/懒加载约定纳入 WxChannelService

Changes:

  • 新增 WxChannelEwaybillService 接口与 WxChannelEwaybillServiceImpl 实现,在 WxChannelService / BaseWxChannelServiceImpl 中加入 getEwaybillService() 的懒加载接入。
  • WxChannelApiUrlConstants 增加 Ewaybill 常量分组,覆盖模板、账号/快递、订单、打印共 16 个 URL。
  • 新增 bean.ewaybill 包,包括动态参数容器 AbstractEwaybillRequest/AbstractEwaybillResponse、显式 ID 包装类(Template/Waybill)、以及各请求/响应子类,并补充序列化/服务入口测试。

Reviewed changes

Copilot reviewed 26 out of 26 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java 新增 getEwaybillService() 入口
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelEwaybillService.java 新增电子面单服务接口(16 方法)
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java 接入 ewaybill 服务的同步懒加载字段
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelEwaybillServiceImpl.java 实现 16 个接口,统一通过 shopService.post + ResponseUtils.decode
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java 新增 Ewaybill URL 常量分组
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/AbstractEwaybillRequest.java 动态参数请求基类(@JsonAnyGetter/Setter)—存在序列化双写问题
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/AbstractEwaybillResponse.java 动态参数响应基类,未匹配字段进 extra
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/TemplateIdParam.java 模板 ID 参数包装
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/TemplateIdResponse.java 显式声明 template_id 字段的响应
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/TemplateConfigResponse.java、TemplateInfoResponse.java、TemplateCreateRequest.java、TemplateUpdateRequest.java 模板相关请求/响应包装
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/AccountInfoResponse.java、DeliveryListResponse.java 账号/快递公司列表响应
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/PreCreateRequest.java、PreCreateResponse.java、CreateOrderRequest.java、CreateOrderResponse.java、AddSubOrderRequest.java、OrderDetailResponse.java 订单/子件相关请求与响应
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/PrintContentResponse.java 打印报文响应
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/ewaybill/WaybillIdParam.java、WaybillIdsParam.java 单/批量运单 ID 参数包装
weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/ewaybill/WxChannelEwaybillBeanTest.java 序列化/反序列化基础用例
weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelEwaybillServiceAccessorTest.java 服务入口可用性用例

Comment on lines +24 to +34
private Map<String, Object> params = new LinkedHashMap<>();

@JsonAnySetter
public void addParam(String key, Object value) {
params.put(key, value);
}

@JsonAnyGetter
public Map<String, Object> anyParams() {
return params;
}
Comment on lines +25 to +30
private Map<String, Object> extra = new LinkedHashMap<>();

@JsonAnySetter
public void addExtra(String key, Object value) {
extra.put(key, value);
}
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