Skip to content

Commit 5bb9dee

Browse files
authored
🆕 #4104 【视频号】补齐微信小店商品管理的13 个服务接口与数据模型
1 parent 9a616de commit 5bb9dee

27 files changed

Lines changed: 1057 additions & 2 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ sonar-project.properties
5151
!/.mvn/wrapper/maven-wrapper.jar
5252
*.versionsBackup
5353

54+
# Local Superpowers planning artifacts
55+
docs/superpowers/
56+
5457
# STS
5558
.factorypath
5659
*.zip

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

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,26 @@
1313
import me.chanjar.weixin.channel.bean.product.GiftProductInfo;
1414
import me.chanjar.weixin.channel.bean.product.GiftProductListParam;
1515
import me.chanjar.weixin.channel.bean.product.GiftProductListResponse;
16+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam;
17+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceResponse;
18+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewParam;
19+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewResponse;
20+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingParam;
21+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingResponse;
22+
import me.chanjar.weixin.channel.bean.product.ProductAuditQuotaResponse;
23+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategyResponse;
24+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategySetParam;
25+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendParam;
26+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendResponse;
27+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyParam;
28+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyResponse;
29+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckParam;
30+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckResponse;
31+
import me.chanjar.weixin.channel.bean.product.ProductSchemeParam;
32+
import me.chanjar.weixin.channel.bean.product.ProductSchemeResponse;
33+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowParam;
34+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowResponse;
35+
import me.chanjar.weixin.channel.bean.product.ProductTimingSaleParam;
1636
import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse;
1737
import me.chanjar.weixin.channel.bean.product.SkuStockResponse;
1838
import me.chanjar.weixin.channel.bean.product.SpuFastInfo;
@@ -213,6 +233,123 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy
213233
*/
214234
ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException;
215235

