-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
新增微信小店代发管理模块:Supplier 关联、自动分配与 Dropship 单据接口支持 #4031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
binarywang
merged 3 commits into
develop
from
copilot/fix-1343140-49122742-9a4504fb-0040-486e-93ce-33f73309afba
Jul 18, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...in-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| package me.chanjar.weixin.channel.api; | ||
|
|
||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DistributeTypeResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipAssignRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipDetailResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipListRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipListResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipSearchRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.ProductDistributeRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.ProductListResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.SupplierInfoResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.SupplierListResponse; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
|
|
||
| /** | ||
| * 视频号小店代发管理服务。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| * @see <a href="https://developers.weixin.qq.com/doc/channels/API/supplier/">代发管理接口文档</a> | ||
| */ | ||
| public interface WxChannelSupplierService { | ||
|
|
||
| /** 获取供货商列表。 */ | ||
| SupplierListResponse getSupplierList() throws WxErrorException; | ||
|
|
||
| /** | ||
| * 获取供货商列表。 | ||
| * | ||
| * @param pageSize 每页数量 | ||
| * @param nextKey 由上次请求返回,记录翻页的上下文。传入时会从上次返回的结果往后翻一页 | ||
| * @return 供货商列表响应 | ||
| * @throws WxErrorException 异常 | ||
| */ | ||
| SupplierListResponse getSupplierList(Integer pageSize, String nextKey) throws WxErrorException; | ||
|
|
||
| /** 获取分配方式。 */ | ||
| DistributeTypeResponse getDistribute() throws WxErrorException; | ||
|
|
||
| /** 设置全店订单手动分配。 */ | ||
| WxChannelBaseResponse setManuallyDistribute() throws WxErrorException; | ||
|
|
||
| /** 设置全店订单自动分配。 */ | ||
| WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException; | ||
|
|
||
| /** 设置按商品自动分配。 */ | ||
| WxChannelBaseResponse setProductDistribute(ProductDistributeRequest req) throws WxErrorException; | ||
|
|
||
| /** 获取商品对应的自动分配供货商。 */ | ||
| SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException; | ||
|
|
||
| /** 获取按商品自动分配的商品列表。 */ | ||
| ProductListResponse getProductList(String supplierId) throws WxErrorException; | ||
|
|
||
| /** 分配订单代发。 */ | ||
| DropshipResponse assignOrder(DropshipAssignRequest req) throws WxErrorException; | ||
|
|
||
| /** 取消分配代发单。 */ | ||
| WxChannelBaseResponse cancelDropship(String orderId) throws WxErrorException; | ||
|
|
||
| /** 查询代发单详情。 */ | ||
| DropshipDetailResponse getDropship(String orderId) throws WxErrorException; | ||
|
|
||
| /** 拉取代发单列表。 */ | ||
| DropshipListResponse listDropship(DropshipListRequest req) throws WxErrorException; | ||
|
|
||
| /** 搜索代发单。 */ | ||
| DropshipListResponse searchDropship(DropshipSearchRequest req) throws WxErrorException; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 132 additions & 0 deletions
132
...hannel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| package me.chanjar.weixin.channel.api.impl; | ||
|
|
||
| import com.google.gson.JsonObject; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import me.chanjar.weixin.channel.api.WxChannelSupplierService; | ||
| import me.chanjar.weixin.channel.bean.base.StreamPageParam; | ||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DistributeTypeResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipAssignRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipDetailResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipListRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipListResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.DropshipSearchRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.ProductDistributeRequest; | ||
| import me.chanjar.weixin.channel.bean.supplier.ProductListResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.SupplierInfoResponse; | ||
| import me.chanjar.weixin.channel.bean.supplier.SupplierListResponse; | ||
| import me.chanjar.weixin.channel.util.ResponseUtils; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
| import me.chanjar.weixin.common.util.json.GsonHelper; | ||
|
|
||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.ASSIGN_DROPSHIP_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.CANCEL_DROPSHIP_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DISTRIBUTE_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DROPSHIP_LIST_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DROPSHIP_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_PRODUCT_DEFAULT_DISTRIBUTE_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_PRODUCT_LIST_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_SUPPLIER_LIST_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SEARCH_DROPSHIP_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_ALL_DISTRIBUTION_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_MANUALLY_DISTRIBUTE_URL; | ||
| import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_PRODUCT_DISTRIBUTE_URL; | ||
|
|
||
| /** | ||
| * 视频号小店代发管理服务。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Slf4j | ||
| public class WxChannelSupplierServiceImpl implements WxChannelSupplierService { | ||
|
|
||
| private final BaseWxChannelServiceImpl<?, ?> shopService; | ||
|
|
||
| public WxChannelSupplierServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) { | ||
| this.shopService = shopService; | ||
| } | ||
|
|
||
| @Override | ||
| public SupplierListResponse getSupplierList() throws WxErrorException { | ||
| return getSupplierList(null, null); | ||
| } | ||
|
|
||
| @Override | ||
| public SupplierListResponse getSupplierList(Integer pageSize, String nextKey) throws WxErrorException { | ||
| StreamPageParam param = new StreamPageParam(pageSize, nextKey); | ||
| String respJson = shopService.post(GET_SUPPLIER_LIST_URL, param); | ||
| return ResponseUtils.decode(respJson, SupplierListResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public DistributeTypeResponse getDistribute() throws WxErrorException { | ||
| String respJson = shopService.post(GET_DISTRIBUTE_URL, "{}"); | ||
| return ResponseUtils.decode(respJson, DistributeTypeResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public WxChannelBaseResponse setManuallyDistribute() throws WxErrorException { | ||
| String respJson = shopService.post(SET_MANUALLY_DISTRIBUTE_URL, "{}"); | ||
| return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException { | ||
| JsonObject req = GsonHelper.buildJsonObject("supplier_id", supplierId); | ||
| String respJson = shopService.post(SET_ALL_DISTRIBUTION_URL, req); | ||
| return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public WxChannelBaseResponse setProductDistribute(ProductDistributeRequest req) throws WxErrorException { | ||
| String respJson = shopService.post(SET_PRODUCT_DISTRIBUTE_URL, req); | ||
| return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException { | ||
| JsonObject req = GsonHelper.buildJsonObject("product_id", productId); | ||
| String respJson = shopService.post(GET_PRODUCT_DEFAULT_DISTRIBUTE_URL, req); | ||
| return ResponseUtils.decode(respJson, SupplierInfoResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public ProductListResponse getProductList(String supplierId) throws WxErrorException { | ||
| JsonObject req = GsonHelper.buildJsonObject("supplier_id", supplierId); | ||
| String respJson = shopService.post(GET_PRODUCT_LIST_URL, req); | ||
| return ResponseUtils.decode(respJson, ProductListResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public DropshipResponse assignOrder(DropshipAssignRequest req) throws WxErrorException { | ||
| String respJson = shopService.post(ASSIGN_DROPSHIP_URL, req); | ||
| return ResponseUtils.decode(respJson, DropshipResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public WxChannelBaseResponse cancelDropship(String orderId) throws WxErrorException { | ||
| JsonObject req = GsonHelper.buildJsonObject("order_id", orderId); | ||
| String respJson = shopService.post(CANCEL_DROPSHIP_URL, req); | ||
| return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public DropshipDetailResponse getDropship(String orderId) throws WxErrorException { | ||
| JsonObject req = GsonHelper.buildJsonObject("order_id", orderId); | ||
| String respJson = shopService.post(GET_DROPSHIP_URL, req); | ||
| return ResponseUtils.decode(respJson, DropshipDetailResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public DropshipListResponse listDropship(DropshipListRequest req) throws WxErrorException { | ||
| String respJson = shopService.post(GET_DROPSHIP_LIST_URL, req); | ||
| return ResponseUtils.decode(respJson, DropshipListResponse.class); | ||
| } | ||
|
|
||
| @Override | ||
| public DropshipListResponse searchDropship(DropshipSearchRequest req) throws WxErrorException { | ||
| String respJson = shopService.post(SEARCH_DROPSHIP_URL, req); | ||
| return ResponseUtils.decode(respJson, DropshipListResponse.class); | ||
| } | ||
| } | ||
25 changes: 25 additions & 0 deletions
25
...channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package me.chanjar.weixin.channel.bean.supplier; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
|
|
||
| /** | ||
| * 分配方式响应。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @EqualsAndHashCode(callSuper = true) | ||
| public class DistributeTypeResponse extends WxChannelBaseResponse { | ||
| private static final long serialVersionUID = -750860556286328053L; | ||
|
|
||
| @JsonProperty("distribute_type") | ||
| private Integer distributeType; | ||
|
|
||
| @JsonProperty("supplier_info") | ||
| private SupplierInfo supplierInfo; | ||
| } |
25 changes: 25 additions & 0 deletions
25
...-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| package me.chanjar.weixin.channel.bean.supplier; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.io.Serializable; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * 代发单分配请求。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class DropshipAssignRequest implements Serializable { | ||
| private static final long serialVersionUID = 6945436332042017565L; | ||
|
|
||
| @JsonProperty("order_id") | ||
| private String orderId; | ||
|
|
||
| @JsonProperty("supplier_id") | ||
| private String supplierId; | ||
| } |
22 changes: 22 additions & 0 deletions
22
...channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package me.chanjar.weixin.channel.bean.supplier; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import lombok.Data; | ||
| import lombok.EqualsAndHashCode; | ||
| import lombok.NoArgsConstructor; | ||
| import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; | ||
|
|
||
| /** | ||
| * 代发单详情响应。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @EqualsAndHashCode(callSuper = true) | ||
| public class DropshipDetailResponse extends WxChannelBaseResponse { | ||
| private static final long serialVersionUID = 5548774863400272707L; | ||
|
|
||
| @JsonProperty("dropship_info") | ||
| private DropshipInfo dropshipInfo; | ||
| } |
37 changes: 37 additions & 0 deletions
37
weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package me.chanjar.weixin.channel.bean.supplier; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.io.Serializable; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * 代发单信息。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class DropshipInfo implements Serializable { | ||
| private static final long serialVersionUID = -7880364210849039278L; | ||
|
|
||
| @JsonProperty("order_id") | ||
| private String orderId; | ||
|
|
||
| @JsonProperty("supplier_id") | ||
| private String supplierId; | ||
|
|
||
| @JsonProperty("ds_order_id") | ||
| private String dropshipId; | ||
|
|
||
| @JsonProperty("status") | ||
| private Integer status; | ||
|
|
||
| @JsonProperty("create_time") | ||
| private Long createTime; | ||
|
|
||
| @JsonProperty("update_time") | ||
| private Long updateTime; | ||
| } |
37 changes: 37 additions & 0 deletions
37
...va-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package me.chanjar.weixin.channel.bean.supplier; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonInclude; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import java.io.Serializable; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| /** | ||
| * 代发单列表请求。 | ||
| * | ||
| * @author <a href="https://github.com/github-copilot">GitHub Copilot</a> | ||
| */ | ||
| @Data | ||
| @NoArgsConstructor | ||
| @JsonInclude(JsonInclude.Include.NON_NULL) | ||
| public class DropshipListRequest implements Serializable { | ||
| private static final long serialVersionUID = 2638071229335192596L; | ||
|
|
||
| @JsonProperty("supplier_id") | ||
| private String supplierId; | ||
|
|
||
| @JsonProperty("status") | ||
| private Integer status; | ||
|
|
||
| @JsonProperty("create_time_start") | ||
| private Long createTimeStart; | ||
|
|
||
| @JsonProperty("create_time_end") | ||
| private Long createTimeEnd; | ||
|
|
||
| @JsonProperty("page_size") | ||
| private Integer pageSize; | ||
|
|
||
| @JsonProperty("next_key") | ||
| private String nextKey; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.