Skip to content

Commit f34db91

Browse files
committed
feat: 完善小店商品管理接口
1 parent 3a0be1d commit f34db91

26 files changed

Lines changed: 912 additions & 0 deletions

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

Lines changed: 61 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,47 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy
213233
*/
214234
ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException;
215235

236+
/** 获取商品的移动应用跳转 scheme 码. */
237+
ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException;
238+
239+
/** 商品类目推荐. */
240+
ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param) throws WxErrorException;
241+
242+
/** 商品立即开售. */
243+
WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException;
244+
245+
/** 取消商品开售. */
246+
WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException;
247+
248+
/** 站内外商品属性映射. */
249+
ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param) throws WxErrorException;
250+
251+
/** 发品前校验. */
252+
ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param) throws WxErrorException;
253+
254+
/** 获取商品上架策略. */
255+
ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException;
256+
257+
/** 设置商品上架策略. */
258+
WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException;
259+
260+
/** 获取商品提审限额. */
261+
ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException;
262+
263+
/** 商品属性映射及推荐. */
264+
ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
265+
throws WxErrorException;
266+
267+
/** 商品品牌推荐. */
268+
ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param) throws WxErrorException;
269+
270+
/** 新增第三方货源信息. */
271+
AddProductThirdPartySourceResponse addProductThirdPartySource(AddProductThirdPartySourceParam param)
272+
throws WxErrorException;
273+
274+
/** 获取库存流水. */
275+
ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException;
276+
216277
/**
217278
* 添加非卖商品
218279
*

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

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,36 @@
1414
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_STOCK_UPDATE_URL;
1515
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.GIFT_PRODUCT_UPDATE_URL;
1616
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.LIST_LIMIT_TASK_URL;
17+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL;
1718
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_URL;
1819
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_FREE_UPDATE_URL;
20+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_GET_URL;
21+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_SET_URL;
22+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_BEGIN_TIMING_SALE_URL;
23+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CANCEL_TIMING_SALE_URL;
24+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_CLASSIFY_URL;
25+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_PRE_CHECK_URL;
1926
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DELISTING_URL;
2027
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DEL_URL;
28+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL;
29+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_URL;
30+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_AUDIT_QUOTA_URL;
2131
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_BATCH_URL;
32+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_FLOW_URL;
2233
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_URL;
2334
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_URL;
2435
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_H5URL_URL;
2536
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LISTING_URL;
2637
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LIST_URL;
38+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_PRODUCT_BRAND_RECOMMEND_URL;
2739
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_QRCODE_URL;
40+
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_SCHEME_URL;
2841
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_TAGLINK_URL;
2942
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_STOCK_URL;
3043
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_URL;
3144
import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.STOP_LIMIT_TASK_URL;
3245

46+
import java.util.Collections;
3347
import java.util.List;
3448
import lombok.extern.slf4j.Slf4j;
3549
import me.chanjar.weixin.channel.api.WxChannelProductService;
@@ -38,6 +52,12 @@
3852
import me.chanjar.weixin.channel.bean.limit.LimitTaskListParam;
3953
import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse;
4054
import me.chanjar.weixin.channel.bean.limit.LimitTaskParam;
55+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam;
56+
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceResponse;
57+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewParam;
58+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewResponse;
59+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingParam;
60+
import me.chanjar.weixin.channel.bean.product.ExternalProductMappingResponse;
4161
import me.chanjar.weixin.channel.bean.product.GiftActivityAddParam;
4262
import me.chanjar.weixin.channel.bean.product.GiftActivityAddResponse;
4363
import me.chanjar.weixin.channel.bean.product.GiftActivityInfo;
@@ -46,6 +66,20 @@
4666
import me.chanjar.weixin.channel.bean.product.GiftProductInfo;
4767
import me.chanjar.weixin.channel.bean.product.GiftProductListParam;
4868
import me.chanjar.weixin.channel.bean.product.GiftProductListResponse;
69+
import me.chanjar.weixin.channel.bean.product.ProductAuditQuotaResponse;
70+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategyResponse;
71+
import me.chanjar.weixin.channel.bean.product.ProductAuditStrategySetParam;
72+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendParam;
73+
import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendResponse;
74+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyParam;
75+
import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyResponse;
76+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckParam;
77+
import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckResponse;
78+
import me.chanjar.weixin.channel.bean.product.ProductSchemeParam;
79+
import me.chanjar.weixin.channel.bean.product.ProductSchemeResponse;
80+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowParam;
81+
import me.chanjar.weixin.channel.bean.product.ProductStockFlowResponse;
82+
import me.chanjar.weixin.channel.bean.product.ProductTimingSaleParam;
4983
import me.chanjar.weixin.channel.bean.product.SkuStockBatchParam;
5084
import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse;
5185
import me.chanjar.weixin.channel.bean.product.SkuStockParam;
@@ -228,6 +262,85 @@ public ProductTagLinkResponse getProductTagLink(String productId) throws WxError
228262
return ResponseUtils.decode(resJson, ProductTagLinkResponse.class);
229263
}
230264

265+
@Override
266+
public ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException {
267+
return postAndDecode(SPU_SCHEME_URL, param, ProductSchemeResponse.class);
268+
}
269+
270+
@Override
271+
public ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param)
272+
throws WxErrorException {
273+
return postAndDecode(SPU_CATEGORY_CLASSIFY_URL, param, ProductCategoryClassifyResponse.class);
274+
}
275+
276+
@Override
277+
public WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException {
278+
return postAndDecode(SPU_BEGIN_TIMING_SALE_URL, param, WxChannelBaseResponse.class);
279+
}
280+
281+
@Override
282+
public WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException {
283+
return postAndDecode(SPU_CANCEL_TIMING_SALE_URL, Collections.singletonMap("product_id", productId),
284+
WxChannelBaseResponse.class);
285+
}
286+
287+
@Override
288+
public ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param)
289+
throws WxErrorException {
290+
return postAndDecode(SPU_EXTERNAL_PRODUCT_MAPPING_URL, param, ExternalProductMappingResponse.class);
291+
}
292+
293+
@Override
294+
public ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param)
295+
throws WxErrorException {
296+
return postAndDecode(SPU_CATEGORY_PRE_CHECK_URL, param, ProductCategoryPreCheckResponse.class);
297+
}
298+
299+
@Override
300+
public ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException {
301+
return postAndDecode(SPU_AUDIT_STRATEGY_GET_URL, "{}", ProductAuditStrategyResponse.class);
302+
}
303+
304+
@Override
305+
public WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException {
306+
return postAndDecode(SPU_AUDIT_STRATEGY_SET_URL, param, WxChannelBaseResponse.class);
307+
}
308+
309+
@Override
310+
public ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException {
311+
return postAndDecode(SPU_GET_AUDIT_QUOTA_URL, "{}", ProductAuditQuotaResponse.class);
312+
}
313+
314+
@Override
315+
public ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
316+
throws WxErrorException {
317+
return postAndDecode(SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL, param, ExternalProductMappingNewResponse.class);
318+
}
319+
320+
@Override
321+
public ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param)
322+
throws WxErrorException {
323+
return postAndDecode(SPU_PRODUCT_BRAND_RECOMMEND_URL, param, ProductBrandRecommendResponse.class);
324+
}
325+
326+
@Override
327+
public AddProductThirdPartySourceResponse addProductThirdPartySource(AddProductThirdPartySourceParam param)
328+
throws WxErrorException {
329+
return postAndDecode(SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL, param, AddProductThirdPartySourceResponse.class);
330+
}
331+
332+
@Override
333+
public ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException {
334+
return postAndDecode(SPU_GET_STOCK_FLOW_URL, param, ProductStockFlowResponse.class);
335+
}
336+
337+
private <T extends WxChannelBaseResponse> T postAndDecode(String url, Object param, Class<T> responseType)
338+
throws WxErrorException {
339+
String reqJson = param instanceof String ? (String) param : JsonUtils.encode(param);
340+
String resJson = shopService.post(url, reqJson);
341+
return ResponseUtils.decode(resJson, responseType);
342+
}
343+
231344
@Override
232345
public GiftProductAddResponse addGiftProduct(GiftProductInfo info) throws WxErrorException {
233346
String reqJson = JsonUtils.encode(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+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package me.chanjar.weixin.channel.bean.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
5+
import java.util.List;
6+
import lombok.Data;
7+
8+
/** 商品属性映射及推荐请求参数. */
9+
@Data
10+
public class ExternalProductMappingNewParam implements Serializable {
11+
private static final long serialVersionUID = -7982070319116550518L;
12+
13+
@JsonProperty("cat_id")
14+
private Long catId;
15+
@JsonProperty("external_category_name")
16+
private String externalCategoryName;
17+
@JsonProperty("head_imgs")
18+
private List<String> headImgs;
19+
@JsonProperty("detail_imgs")
20+
private List<String> detailImgs;
21+
private String title;
22+
@JsonProperty("external_attributes")
23+
private List<ExternalAttribute> externalAttributes;
24+
25+
@Data
26+
public static class ExternalAttribute implements Serializable {
27+
private static final long serialVersionUID = 300805187240781417L;
28+
private String key;
29+
private String value;
30+
}
31+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package me.chanjar.weixin.channel.bean.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/** 商品属性映射及推荐响应. */
10+
@Data
11+
@EqualsAndHashCode(callSuper = true)
12+
public class ExternalProductMappingNewResponse extends WxChannelBaseResponse {
13+
private static final long serialVersionUID = 4536547956225312823L;
14+
15+
@JsonProperty("attributes")
16+
private List<ExternalProductMappingNewParam.ExternalAttribute> attributes;
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package me.chanjar.weixin.channel.bean.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
5+
import lombok.Data;
6+
7+
/** 站内外商品属性映射请求参数. */
8+
@Data
9+
public class ExternalProductMappingParam implements Serializable {
10+
private static final long serialVersionUID = 3288069294712374035L;
11+
12+
@JsonProperty("cat_id")
13+
private Long catId;
14+
@JsonProperty("external_attribute_name")
15+
private String externalAttributeName;
16+
@JsonProperty("external_attribute_value")
17+
private String externalAttributeValue;
18+
@JsonProperty("external_category_name")
19+
private String externalCategoryName;
20+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.chanjar.weixin.channel.bean.product;
2+
3+
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.util.List;
5+
import lombok.Data;
6+
import lombok.EqualsAndHashCode;
7+
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
8+
9+
/** 站内外商品属性映射响应. */
10+
@Data
11+
@EqualsAndHashCode(callSuper = true)
12+
public class ExternalProductMappingResponse extends WxChannelBaseResponse {
13+
private static final long serialVersionUID = -8356596972896906087L;
14+
15+
@JsonProperty("external_attribute_name")
16+
private String externalAttributeName;
17+
@JsonProperty("external_attribute_value")
18+
private String externalAttributeValue;
19+
@JsonProperty("internal_attribute_name")
20+
private String internalAttributeName;
21+
@JsonProperty("internal_attribute_value")
22+
private List<String> internalAttributeValue;
23+
}

0 commit comments

Comments
 (0)