236+
/**
237+
* 获取商品的移动应用跳转 scheme 码.
238+
*
239+
* @param param 商品 ID、来源 appid、过期时间和附加信息
240+
* @return 商品跳转 scheme 码
241+
* @throws WxErrorException 调用微信接口失败
242+
*/
243+
ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException;
244+
245+
/**
246+
* 商品类目推荐.
247+
*
248+
* @param param 请求类型、商品标题、主图和可选类目 ID;当请求类型为 2 时必须提供类目 ID
249+
* @return 推荐类目及店铺经营权限
250+
* @throws WxErrorException 调用微信接口失败
251+
*/
252+
ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param) throws WxErrorException;
253+
254+
/**
255+
* 将定时开售商品改为立即开售.
256+
*
257+
* @param param 商品 ID 和定时开售任务 ID
258+
* @return 操作结果
259+
* @throws WxErrorException 调用微信接口失败
260+
*/
261+
WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException;
262+
263+
/**
264+
* 取消商品开售.
265+
*
266+
* @param productId 商品 ID
267+
* @return 操作结果
268+
* @throws WxErrorException 调用微信接口失败
269+
*/
270+
WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException;
271+
272+
/**
273+
* 查询站内外商品属性映射.
274+
*
275+
* @param param 叶子类目 ID、外部类目和外部属性
276+
* @return 对应的站内属性及可选属性值
277+
* @throws WxErrorException 调用微信接口失败
278+
*/
279+
ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param) throws WxErrorException;
280+
281+
/**
282+
* 发品前校验店铺类目资质.
283+
*
284+
* @param param 待发布商品的叶子类目 ID
285+
* @return 校验结果和未通过原因
286+
* @throws WxErrorException 调用微信接口失败
287+
*/
288+
ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param) throws WxErrorException;
289+
290+
/**
291+
* 获取店铺维度的商品上架策略.
292+
*
293+
* @return 当前上架策略
294+
* @throws WxErrorException 调用微信接口失败
295+
*/
296+
ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException;
297+
298+
/**
299+
* 设置店铺维度的商品上架策略.
300+
*
301+
* @param param 要设置的上架策略
302+
* @return 操作结果
303+
* @throws WxErrorException 调用微信接口失败
304+
*/
305+
WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException;
306+
307+
/**
308+
* 获取当前店铺的商品提审限额.
309+
*
310+
* @return 提审总额度和新品剩余额度
311+
* @throws WxErrorException 调用微信接口失败
312+
*/
313+
ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException;
314+
315+
/**
316+
* 商品属性映射及推荐.
317+
*
318+
* @param param 叶子类目、商品标题、主图及可选的外部属性
319+
* @return 推荐的站内属性
320+
* @throws WxErrorException 调用微信接口失败
321+
*/
322+
ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
323+
throws WxErrorException;
324+
325+
/**
326+
* 根据商品信息推荐店铺已有资质的品牌.
327+
*
328+
* @param param 商品叶子类目、标题和图片
329+
* @return 推荐品牌
330+
* @throws WxErrorException 调用微信接口失败
331+
*/
332+
ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param) throws WxErrorException;
333+
334+
/**
335+
* 新增第三方货源信息.
336+
*
337+
* @param param 场景、发布方式、货主及货源商品信息
338+
* @return 包含第三方货源 ID 的操作结果
339+
* @throws WxErrorException 调用微信接口失败
340+
*/
341+
AddProductThirdPartySourceResponse addProductThirdPartySource(AddProductThirdPartySourceParam param)
342+
throws WxErrorException;
343+
344+
/**
345+
* 获取商品库存流水.
346+
*
347+
* @param param 商品、SKU、库存类型、时间范围和分页参数;pageSize 必填,stockType 为 1 时 finderId 必填,库存类型非 0 和 1 时 stockTypeId 必填
348+
* @return 库存流水及下一页标识
349+
* @throws WxErrorException 调用微信接口失败
350+
*/
351+
ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException;
352+
216353
/**
217354
* 添加非卖商品
218355
*

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

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@
22

33

44
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.CANCEL_AUDIT_URL;
5+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.DELETE_LIMIT_TASK_URL;
6+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_ADD_URL;
7+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_DELETE_URL;
8+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_ACTIVITY_STOP_URL;
9+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_ADD_URL;
10+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_GET_URL;
11+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_LIST_URL;
12+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_ON_SALE_SET_URL;
13+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_STOCK_UPDATE_URL;
14+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_UPDATE_URL;
15+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.LIST_LIMIT_TASK_URL;
16+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL;
517
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_URL;
618
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_FREE_UPDATE_URL;
19+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_GET_URL;
20+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_SET_URL;
21+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_BEGIN_TIMING_SALE_URL;
22+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CANCEL_TIMING_SALE_URL;
23+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_CLASSIFY_URL;
24+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_PRE_CHECK_URL;
725
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DELISTING_URL;
826
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DEL_URL;
27+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL;
28+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_URL;
29+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_AUDIT_QUOTA_URL;
30+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_BATCH_URL;
31+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_FLOW_URL;
32+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_URL;
933
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_URL;
1034
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_H5URL_URL;
1135
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LISTING_URL;
1236
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LIST_URL;
37+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_PRODUCT_BRAND_RECOMMEND_URL;
1338
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_QRCODE_URL;
39+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_SCHEME_URL;
1440
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_TAGLINK_URL;
1541
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_URL;
1642

43+
import java.util.Collections;
1744
import java.util.List;
1845
import lombok.extern.slf4j.Slf4j;
1946
import me.chanjar.weixin.channel.api.WxChannelGiftService;
@@ -24,13 +51,35 @@
2451
import me.chanjar.weixin.channel.bean.limit.LimitTaskAddResponse;
2552
import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse;
2653
import me.chanjar.weixin.channel.bean.limit.LimitTaskParam;
54+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam;
55+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceResponse;
56+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewParam;
57+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewResponse;
58+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingParam;
59+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingResponse;
60+
import me.chanjar.weixin.channel.bean.product.GiftActivityAddParam;
2761
import me.chanjar.weixin.channel.bean.product.GiftActivityAddResponse;
2862
import me.chanjar.weixin.channel.bean.product.GiftActivityInfo;
2963
import me.chanjar.weixin.channel.bean.product.GiftProductAddResponse;
3064
import me.chanjar.weixin.channel.bean.product.GiftProductGetResponse;
3165
import me.chanjar.weixin.channel.bean.product.GiftProductInfo;
3266
import me.chanjar.weixin.channel.bean.product.GiftProductListParam;
3367
import me.chanjar.weixin.channel.bean.product.GiftProductListResponse;
68+
import me.chanjar.weixin.channel.bean.product.ProductAuditQuotaResponse;
69+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategyResponse;
70+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategySetParam;
71+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendParam;
72+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendResponse;
73+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyParam;
74+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyResponse;
75+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckParam;
76+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckResponse;
77+
import me.chanjar.weixin.channel.bean.product.ProductSchemeParam;
78+
import me.chanjar.weixin.channel.bean.product.ProductSchemeResponse;
79+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowParam;
80+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowResponse;
81+
import me.chanjar.weixin.channel.bean.product.ProductTimingSaleParam;
82+
import me.chanjar.weixin.channel.bean.product.SkuStockBatchParam;
3483
import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse;
3584
import me.chanjar.weixin.channel.bean.product.SkuStockResponse;
3685
import me.chanjar.weixin.channel.bean.product.SpuFastInfo;
@@ -216,6 +265,85 @@ public ProductTagLinkResponse getProductTagLink(String productId) throws WxError
216265
return ResponseUtils.decode(resJson, ProductTagLinkResponse.class);
217266
}
218267

268+
@Override
269+
public ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException {
270+
return postAndDecode(SPU_SCHEME_URL, param, ProductSchemeResponse.class);
271+
}
272+
273+
@Override
274+
public ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param)
275+
throws WxErrorException {
276+
return postAndDecode(SPU_CATEGORY_CLASSIFY_URL, param, ProductCategoryClassifyResponse.class);
277+
}
278+
279+
@Override
280+
public WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException {
281+
return postAndDecode(SPU_BEGIN_TIMING_SALE_URL, param, WxChannelBaseResponse.class);
282+
}
283+
284+
@Override
285+
public WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException {
286+
return postAndDecode(SPU_CANCEL_TIMING_SALE_URL, Collections.singletonMap("product_id", productId),
287+
WxChannelBaseResponse.class);
288+
}
289+
290+
@Override
291+
public ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param)
292+
throws WxErrorException {
293+
return postAndDecode(SPU_EXTERNAL_PRODUCT_MAPPING_URL, param, ExternalProductMappingResponse.class);
294+
}
295+
296+
@Override
297+
public ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param)
298+
throws WxErrorException {
299+
return postAndDecode(SPU_CATEGORY_PRE_CHECK_URL, param, ProductCategoryPreCheckResponse.class);
300+
}
301+
302+
@Override
303+
public ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException {
304+
return postAndDecode(SPU_AUDIT_STRATEGY_GET_URL, "{}", ProductAuditStrategyResponse.class);
305+
}
306+
307+
@Override
308+
public WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException {
309+
return postAndDecode(SPU_AUDIT_STRATEGY_SET_URL, param, WxChannelBaseResponse.class);
310+
}
311+
312+
@Override
313+
public ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException {
314+
return postAndDecode(SPU_GET_AUDIT_QUOTA_URL, "{}", ProductAuditQuotaResponse.class);
315+
}
316+
317+
@Override
318+
public ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
319+
throws WxErrorException {
320+
return postAndDecode(SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL, param, ExternalProductMappingNewResponse.class);
321+
}
322+
323+
@Override
324+
public ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param)
325+
throws WxErrorException {
326+
return postAndDecode(SPU_PRODUCT_BRAND_RECOMMEND_URL, param, ProductBrandRecommendResponse.class);
327+
}
328+
329+
@Override
330+
public AddProductThirdPartySourceResponse addProductThirdPartySource(AddProductThirdPartySourceParam param)
331+
throws WxErrorException {
332+
return postAndDecode(SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL, param, AddProductThirdPartySourceResponse.class);
333+
}
334+
335+
@Override
336+
public ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException {
337+
return postAndDecode(SPU_GET_STOCK_FLOW_URL, param, ProductStockFlowResponse.class);
338+
}
339+
340+
private <T extends WxChannelBaseResponse> T postAndDecode(String url, Object param, Class<T> responseType)
341+
throws WxErrorException {
342+
String reqJson = param instanceof String ? (String) param : JsonUtils.encode(param);
343+
String resJson = shopService.post(url, reqJson);
344+
return ResponseUtils.decode(resJson, responseType);
345+
}
346+
219347
@Override
220348
public GiftProductAddResponse addGiftProduct(GiftProductInfo info) throws WxErrorException {
221349
return giftService.addGiftProduct(info);
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.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import com.fasterxml.jackson.databind.JsonNode;
5+
import java.io.Serializable;
6+
import lombok.Data;
7+
8+
/** 新增第三方货源信息请求参数. */
9+
@Data
10+
public class AddProductThirdPartySourceParam implements Serializable {
11+
private static final long serialVersionUID = -5784320217481497742L;
12+
13+
@JsonProperty("scene_value")
14+
private Integer sceneValue;
15+
@JsonProperty("publish_method")
16+
private Integer publishMethod;
17+
private JsonNode supplier;
18+
@JsonProperty("supplier_shop_performance")
19+
private JsonNode supplierShopPerformance;
20+
@JsonProperty("product_source_info")
21+
private JsonNode productSourceInfo;
22+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package me.chanjar.weixin.channel.bean.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
7+
8+
/** 新增第三方货源信息响应. */
9+
@Data
10+
@EqualsAndHashCode(callSuper = true)
11+
public class AddProductThirdPartySourceResponse extends WxChannelBaseResponse {
12+
private static final long serialVersionUID = -7528226120383065861L;
13+
14+
@JsonProperty("third_party_source_id")
15+
private Long thirdPartySourceId;
16+
}

0 commit comments

Comments
 (0)