From 627cb2dc75a9a6d1e69e6529e3d12ccce55e9f6a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 14:19:38 +0000 Subject: [PATCH 1/3] Initial plan From 75ac8775370d5a58f1b5cfb7ce6674d4e05f8f8d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 31 May 2026 14:31:22 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E5=8F=B7=E5=B0=8F=E5=BA=97=E4=BB=A3=E5=8F=91=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E5=9F=BA=E7=A1=80=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/channel/api/WxChannelService.java | 7 + .../channel/api/WxChannelSupplierService.java | 60 +++++++++ .../api/impl/BaseWxChannelServiceImpl.java | 9 ++ .../impl/WxChannelSupplierServiceImpl.java | 120 ++++++++++++++++++ .../bean/supplier/DistributeTypeResponse.java | 25 ++++ .../bean/supplier/DropshipAssignRequest.java | 25 ++++ .../bean/supplier/DropshipDetailResponse.java | 22 ++++ .../channel/bean/supplier/DropshipInfo.java | 37 ++++++ .../bean/supplier/DropshipListRequest.java | 37 ++++++ .../bean/supplier/DropshipListResponse.java | 29 +++++ .../bean/supplier/DropshipResponse.java | 28 ++++ .../bean/supplier/DropshipSearchRequest.java | 26 ++++ .../supplier/ProductDistributeRequest.java | 26 ++++ .../bean/supplier/ProductListResponse.java | 42 ++++++ .../channel/bean/supplier/SupplierInfo.java | 28 ++++ .../bean/supplier/SupplierInfoResponse.java | 22 ++++ .../bean/supplier/SupplierListResponse.java | 29 +++++ .../constant/WxChannelApiUrlConstants.java | 28 ++++ .../supplier/WxChannelSupplierBeanTest.java | 50 ++++++++ 19 files changed, 650 insertions(+) create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipSearchRequest.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductDistributeRequest.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductListResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfo.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfoResponse.java create mode 100644 weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierListResponse.java create mode 100644 weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java index 50a029c196..ec139dd671 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java @@ -119,6 +119,13 @@ public interface WxChannelService extends BaseWxChannelService { */ WxLeagueWindowService getLeagueWindowService(); + /** + * 代发管理服务 + * + * @return 代发管理服务 + */ + WxChannelSupplierService getSupplierService(); + /** * 优选联盟-团长服务 * diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java new file mode 100644 index 0000000000..3b69db60ef --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java @@ -0,0 +1,60 @@ +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 GitHub Copilot + * @link 代发管理接口文档 + */ +public interface WxChannelSupplierService { + + /** 获取供货商列表。 */ + SupplierListResponse getSupplierList() 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; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java index 1a608e1f6a..a9bb5eb2b4 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java @@ -50,6 +50,7 @@ public abstract class BaseWxChannelServiceImpl implements WxChannelService private WxStoreHomePageService homePageService = null; private WxStoreCooperationService cooperationService = null; private WxChannelCompassShopService compassShopService = null; + private WxChannelSupplierService supplierService = null; private WxLeagueWindowService leagueWindowService = null; private WxLeagueSupplierService leagueSupplierService = null; private WxLeaguePromoterService leaguePromoterService = null; @@ -392,6 +393,14 @@ public synchronized WxChannelCompassShopService getCompassShopService() { return compassShopService; } + @Override + public synchronized WxChannelSupplierService getSupplierService() { + if (supplierService == null) { + supplierService = new WxChannelSupplierServiceImpl(this); + } + return supplierService; + } + @Override public synchronized WxLeagueWindowService getLeagueWindowService() { if (leagueWindowService == null) { diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java new file mode 100644 index 0000000000..b4739d335f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java @@ -0,0 +1,120 @@ +package me.chanjar.weixin.channel.api.impl; + +import lombok.extern.slf4j.Slf4j; +import me.chanjar.weixin.channel.api.WxChannelSupplierService; +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 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 GitHub Copilot + */ +@Slf4j +public class WxChannelSupplierServiceImpl implements WxChannelSupplierService { + + private final BaseWxChannelServiceImpl shopService; + + public WxChannelSupplierServiceImpl(BaseWxChannelServiceImpl shopService) { + this.shopService = shopService; + } + + @Override + public SupplierListResponse getSupplierList() throws WxErrorException { + String respJson = shopService.post(GET_SUPPLIER_LIST_URL, "{}"); + 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 { + ProductDistributeRequest req = new ProductDistributeRequest(); + req.setSupplierId(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 { + String respJson = shopService.post(GET_PRODUCT_DEFAULT_DISTRIBUTE_URL, "{\"product_id\":\"" + productId + "\"}"); + return ResponseUtils.decode(respJson, SupplierInfoResponse.class); + } + + @Override + public ProductListResponse getProductList(String supplierId) throws WxErrorException { + String respJson = shopService.post(GET_PRODUCT_LIST_URL, "{\"supplier_id\":\"" + supplierId + "\"}"); + 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 { + String respJson = shopService.post(CANCEL_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}"); + return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); + } + + @Override + public DropshipDetailResponse getDropship(String orderId) throws WxErrorException { + String respJson = shopService.post(GET_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}"); + 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); + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java new file mode 100644 index 0000000000..3537892b12 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DistributeTypeResponse.java @@ -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 GitHub Copilot + */ +@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; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java new file mode 100644 index 0000000000..3fa3904a57 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipAssignRequest.java @@ -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 GitHub Copilot + */ +@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; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java new file mode 100644 index 0000000000..a2cd0f983e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipDetailResponse.java @@ -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 GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DropshipDetailResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = 5548774863400272707L; + + @JsonProperty("dropship_info") + private DropshipInfo dropshipInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java new file mode 100644 index 0000000000..2b90bd7a5f --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java @@ -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 GitHub Copilot + */ +@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("dropship_id") + private String dropshipId; + + @JsonProperty("status") + private Integer status; + + @JsonProperty("create_time") + private Long createTime; + + @JsonProperty("update_time") + private Long updateTime; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java new file mode 100644 index 0000000000..ad89ad7cd5 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListRequest.java @@ -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 GitHub Copilot + */ +@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; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListResponse.java new file mode 100644 index 0000000000..2665f8ef15 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipListResponse.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 代发单列表响应。 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DropshipListResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = -2850183412032417307L; + + @JsonProperty("dropship_list") + private List dropshipList; + + @JsonProperty("next_key") + private String nextKey; + + @JsonProperty("has_more") + private Boolean hasMore; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipResponse.java new file mode 100644 index 0000000000..65a529e865 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipResponse.java @@ -0,0 +1,28 @@ +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 GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class DropshipResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = 4376618566823584629L; + + @JsonProperty("order_id") + private String orderId; + + @JsonProperty("supplier_id") + private String supplierId; + + @JsonProperty("dropship_id") + private String dropshipId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipSearchRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipSearchRequest.java new file mode 100644 index 0000000000..c658a3c16d --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipSearchRequest.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +/** + * 代发单搜索请求。 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public class DropshipSearchRequest extends DropshipListRequest { + private static final long serialVersionUID = 3915264648809784742L; + + @JsonProperty("order_id") + private String orderId; + + @JsonProperty("dropship_id") + private String dropshipId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductDistributeRequest.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductDistributeRequest.java new file mode 100644 index 0000000000..c1018d2255 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductDistributeRequest.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 按商品自动分配请求。 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class ProductDistributeRequest implements Serializable { + private static final long serialVersionUID = 4201609097231290078L; + + @JsonProperty("supplier_id") + private String supplierId; + + @JsonProperty("product_id_list") + private List productIdList; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductListResponse.java new file mode 100644 index 0000000000..f585ab0969 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/ProductListResponse.java @@ -0,0 +1,42 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 按商品自动分配商品列表响应。 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ProductListResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = -7096250227033388295L; + + @JsonProperty("product_list") + private List productList; + + @JsonProperty("next_key") + private String nextKey; + + @JsonProperty("has_more") + private Boolean hasMore; + + @Data + @NoArgsConstructor + public static class ProductInfo implements Serializable { + private static final long serialVersionUID = -4482299212575966325L; + + @JsonProperty("product_id") + private String productId; + + @JsonProperty("supplier_id") + private String supplierId; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfo.java new file mode 100644 index 0000000000..0944107c19 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfo.java @@ -0,0 +1,28 @@ +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 GitHub Copilot + */ +@Data +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +public class SupplierInfo implements Serializable { + private static final long serialVersionUID = -6480813119738259476L; + + @JsonProperty("supplier_id") + private String supplierId; + + @JsonProperty("supplier_name") + private String supplierName; + + @JsonProperty("status") + private Integer status; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfoResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfoResponse.java new file mode 100644 index 0000000000..7f138a5929 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierInfoResponse.java @@ -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 GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SupplierInfoResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = -3071464065836573893L; + + @JsonProperty("supplier_info") + private SupplierInfo supplierInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierListResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierListResponse.java new file mode 100644 index 0000000000..6bab0615a7 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/SupplierListResponse.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 供货商列表响应。 + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class SupplierListResponse extends WxChannelBaseResponse { + private static final long serialVersionUID = -692609589633695295L; + + @JsonProperty("supplier_list") + private List supplierList; + + @JsonProperty("next_key") + private String nextKey; + + @JsonProperty("has_more") + private Boolean hasMore; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java index 6c2076d85b..a9d2e6ec6a 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/constant/WxChannelApiUrlConstants.java @@ -429,6 +429,34 @@ public interface League { String GET_LEAGUE_ITEM_LIST_URL = "https://api.weixin.qq.com/channels/ec/league/item/list/get"; } + /** 代发管理相关接口 */ + public interface Supplier { + /** 获取供货商列表 */ + String GET_SUPPLIER_LIST_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/get_supplier_list"; + /** 获取分配方式 */ + String GET_DISTRIBUTE_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/get_distribute"; + /** 设置全店订单手动分配 */ + String SET_MANUALLY_DISTRIBUTE_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/set_manually_distribute"; + /** 设置全店订单自动分配 */ + String SET_ALL_DISTRIBUTION_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/set_all_distribution"; + /** 设置按商品自动分配 */ + String SET_PRODUCT_DISTRIBUTE_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/set_product_distribute"; + /** 获取商品对应的自动分配供货商 */ + String GET_PRODUCT_DEFAULT_DISTRIBUTE_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/get_product_default_distribute"; + /** 获取按商品自动分配的商品列表 */ + String GET_PRODUCT_LIST_URL = "https://api.weixin.qq.com/channels/ec/supplier/relation/get_product_list"; + /** 分配订单代发 */ + String ASSIGN_DROPSHIP_URL = "https://api.weixin.qq.com/channels/ec/order/dropship/assign"; + /** 取消分配代发单 */ + String CANCEL_DROPSHIP_URL = "https://api.weixin.qq.com/channels/ec/order/dropship/cancel"; + /** 查询代发单详情 */ + String GET_DROPSHIP_URL = "https://api.weixin.qq.com/channels/ec/order/dropship/get"; + /** 拉取代发单列表 */ + String GET_DROPSHIP_LIST_URL = "https://api.weixin.qq.com/channels/ec/order/dropship/list"; + /** 搜索代发单 */ + String SEARCH_DROPSHIP_URL = "https://api.weixin.qq.com/channels/ec/order/dropship/search"; + } + /** 视频号助手开放接口 */ public interface Assistant { diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java new file mode 100644 index 0000000000..e382d519f9 --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java @@ -0,0 +1,50 @@ +package me.chanjar.weixin.channel.bean.supplier; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertNotNull; + +import java.util.Arrays; +import me.chanjar.weixin.channel.util.JsonUtils; +import org.testng.annotations.Test; + +/** + * @author GitHub Copilot + */ +public class WxChannelSupplierBeanTest { + + @Test + public void testEncodeProductDistributeRequest() { + ProductDistributeRequest request = new ProductDistributeRequest(); + request.setSupplierId("1001"); + request.setProductIdList(Arrays.asList("p1", "p2")); + + String json = JsonUtils.encode(request); + assertNotNull(json); + assertFalse(json.contains("supplierId")); + assertFalse(json.contains("productIdList")); + assertEquals(json, "{\"supplier_id\":\"1001\",\"product_id_list\":[\"p1\",\"p2\"]}"); + } + + @Test + public void testEncodeDropshipAssignRequest() { + DropshipAssignRequest request = new DropshipAssignRequest(); + request.setOrderId("o1"); + request.setSupplierId("s1"); + + String json = JsonUtils.encode(request); + assertNotNull(json); + assertEquals(json, "{\"order_id\":\"o1\",\"supplier_id\":\"s1\"}"); + } + + @Test + public void testDecodeSupplierListResponse() { + String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"supplier_list\":[{\"supplier_id\":\"s1\",\"supplier_name\":\"供货商1\",\"status\":1}],\"has_more\":false}"; + SupplierListResponse response = JsonUtils.decode(json, SupplierListResponse.class); + + assertNotNull(response); + assertEquals(response.getErrCode(), 0); + assertEquals(response.getSupplierList().size(), 1); + assertEquals(response.getSupplierList().get(0).getSupplierId(), "s1"); + } +} From 8dc1e2065728ffe0db6b17c4a2d1b30733d75616 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Sat, 18 Jul 2026 16:42:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E4=BB=A3=E5=8F=91?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/api/WxChannelSupplierService.java | 12 ++++++++- .../impl/WxChannelSupplierServiceImpl.java | 26 ++++++++++++++----- .../channel/bean/supplier/DropshipInfo.java | 2 +- .../supplier/WxChannelSupplierBeanTest.java | 16 ++++++++++-- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java index 3b69db60ef..35e46b6dca 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelSupplierService.java @@ -18,13 +18,23 @@ * 视频号小店代发管理服务。 * * @author GitHub Copilot - * @link 代发管理接口文档 + * @see 代发管理接口文档 */ 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; diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java index b4739d335f..451aebc8a0 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelSupplierServiceImpl.java @@ -1,7 +1,9 @@ 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; @@ -16,6 +18,7 @@ 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; @@ -46,7 +49,13 @@ public WxChannelSupplierServiceImpl(BaseWxChannelServiceImpl shopService) @Override public SupplierListResponse getSupplierList() throws WxErrorException { - String respJson = shopService.post(GET_SUPPLIER_LIST_URL, "{}"); + 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); } @@ -64,8 +73,7 @@ public WxChannelBaseResponse setManuallyDistribute() throws WxErrorException { @Override public WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException { - ProductDistributeRequest req = new ProductDistributeRequest(); - req.setSupplierId(supplierId); + JsonObject req = GsonHelper.buildJsonObject("supplier_id", supplierId); String respJson = shopService.post(SET_ALL_DISTRIBUTION_URL, req); return ResponseUtils.decode(respJson, WxChannelBaseResponse.class); } @@ -78,13 +86,15 @@ public WxChannelBaseResponse setProductDistribute(ProductDistributeRequest req) @Override public SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException { - String respJson = shopService.post(GET_PRODUCT_DEFAULT_DISTRIBUTE_URL, "{\"product_id\":\"" + productId + "\"}"); + 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 { - String respJson = shopService.post(GET_PRODUCT_LIST_URL, "{\"supplier_id\":\"" + supplierId + "\"}"); + JsonObject req = GsonHelper.buildJsonObject("supplier_id", supplierId); + String respJson = shopService.post(GET_PRODUCT_LIST_URL, req); return ResponseUtils.decode(respJson, ProductListResponse.class); } @@ -96,13 +106,15 @@ public DropshipResponse assignOrder(DropshipAssignRequest req) throws WxErrorExc @Override public WxChannelBaseResponse cancelDropship(String orderId) throws WxErrorException { - String respJson = shopService.post(CANCEL_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}"); + 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 { - String respJson = shopService.post(GET_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}"); + JsonObject req = GsonHelper.buildJsonObject("order_id", orderId); + String respJson = shopService.post(GET_DROPSHIP_URL, req); return ResponseUtils.decode(respJson, DropshipDetailResponse.class); } diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java index 2b90bd7a5f..b2a0594073 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/supplier/DropshipInfo.java @@ -23,7 +23,7 @@ public class DropshipInfo implements Serializable { @JsonProperty("supplier_id") private String supplierId; - @JsonProperty("dropship_id") + @JsonProperty("ds_order_id") private String dropshipId; @JsonProperty("status") diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java index e382d519f9..2c562b8dbc 100644 --- a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/supplier/WxChannelSupplierBeanTest.java @@ -23,7 +23,9 @@ public void testEncodeProductDistributeRequest() { assertNotNull(json); assertFalse(json.contains("supplierId")); assertFalse(json.contains("productIdList")); - assertEquals(json, "{\"supplier_id\":\"1001\",\"product_id_list\":[\"p1\",\"p2\"]}"); + ProductDistributeRequest decoded = JsonUtils.decode(json, ProductDistributeRequest.class); + assertEquals(decoded.getSupplierId(), "1001"); + assertEquals(decoded.getProductIdList(), Arrays.asList("p1", "p2")); } @Test @@ -34,7 +36,9 @@ public void testEncodeDropshipAssignRequest() { String json = JsonUtils.encode(request); assertNotNull(json); - assertEquals(json, "{\"order_id\":\"o1\",\"supplier_id\":\"s1\"}"); + DropshipAssignRequest decoded = JsonUtils.decode(json, DropshipAssignRequest.class); + assertEquals(decoded.getOrderId(), "o1"); + assertEquals(decoded.getSupplierId(), "s1"); } @Test @@ -47,4 +51,12 @@ public void testDecodeSupplierListResponse() { assertEquals(response.getSupplierList().size(), 1); assertEquals(response.getSupplierList().get(0).getSupplierId(), "s1"); } + + @Test + public void testDecodeDropshipInfo() { + DropshipInfo info = JsonUtils.decode("{\"ds_order_id\":\"d1\"}", DropshipInfo.class); + + assertNotNull(info); + assertEquals(info.getDropshipId(), "d1"); + } }