Skip to content

Commit a0c2daa

Browse files
committed
docs: 补充商品管理接口说明
1 parent f34db91 commit a0c2daa

5 files changed

Lines changed: 132 additions & 18 deletions

File tree

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

Lines changed: 89 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -233,45 +233,121 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy
233233
*/
234234
ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException;
235235

236-
/** 获取商品的移动应用跳转 scheme 码. */
236+
/**
237+
* 获取商品的移动应用跳转 scheme 码.
238+
*
239+
* @param param 商品 ID、来源 appid、过期时间和附加信息
240+
* @return 商品跳转 scheme 码
241+
* @throws WxErrorException 调用微信接口失败
242+
*/
237243
ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException;
238244

239-
/** 商品类目推荐. */
245+
/**
246+
* 商品类目推荐.
247+
*
248+
* @param param 请求类型、商品标题、主图和可选类目 ID;当请求类型为 2 时必须提供类目 ID
249+
* @return 推荐类目及店铺经营权限
250+
* @throws WxErrorException 调用微信接口失败
251+
*/
240252
ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param) throws WxErrorException;
241253

242-
/** 商品立即开售. */
254+
/**
255+
* 将定时开售商品改为立即开售.
256+
*
257+
* @param param 商品 ID 和定时开售任务 ID
258+
* @return 操作结果
259+
* @throws WxErrorException 调用微信接口失败
260+
*/
243261
WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException;
244262

245-
/** 取消商品开售. */
263+
/**
264+
* 取消商品开售.
265+
*
266+
* @param productId 商品 ID
267+
* @return 操作结果
268+
* @throws WxErrorException 调用微信接口失败
269+
*/
246270
WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException;
247271

248-
/** 站内外商品属性映射. */
272+
/**
273+
* 查询站内外商品属性映射.
274+
*
275+
* @param param 叶子类目 ID、外部类目和外部属性
276+
* @return 对应的站内属性及可选属性值
277+
* @throws WxErrorException 调用微信接口失败
278+
*/
249279
ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param) throws WxErrorException;
250280

251-
/** 发品前校验. */
281+
/**
282+
* 发品前校验店铺类目资质.
283+
*
284+
* @param param 待发布商品的叶子类目 ID
285+
* @return 校验结果和未通过原因
286+
* @throws WxErrorException 调用微信接口失败
287+
*/
252288
ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param) throws WxErrorException;
253289

254-
/** 获取商品上架策略. */
290+
/**
291+
* 获取店铺维度的商品上架策略.
292+
*
293+
* @return 当前上架策略
294+
* @throws WxErrorException 调用微信接口失败
295+
*/
255296
ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException;
256297

257-
/** 设置商品上架策略. */
298+
/**
299+
* 设置店铺维度的商品上架策略.
300+
*
301+
* @param param 要设置的上架策略
302+
* @return 操作结果
303+
* @throws WxErrorException 调用微信接口失败
304+
*/
258305
WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException;
259306

260-
/** 获取商品提审限额. */
307+
/**
308+
* 获取当前店铺的商品提审限额.
309+
*
310+
* @return 提审总额度和新品剩余额度
311+
* @throws WxErrorException 调用微信接口失败
312+
*/
261313
ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException;
262314

263-
/** 商品属性映射及推荐. */
315+
/**
316+
* 商品属性映射及推荐.
317+
*
318+
* @param param 叶子类目、商品标题、主图及可选的外部属性
319+
* @return 推荐的站内属性
320+
* @throws WxErrorException 调用微信接口失败
321+
*/
264322
ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param)
265323
throws WxErrorException;
266324

267-
/** 商品品牌推荐. */
325+
/**
326+
* 根据商品信息推荐店铺已有资质的品牌.
327+
*
328+
* @param param 商品叶子类目、标题和图片
329+
* @return 推荐品牌
330+
* @throws WxErrorException 调用微信接口失败
331+
*/
268332
ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param) throws WxErrorException;
269333

270-
/** 新增第三方货源信息. */
334+
/**
335+
* 新增第三方货源信息.
336+
*
337+
* @param param 场景、发布方式、货主及货源商品信息
338+
* @return 包含第三方货源 ID 的操作结果
339+
* @throws WxErrorException 调用微信接口失败
340+
*/
271341
AddProductThirdPartySourceResponse addProductThirdPartySource(AddProductThirdPartySourceParam param)
272342
throws WxErrorException;
273343

274-
/** 获取库存流水. */
344+
/**
345+
* 获取商品库存流水.
346+
*
347+
* @param param 商品、SKU、库存类型、时间范围和分页参数;pageSize 必填,库存类型非 0 和 1 时 stockTypeId 必填
348+
* @return 库存流水及下一页标识
349+
* @throws WxErrorException 调用微信接口失败
350+
*/
275351
ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException;
276352

