Skip to content

Commit 75ac877

Browse files
authored
新增视频号小店代发管理模块基础能力
1 parent 627cb2d commit 75ac877

19 files changed

Lines changed: 650 additions & 0 deletions

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,13 @@ public interface WxChannelService extends BaseWxChannelService {
119119
*/
120120
WxLeagueWindowService getLeagueWindowService();
121121

122+
/**
123+
* 代发管理服务
124+
*
125+
* @return 代发管理服务
126+
*/
127+
WxChannelSupplierService getSupplierService();
128+
122129
/**
123130
* 优选联盟-团长服务
124131
*
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package me.chanjar.weixin.channel.api;
2+
3+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
4+
import me.chanjar.weixin.channel.bean.supplier.DistributeTypeResponse;
5+
import me.chanjar.weixin.channel.bean.supplier.DropshipAssignRequest;
6+
import me.chanjar.weixin.channel.bean.supplier.DropshipDetailResponse;
7+
import me.chanjar.weixin.channel.bean.supplier.DropshipListRequest;
8+
import me.chanjar.weixin.channel.bean.supplier.DropshipListResponse;
9+
import me.chanjar.weixin.channel.bean.supplier.DropshipResponse;
10+
import me.chanjar.weixin.channel.bean.supplier.DropshipSearchRequest;
11+
import me.chanjar.weixin.channel.bean.supplier.ProductDistributeRequest;
12+
import me.chanjar.weixin.channel.bean.supplier.ProductListResponse;
13+
import me.chanjar.weixin.channel.bean.supplier.SupplierInfoResponse;
14+
import me.chanjar.weixin.channel.bean.supplier.SupplierListResponse;
15+
import me.chanjar.weixin.common.error.WxErrorException;
16+
17+
/**
18+
* 视频号小店代发管理服务。
19+
*
20+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
21+
* @link <a href="https://developers.weixin.qq.com/doc/channels/API/supplier/">代发管理接口文档</a>
22+
*/
23+
public interface WxChannelSupplierService {
24+
25+
/** 获取供货商列表。 */
26+
SupplierListResponse getSupplierList() throws WxErrorException;
27+
28+
/** 获取分配方式。 */
29+
DistributeTypeResponse getDistribute() throws WxErrorException;
30+
31+
/** 设置全店订单手动分配。 */
32+
WxChannelBaseResponse setManuallyDistribute() throws WxErrorException;
33+
34+
/** 设置全店订单自动分配。 */
35+
WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException;
36+
37+
/** 设置按商品自动分配。 */
38+
WxChannelBaseResponse setProductDistribute(ProductDistributeRequest req) throws WxErrorException;
39+
40+
/** 获取商品对应的自动分配供货商。 */
41+
SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException;
42+
43+
/** 获取按商品自动分配的商品列表。 */
44+
ProductListResponse getProductList(String supplierId) throws WxErrorException;
45+
46+
/** 分配订单代发。 */
47+
DropshipResponse assignOrder(DropshipAssignRequest req) throws WxErrorException;
48+
49+
/** 取消分配代发单。 */
50+
WxChannelBaseResponse cancelDropship(String orderId) throws WxErrorException;
51+
52+
/** 查询代发单详情。 */
53+
DropshipDetailResponse getDropship(String orderId) throws WxErrorException;
54+
55+
/** 拉取代发单列表。 */
56+
DropshipListResponse listDropship(DropshipListRequest req) throws WxErrorException;
57+
58+
/** 搜索代发单。 */
59+
DropshipListResponse searchDropship(DropshipSearchRequest req) throws WxErrorException;
60+
}

weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/BaseWxChannelServiceImpl.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public abstract class BaseWxChannelServiceImpl<H, P> implements WxChannelService
5050
private WxStoreHomePageService homePageService = null;
5151
private WxStoreCooperationService cooperationService = null;
5252
private WxChannelCompassShopService compassShopService = null;
53+
private WxChannelSupplierService supplierService = null;
5354
private WxLeagueWindowService leagueWindowService = null;
5455
private WxLeagueSupplierService leagueSupplierService = null;
5556
private WxLeaguePromoterService leaguePromoterService = null;
@@ -392,6 +393,14 @@ public synchronized WxChannelCompassShopService getCompassShopService() {
392393
return compassShopService;
393394
}
394395

396+
@Override
397+
public synchronized WxChannelSupplierService getSupplierService() {
398+
if (supplierService == null) {
399+
supplierService = new WxChannelSupplierServiceImpl(this);
400+
}
401+
return supplierService;
402+
}
403+
395404
@Override
396405
public synchronized WxLeagueWindowService getLeagueWindowService() {
397406
if (leagueWindowService == null) {
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
package me.chanjar.weixin.channel.api.impl;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import me.chanjar.weixin.channel.api.WxChannelSupplierService;
5+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
6+
import me.chanjar.weixin.channel.bean.supplier.DistributeTypeResponse;
7+
import me.chanjar.weixin.channel.bean.supplier.DropshipAssignRequest;
8+
import me.chanjar.weixin.channel.bean.supplier.DropshipDetailResponse;
9+
import me.chanjar.weixin.channel.bean.supplier.DropshipListRequest;
10+
import me.chanjar.weixin.channel.bean.supplier.DropshipListResponse;
11+
import me.chanjar.weixin.channel.bean.supplier.DropshipResponse;
12+
import me.chanjar.weixin.channel.bean.supplier.DropshipSearchRequest;
13+
import me.chanjar.weixin.channel.bean.supplier.ProductDistributeRequest;
14+
import me.chanjar.weixin.channel.bean.supplier.ProductListResponse;
15+
import me.chanjar.weixin.channel.bean.supplier.SupplierInfoResponse;
16+
import me.chanjar.weixin.channel.bean.supplier.SupplierListResponse;
17+
import me.chanjar.weixin.channel.util.ResponseUtils;
18+
import me.chanjar.weixin.common.error.WxErrorException;
19+
20+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.ASSIGN_DROPSHIP_URL;
21+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.CANCEL_DROPSHIP_URL;
22+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DISTRIBUTE_URL;
23+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DROPSHIP_LIST_URL;
24+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_DROPSHIP_URL;
25+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_PRODUCT_DEFAULT_DISTRIBUTE_URL;
26+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_PRODUCT_LIST_URL;
27+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.GET_SUPPLIER_LIST_URL;
28+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SEARCH_DROPSHIP_URL;
29+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_ALL_DISTRIBUTION_URL;
30+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_MANUALLY_DISTRIBUTE_URL;
31+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Supplier.SET_PRODUCT_DISTRIBUTE_URL;
32+
33+
/**
34+
* 视频号小店代发管理服务。
35+
*
36+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
37+
*/
38+
@Slf4j
39+
public class WxChannelSupplierServiceImpl implements WxChannelSupplierService {
40+
41+
private final BaseWxChannelServiceImpl<?, ?> shopService;
42+
43+
public WxChannelSupplierServiceImpl(BaseWxChannelServiceImpl<?, ?> shopService) {
44+
this.shopService = shopService;
45+
}
46+
47+
@Override
48+
public SupplierListResponse getSupplierList() throws WxErrorException {
49+
String respJson = shopService.post(GET_SUPPLIER_LIST_URL, "{}");
50+
return ResponseUtils.decode(respJson, SupplierListResponse.class);
51+
}
52+
53+
@Override
54+
public DistributeTypeResponse getDistribute() throws WxErrorException {
55+
String respJson = shopService.post(GET_DISTRIBUTE_URL, "{}");
56+
return ResponseUtils.decode(respJson, DistributeTypeResponse.class);
57+
}
58+
59+
@Override
60+
public WxChannelBaseResponse setManuallyDistribute() throws WxErrorException {
61+
String respJson = shopService.post(SET_MANUALLY_DISTRIBUTE_URL, "{}");
62+
return ResponseUtils.decode(respJson, WxChannelBaseResponse.class);
63+
}
64+
65+
@Override
66+
public WxChannelBaseResponse setAllDistribute(String supplierId) throws WxErrorException {
67+
ProductDistributeRequest req = new ProductDistributeRequest();
68+
req.setSupplierId(supplierId);
69+
String respJson = shopService.post(SET_ALL_DISTRIBUTION_URL, req);
70+
return ResponseUtils.decode(respJson, WxChannelBaseResponse.class);
71+
}
72+
73+
@Override
74+
public WxChannelBaseResponse setProductDistribute(ProductDistributeRequest req) throws WxErrorException {
75+
String respJson = shopService.post(SET_PRODUCT_DISTRIBUTE_URL, req);
76+
return ResponseUtils.decode(respJson, WxChannelBaseResponse.class);
77+
}
78+
79+
@Override
80+
public SupplierInfoResponse getProductDefaultDistribute(String productId) throws WxErrorException {
81+
String respJson = shopService.post(GET_PRODUCT_DEFAULT_DISTRIBUTE_URL, "{\"product_id\":\"" + productId + "\"}");
82+
return ResponseUtils.decode(respJson, SupplierInfoResponse.class);
83+
}
84+
85+
@Override
86+
public ProductListResponse getProductList(String supplierId) throws WxErrorException {
87+
String respJson = shopService.post(GET_PRODUCT_LIST_URL, "{\"supplier_id\":\"" + supplierId + "\"}");
88+
return ResponseUtils.decode(respJson, ProductListResponse.class);
89+
}
90+
91+
@Override
92+
public DropshipResponse assignOrder(DropshipAssignRequest req) throws WxErrorException {
93+
String respJson = shopService.post(ASSIGN_DROPSHIP_URL, req);
94+
return ResponseUtils.decode(respJson, DropshipResponse.class);
95+
}
96+
97+
@Override
98+
public WxChannelBaseResponse cancelDropship(String orderId) throws WxErrorException {
99+
String respJson = shopService.post(CANCEL_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}");
100+
return ResponseUtils.decode(respJson, WxChannelBaseResponse.class);
101+
}
102+
103+
@Override
104+
public DropshipDetailResponse getDropship(String orderId) throws WxErrorException {
105+
String respJson = shopService.post(GET_DROPSHIP_URL, "{\"order_id\":\"" + orderId + "\"}");
106+
return ResponseUtils.decode(respJson, DropshipDetailResponse.class);
107+
}
108+
109+
@Override
110+
public DropshipListResponse listDropship(DropshipListRequest req) throws WxErrorException {
111+
String respJson = shopService.post(GET_DROPSHIP_LIST_URL, req);
112+
return ResponseUtils.decode(respJson, DropshipListResponse.class);
113+
}
114+
115+
@Override
116+
public DropshipListResponse searchDropship(DropshipSearchRequest req) throws WxErrorException {
117+
String respJson = shopService.post(SEARCH_DROPSHIP_URL, req);
118+
return ResponseUtils.decode(respJson, DropshipListResponse.class);
119+
}
120+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 分配方式响应。
11+
*
12+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class DistributeTypeResponse extends WxChannelBaseResponse {
18+
private static final long serialVersionUID = -750860556286328053L;
19+
20+
@JsonProperty("distribute_type")
21+
private Integer distributeType;
22+
23+
@JsonProperty("supplier_info")
24+
private SupplierInfo supplierInfo;
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.io.Serializable;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
/**
10+
* 代发单分配请求。
11+
*
12+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
17+
public class DropshipAssignRequest implements Serializable {
18+
private static final long serialVersionUID = 6945436332042017565L;
19+
20+
@JsonProperty("order_id")
21+
private String orderId;
22+
23+
@JsonProperty("supplier_id")
24+
private String supplierId;
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import lombok.NoArgsConstructor;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/**
10+
* 代发单详情响应。
11+
*
12+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@EqualsAndHashCode(callSuper = true)
17+
public class DropshipDetailResponse extends WxChannelBaseResponse {
18+
private static final long serialVersionUID = 5548774863400272707L;
19+
20+
@JsonProperty("dropship_info")
21+
private DropshipInfo dropshipInfo;
22+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.io.Serializable;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
/**
10+
* 代发单信息。
11+
*
12+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
17+
public class DropshipInfo implements Serializable {
18+
private static final long serialVersionUID = -7880364210849039278L;
19+
20+
@JsonProperty("order_id")
21+
private String orderId;
22+
23+
@JsonProperty("supplier_id")
24+
private String supplierId;
25+
26+
@JsonProperty("dropship_id")
27+
private String dropshipId;
28+
29+
@JsonProperty("status")
30+
private Integer status;
31+
32+
@JsonProperty("create_time")
33+
private Long createTime;
34+
35+
@JsonProperty("update_time")
36+
private Long updateTime;
37+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonInclude;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
import java.io.Serializable;
6+
import lombok.Data;
7+
import lombok.NoArgsConstructor;
8+
9+
/**
10+
* 代发单列表请求。
11+
*
12+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
13+
*/
14+
@Data
15+
@NoArgsConstructor
16+
@JsonInclude(JsonInclude.Include.NON_NULL)
17+
public class DropshipListRequest implements Serializable {
18+
private static final long serialVersionUID = 2638071229335192596L;
19+
20+
@JsonProperty("supplier_id")
21+
private String supplierId;
22+
23+
@JsonProperty("status")
24+
private Integer status;
25+
26+
@JsonProperty("create_time_start")
27+
private Long createTimeStart;
28+
29+
@JsonProperty("create_time_end")
30+
private Long createTimeEnd;
31+
32+
@JsonProperty("page_size")
33+
private Integer pageSize;
34+
35+
@JsonProperty("next_key")
36+
private String nextKey;
37+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package me.chanjar.weixin.channel.bean.supplier;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
import lombok.NoArgsConstructor;
8+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
9+
10+
/**
11+
* 代发单列表响应。
12+
*
13+
* @author <a href="https://github.com/github-copilot">GitHub Copilot</a>
14+
*/
15+
@Data
16+
@NoArgsConstructor
17+
@EqualsAndHashCode(callSuper = true)
18+
public class DropshipListResponse extends WxChannelBaseResponse {
19+
private static final long serialVersionUID = -2850183412032417307L;
20+
21+
@JsonProperty("dropship_list")
22+
private List<DropshipInfo> dropshipList;
23+
24+
@JsonProperty("next_key")
25+
private String nextKey;
26+
27+
@JsonProperty("has_more")
28+
private Boolean hasMore;
29+
}

0 commit comments

Comments
 (0)