新增微信小店代发管理模块:Supplier 关联、自动分配与 Dropship 单据接口支持#4031
Conversation
There was a problem hiding this comment.
Pull request overview
为 weixin-java-channel 模块新增了视频号小店"代发管理"能力,覆盖供货商关联、分配策略与代发单管理共 12 个接口,并补充服务入口、URL 常量、请求/响应模型以及关键序列化单测。
Changes:
- 新增
WxChannelSupplierService接口与实现,并在WxChannelService/BaseWxChannelServiceImpl中以懒加载方式暴露。 - 在
WxChannelApiUrlConstants增加Supplier分组的 12 条官方接口 URL 常量。 - 在
bean/supplier下新增供货商/代发单的请求与响应模型,并补充WxChannelSupplierBeanTest验证序列化契约。
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java | 暴露 getSupplierService() 入口 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java | 新增代发管理服务接口,定义 12 个方法 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java | 注册并懒加载 WxChannelSupplierServiceImpl |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java | 服务实现,调用各接口 URL |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java | 新增 Supplier URL 常量分组 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfo.java | 基础供货商实体 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfoResponse.java | 单个供货商响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierListResponse.java | 供货商列表分页响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductDistributeRequest.java | 按商品分配请求 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductListResponse.java | 商品分配列表响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java | 分配方式响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java | 代发单实体 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java | 代发单分配请求 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipResponse.java | 代发单分配响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java | 代发单详情响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java | 代发单列表请求 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListResponse.java | 代发单列表响应 |
| weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipSearchRequest.java | 代发单搜索请求(继承列表请求) |
| weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java | 关键序列化/反序列化单测 |
|
|
||
| @Override | ||
| public SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException { | ||
| String respJson = shopService.post(GET_PRODUCT_DEFAULT_DISTRIBUTE_URL, "{\"product_id\":\"" + productId + "\"}"); |
| public WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException { | ||
| ProductDistributeRequest req = new ProductDistributeRequest(); | ||
| req.setSupplierId(supplierId); | ||
| String respJson = shopService.post(SET_ALL_DISTRIBUTION_URL, req); | ||
| return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); | ||
| } |
| assertNotNull(json); | ||
| assertFalse(json.contains("supplierId")); | ||
| assertFalse(json.contains("productIdList")); | ||
| assertEquals(json, "{\"supplier_id\":\"1001\",\"product_id_list\":[\"p1\",\"p2\"]}"); |
| * 视频号小店代发管理服务。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| * @link <a href="https://developers.weixin.qq.com/doc/channels/API/supplier/">代发管理接口文档</a> |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75ac877537
ℹ️ 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".
| @JsonProperty("dropship_id") | ||
| private String dropshipId; |
There was a problem hiding this comment.
Map dropship order ids with the API field name
When deserializing real dropship records, this field will remain null because the WeChat shop order payload uses ds_order_id for the dropship order number (the existing me.chanjar.weixin.channel.bean.order.DropshipInfo model already maps that key), not dropship_id. This affects list/detail/assign responses that need to expose the returned dropship order id to callers.
Useful? React with 👍 / 👎.
| public SupplierListResponse getSupplierList() throws WxErrorException { | ||
| String respJson = shopService.post(GET_SUPPLIER_LIST_URL, "{}"); |
There was a problem hiding this comment.
Expose pagination parameters for supplier lists
When a merchant has more suppliers than the first page, callers cannot retrieve the next page: the response model exposes has_more/next_key, but this method always posts an empty body and the public API has no way to send the returned cursor (or page size). This makes the service silently unusable for complete supplier enumeration once has_more is true.
Useful? React with 👍 / 👎.
当前
weixin-java-channel缺少代发管理能力,无法覆盖商家与供货商关联、订单自动分配以及代发单管理场景。本 PR 基于官方代发管理文档,补齐 12 个接口在服务层、路由入口与数据模型层的支持。
服务入口与能力挂载
WxChannelSupplierService,定义 12 个代发管理接口方法(供货商列表、分配策略、代发单分配/取消/查询/列表/搜索)。WxChannelService暴露getSupplierService()。BaseWxChannelServiceImpl中完成WxChannelSupplierServiceImpl的懒加载接入。API 常量补齐(官方路径)
WxChannelApiUrlConstants新增Supplier分组,增加以下路径常量:/channels/ec/supplier/relation/get_supplier_list/channels/ec/supplier/relation/get_distribute/channels/ec/supplier/relation/set_manually_distribute/channels/ec/supplier/relation/set_all_distribution/channels/ec/supplier/relation/set_product_distribute/channels/ec/supplier/relation/get_product_default_distribute/channels/ec/supplier/relation/get_product_list/channels/ec/order/dropship/assign/channels/ec/order/dropship/cancel/channels/ec/order/dropship/get/channels/ec/order/dropship/list/channels/ec/order/dropship/search请求/响应模型新增
bean/supplier下请求与响应对象,覆盖:ProductDistributeRequest、DistributeTypeResponse、SupplierInfoResponse、ProductListResponseDropshipAssignRequest、DropshipResponse、DropshipDetailResponse、DropshipListRequest、DropshipSearchRequest、DropshipListResponseSupplierInfo、DropshipInfo@JsonProperty对齐接口 JSON 键(如supplier_id、product_id_list、dropship_list)。实现示例(服务调用形态)
单元测试补充
WxChannelSupplierBeanTest,覆盖新增模型的关键序列化/反序列化契约,确保请求体与响应映射可用。