277353
/**

‎weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditQuotaResponse.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.chanjar.weixin.channel.bean.product;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
45
import lombok.Data;
56
import lombok.EqualsAndHashCode;
67
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
@@ -15,7 +16,9 @@ public class ProductAuditQuotaResponse extends WxChannelBaseResponse {
1516
private AuditQuota auditQuota;
1617

1718
@Data
18-
public static class AuditQuota {
19+
public static class AuditQuota implements Serializable {
20+
private static final long serialVersionUID = 6066821247844334714L;
21+
1922
@JsonProperty("block_status")
2023
private Integer blockStatus;
2124
@JsonProperty("avail_quota")

‎weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyResponse.java‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package me.chanjar.weixin.channel.bean.product;
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
4+
import java.io.Serializable;
45
import java.util.List;
56
import lombok.Data;
67
import lombok.EqualsAndHashCode;
@@ -17,20 +18,26 @@ public class ProductCategoryClassifyResponse extends WxChannelBaseResponse {
1718
private Boolean wrongCat;
1819

1920
@Data
20-
public static class CategoryInfo {
21+
public static class CategoryInfo implements Serializable {
22+
private static final long serialVersionUID = -4800760946330901306L;
23+
2124
private List<CategoryLevel> cats;
2225
}
2326

2427
@Data
25-
public static class CategoryLevel {
28+
public static class CategoryLevel implements Serializable {
29+
private static final long serialVersionUID = 8010801623725584755L;
30+
2631
@JsonProperty("cat_info")
2732
private Category catInfo;
2833
@JsonProperty("has_permission")
2934
private Boolean hasPermission;
3035
}
3136

3237
@Data
33-
public static class Category {
38+
public static class Category implements Serializable {
39+
private static final long serialVersionUID = -9013991576741902059L;
40+
3441
@JsonProperty("cat_id")
3542
private String catId;
3643
@JsonProperty("cat_name")

‎weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowResponse.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.fasterxml.jackson.annotation.JsonProperty;
44
import com.fasterxml.jackson.databind.JsonNode;
5+
import java.io.Serializable;
56
import java.util.List;
67
import lombok.Data;
78
import lombok.EqualsAndHashCode;
@@ -16,7 +17,9 @@ public class ProductStockFlowResponse extends WxChannelBaseResponse {
1617
private StockFlowData data;
1718

1819
@Data
19-
public static class StockFlowData {
20+
public static class StockFlowData implements Serializable {
21+
private static final long serialVersionUID = -4963813730951045381L;
22+
2023
@JsonProperty("stock_flow_info_list")
2124
private List<JsonNode> stockFlowInfoList;
2225
@JsonProperty("next_key")

‎weixin-java-channel/src/test/java/me/chanjar/weixin/channel/api/impl/WxChannelProductManagementServiceImplTest.java‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import static org.testng.Assert.assertEquals;
44
import static org.testng.Assert.assertTrue;
55

6+
import java.io.ByteArrayOutputStream;
7+
import java.io.IOException;
8+
import java.io.ObjectOutputStream;
69
import java.util.Arrays;
710
import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse;
811
import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam;
@@ -213,6 +216,21 @@ public void shouldGetStockFlowWithRequiredPaginationAndStockTypeId() throws WxEr
213216
assertEquals(result.getData().getNextKey(), "next");
214217
}
215218

219+
@Test
220+
public void shouldSerializeNestedProductManagementResponses() throws IOException {
221+
ProductAuditQuotaResponse.AuditQuota auditQuota = new ProductAuditQuotaResponse.AuditQuota();
222+
ProductCategoryClassifyResponse.Category category = new ProductCategoryClassifyResponse.Category();
223+
ProductCategoryClassifyResponse.CategoryLevel categoryLevel = new ProductCategoryClassifyResponse.CategoryLevel();
224+
ProductCategoryClassifyResponse.CategoryInfo categoryInfo = new ProductCategoryClassifyResponse.CategoryInfo();
225+
ProductStockFlowResponse.StockFlowData stockFlowData = new ProductStockFlowResponse.StockFlowData();
226+
227+
assertSerializable(auditQuota);
228+
assertSerializable(category);
229+
assertSerializable(categoryLevel);
230+
assertSerializable(categoryInfo);
231+
assertSerializable(stockFlowData);
232+
}
233+
216234
private static WxChannelProductServiceImpl productService(RecordingChannelService channelService) {
217235
return new WxChannelProductServiceImpl(channelService);
218236
}
@@ -230,6 +248,13 @@ private static void assertRequest(RecordingChannelService channelService, String
230248
assertEquals(JsonUtils.decode(channelService.getRequestJson(), Object.class), JsonUtils.decode(expectedJson, Object.class));
231249
}
232250

251+
private static void assertSerializable(Object value) throws IOException {
252+
ByteArrayOutputStream output = new ByteArrayOutputStream();
253+
try (ObjectOutputStream objectOutput = new ObjectOutputStream(output)) {
254+
objectOutput.writeObject(value);
255+
}
256+
}
257+
233258
private static class RecordingChannelService extends WxChannelServiceHttpClientImpl {
234259
private final String response;
235260
private String url;

0 commit comments

Comments
 (0)