diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java index 7064adf70f..3ab0410951 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/WxChannelProductService.java @@ -8,6 +8,25 @@ import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse; import me.chanjar.weixin.channel.bean.product.SkuStockResponse; +import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewResponse; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditQuotaResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditStrategyResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditStrategySetParam; +import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendParam; +import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendResponse; +import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyParam; +import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyResponse; +import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckParam; +import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckResponse; +import me.chanjar.weixin.channel.bean.product.ProductSchemeParam; +import me.chanjar.weixin.channel.bean.product.ProductSchemeResponse; +import me.chanjar.weixin.channel.bean.product.ProductStockFlowParam; +import me.chanjar.weixin.channel.bean.product.ProductStockFlowResponse; +import me.chanjar.weixin.channel.bean.product.ProductTimingSaleParam; import me.chanjar.weixin.channel.bean.product.SpuFastInfo; import me.chanjar.weixin.channel.bean.product.SpuGetResponse; import me.chanjar.weixin.channel.bean.product.SpuInfo; @@ -206,6 +225,122 @@ WxChannelBaseResponse updateStock(String productId, String skuId, Integer diffTy */ ProductTagLinkResponse getProductTagLink(String productId) throws WxErrorException; + /** + * 获取商品的移动应用跳转scheme码 + * + * @param param 请求参数 + * @return 商品scheme码 + * @throws WxErrorException 异常 + */ + ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException; + + /** + * 商品类目推荐 + * + * @param param 请求参数 + * @return 推荐类目 + * @throws WxErrorException 异常 + */ + ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param) throws WxErrorException; + + /** + * 商品立即开售 + * + * @param param 请求参数 + * @return 是否成功 + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException; + + /** + * 取消商品开售 + * + * @param productId 商品ID + * @return 是否成功 + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException; + + /** + * 站内外商品属性映射 + * + * @param param 请求参数 + * @return 映射结果 + * @throws WxErrorException 异常 + */ + ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param) throws WxErrorException; + + /** + * 发品前校验 + * + * @param param 请求参数 + * @return 校验结果 + * @throws WxErrorException 异常 + */ + ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param) throws WxErrorException; + + /** + * 获取商品上架策略 + * + * @return 上架策略 + * @throws WxErrorException 异常 + */ + ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException; + + /** + * 设置商品上架策略 + * + * @param param 请求参数 + * @return 是否成功 + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException; + + /** + * 获取商品提审限额 + * + * @return 提审限额 + * @throws WxErrorException 异常 + */ + ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException; + + /** + * 商品属性映射及推荐 + * + * @param param 请求参数 + * @return 映射推荐结果 + * @throws WxErrorException 异常 + */ + ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param) + throws WxErrorException; + + /** + * 商品品牌推荐 + * + * @param param 请求参数 + * @return 品牌推荐结果 + * @throws WxErrorException 异常 + */ + ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param) throws WxErrorException; + + /** + * 新增第三方货源信息 + * + * @param param 请求参数 + * @return 是否成功 + * @throws WxErrorException 异常 + */ + WxChannelBaseResponse addProductThirdPartySource(AddProductThirdPartySourceParam param) throws WxErrorException; + + /** + * 获取库存流水 + * + * @param param 请求参数 + * @return 库存流水 + * @throws WxErrorException 异常 + */ + ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException; + /** * 添加限时抢购任务 * diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java index 08c9638f0c..dd8fab415c 100644 --- a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/api/impl/WxChannelProductServiceImpl.java @@ -5,17 +5,30 @@ import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.CANCEL_AUDIT_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.DELETE_LIMIT_TASK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.LIST_LIMIT_TASK_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_ADD_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_FREE_UPDATE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_GET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_AUDIT_STRATEGY_SET_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_BEGIN_TIMING_SALE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CANCEL_TIMING_SALE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_CLASSIFY_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_CATEGORY_PRE_CHECK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DELISTING_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_DEL_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_EXTERNAL_PRODUCT_MAPPING_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_AUDIT_QUOTA_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_BATCH_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_FLOW_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_STOCK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_GET_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_H5URL_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LISTING_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_LIST_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_PRODUCT_BRAND_RECOMMEND_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_QRCODE_URL; +import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_SCHEME_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_TAGLINK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_STOCK_URL; import static me.chanjar.weixin.channel.constant.WxChannelApiUrlConstants.Spu.SPU_UPDATE_URL; @@ -29,6 +42,25 @@ import me.chanjar.weixin.channel.bean.limit.LimitTaskListParam; import me.chanjar.weixin.channel.bean.limit.LimitTaskListResponse; import me.chanjar.weixin.channel.bean.limit.LimitTaskParam; +import me.chanjar.weixin.channel.bean.product.AddProductThirdPartySourceParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingNewResponse; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingParam; +import me.chanjar.weixin.channel.bean.product.ExternalProductMappingResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditQuotaResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditStrategyResponse; +import me.chanjar.weixin.channel.bean.product.ProductAuditStrategySetParam; +import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendParam; +import me.chanjar.weixin.channel.bean.product.ProductBrandRecommendResponse; +import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyParam; +import me.chanjar.weixin.channel.bean.product.ProductCategoryClassifyResponse; +import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckParam; +import me.chanjar.weixin.channel.bean.product.ProductCategoryPreCheckResponse; +import me.chanjar.weixin.channel.bean.product.ProductSchemeParam; +import me.chanjar.weixin.channel.bean.product.ProductSchemeResponse; +import me.chanjar.weixin.channel.bean.product.ProductStockFlowParam; +import me.chanjar.weixin.channel.bean.product.ProductStockFlowResponse; +import me.chanjar.weixin.channel.bean.product.ProductTimingSaleParam; import me.chanjar.weixin.channel.bean.product.SkuStockBatchParam; import me.chanjar.weixin.channel.bean.product.SkuStockBatchResponse; import me.chanjar.weixin.channel.bean.product.SkuStockParam; @@ -211,6 +243,101 @@ public ProductTagLinkResponse getProductTagLink(String productId) throws WxError return ResponseUtils.decode(resJson, ProductTagLinkResponse.class); } + @Override + public ProductSchemeResponse getProductScheme(ProductSchemeParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_SCHEME_URL, reqJson); + return ResponseUtils.decode(resJson, ProductSchemeResponse.class); + } + + @Override + public ProductCategoryClassifyResponse classifyProductCategory(ProductCategoryClassifyParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_CATEGORY_CLASSIFY_URL, reqJson); + return ResponseUtils.decode(resJson, ProductCategoryClassifyResponse.class); + } + + @Override + public WxChannelBaseResponse beginTimingSale(ProductTimingSaleParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_BEGIN_TIMING_SALE_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public WxChannelBaseResponse cancelTimingSale(String productId) throws WxErrorException { + String reqJson = "{\"product_id\":\"" + productId + "\"}"; + String resJson = shopService.post(SPU_CANCEL_TIMING_SALE_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public ExternalProductMappingResponse externalProductMapping(ExternalProductMappingParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_EXTERNAL_PRODUCT_MAPPING_URL, reqJson); + return ResponseUtils.decode(resJson, ExternalProductMappingResponse.class); + } + + @Override + public ProductCategoryPreCheckResponse categoryPreCheck(ProductCategoryPreCheckParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_CATEGORY_PRE_CHECK_URL, reqJson); + return ResponseUtils.decode(resJson, ProductCategoryPreCheckResponse.class); + } + + @Override + public ProductAuditStrategyResponse getProductAuditStrategy() throws WxErrorException { + String resJson = shopService.post(SPU_AUDIT_STRATEGY_GET_URL, "{}"); + return ResponseUtils.decode(resJson, ProductAuditStrategyResponse.class); + } + + @Override + public WxChannelBaseResponse setProductAuditStrategy(ProductAuditStrategySetParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_AUDIT_STRATEGY_SET_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public ProductAuditQuotaResponse getProductAuditQuota() throws WxErrorException { + String resJson = shopService.post(SPU_GET_AUDIT_QUOTA_URL, "{}"); + return ResponseUtils.decode(resJson, ProductAuditQuotaResponse.class); + } + + @Override + public ExternalProductMappingNewResponse externalProductMappingNew(ExternalProductMappingNewParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL, reqJson); + return ResponseUtils.decode(resJson, ExternalProductMappingNewResponse.class); + } + + @Override + public ProductBrandRecommendResponse productBrandRecommend(ProductBrandRecommendParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_PRODUCT_BRAND_RECOMMEND_URL, reqJson); + return ResponseUtils.decode(resJson, ProductBrandRecommendResponse.class); + } + + @Override + public WxChannelBaseResponse addProductThirdPartySource(AddProductThirdPartySourceParam param) + throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL, reqJson); + return ResponseUtils.decode(resJson, WxChannelBaseResponse.class); + } + + @Override + public ProductStockFlowResponse getStockFlow(ProductStockFlowParam param) throws WxErrorException { + String reqJson = JsonUtils.encode(param); + String resJson = shopService.post(SPU_GET_STOCK_FLOW_URL, reqJson); + return ResponseUtils.decode(resJson, ProductStockFlowResponse.class); + } + @Override public LimitTaskAddResponse addLimitTask(LimitTaskParam param) throws WxErrorException { String reqJson = JsonUtils.encode(param); diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/AddProductThirdPartySourceParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/AddProductThirdPartySourceParam.java new file mode 100644 index 0000000000..84dbfd898a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/AddProductThirdPartySourceParam.java @@ -0,0 +1,38 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 新增第三方货源信息请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class AddProductThirdPartySourceParam implements Serializable { + + private static final long serialVersionUID = -5784320217481497742L; + + /** 场景值. */ + @JsonProperty("scene_value") + private Integer sceneValue; + + /** 商品发布方式. */ + @JsonProperty("publish_method") + private Integer publishMethod; + + /** 货主信息. */ + private JsonNode supplier; + + /** 货主店铺经营表现. */ + @JsonProperty("supplier_shop_performance") + private JsonNode supplierShopPerformance; + + /** 商品在货源平台信息. */ + @JsonProperty("product_source_info") + private JsonNode productSourceInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewParam.java new file mode 100644 index 0000000000..fc8c8638f8 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewParam.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.bean.product; + +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 +public class ExternalProductMappingNewParam implements Serializable { + + private static final long serialVersionUID = -7982070319116550518L; + + /** 叶子类目ID. */ + @JsonProperty("cat_id") + private Long catId; + + /** 外部商品类目名称. */ + @JsonProperty("external_category_name") + private String externalCategoryName; + + /** 商品主图. */ + @JsonProperty("head_imgs") + private List headImgs; + + /** 商品详情图. */ + @JsonProperty("detail_imgs") + private List detailImgs; + + /** 商品标题. */ + private String title; + + /** 外部属性列表. */ + @JsonProperty("external_attributes") + private List externalAttributes; + + @Data + @NoArgsConstructor + public static class ExternalAttribute implements Serializable { + private static final long serialVersionUID = 300805187240781417L; + + private String key; + private String value; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewResponse.java new file mode 100644 index 0000000000..7768cc56a6 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingNewResponse.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +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 ExternalProductMappingNewResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 4536547956225312823L; + + /** 映射属性结果. */ + @JsonProperty("attributes") + private List attributes; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingParam.java new file mode 100644 index 0000000000..c5c0826a39 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 站内外商品属性映射请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ExternalProductMappingParam implements Serializable { + + private static final long serialVersionUID = 3288069294712374035L; + + /** 叶子类目ID. */ + @JsonProperty("cat_id") + private Long catId; + + /** 外部商品属性key. */ + @JsonProperty("external_attribute_name") + private String externalAttributeName; + + /** 外部商品属性值. */ + @JsonProperty("external_attribute_value") + private String externalAttributeValue; + + /** 外部商品类目名称. */ + @JsonProperty("external_category_name") + private String externalCategoryName; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingResponse.java new file mode 100644 index 0000000000..7dad51bcb1 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ExternalProductMappingResponse.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ExternalProductMappingResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -8356596972896906087L; + + @JsonProperty("external_attribute_name") + private String externalAttributeName; + + @JsonProperty("external_attribute_value") + private String externalAttributeValue; + + @JsonProperty("internal_attribute_name") + private String internalAttributeName; + + @JsonProperty("internal_attribute_value") + private List internalAttributeValue; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditQuotaResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditQuotaResponse.java new file mode 100644 index 0000000000..7e9dc46c06 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditQuotaResponse.java @@ -0,0 +1,52 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ProductAuditQuotaResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -6242837308752181147L; + + /** 提审配额信息. */ + @JsonProperty("audit_quota") + private AuditQuota auditQuota; + + @Data + @NoArgsConstructor + public static class AuditQuota { + @JsonProperty("block_status") + private Integer blockStatus; + + @JsonProperty("avail_quota") + private Integer availQuota; + + @JsonProperty("total_quota") + private Integer totalQuota; + + @JsonProperty("unlimited_type") + private Integer unlimitedType; + + @JsonProperty("audit_total_quota") + private Integer auditTotalQuota; + + @JsonProperty("audit_total_remaining") + private Integer auditTotalRemaining; + + @JsonProperty("new_product_total_quota") + private Integer newProductTotalQuota; + + @JsonProperty("new_product_total_remaining") + private Integer newProductTotalRemaining; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyInfo.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyInfo.java new file mode 100644 index 0000000000..8f40e32a55 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyInfo.java @@ -0,0 +1,30 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品上架策略信息. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ProductAuditStrategyInfo implements Serializable { + + private static final long serialVersionUID = -2747596416115475981L; + + /** 隐藏商品信息上架策略标识. */ + @JsonProperty("hide_err_field_flag") + private Integer hideErrFieldFlag; + + /** 相似品策略标识. */ + @JsonProperty("hit_duplicated_flag") + private Integer hitDuplicatedFlag; + + /** 低风险规则策略标识. */ + @JsonProperty("hit_low_risk_rule_flag") + private Integer hitLowRiskRuleFlag; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyResponse.java new file mode 100644 index 0000000000..6b3909de89 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategyResponse.java @@ -0,0 +1,24 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ProductAuditStrategyResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = -1074784511408331849L; + + /** 上架策略. */ + @JsonProperty("audit_strategy") + private ProductAuditStrategyInfo auditStrategy; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategySetParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategySetParam.java new file mode 100644 index 0000000000..8412124219 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductAuditStrategySetParam.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 设置商品上架策略请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ProductAuditStrategySetParam implements Serializable { + + private static final long serialVersionUID = 7542738744842032508L; + + /** 上架策略. */ + @JsonProperty("audit_strategy") + private ProductAuditStrategyInfo auditStrategy; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendParam.java new file mode 100644 index 0000000000..0588d71569 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.product; + +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 +public class ProductBrandRecommendParam implements Serializable { + + private static final long serialVersionUID = 6462717198206491138L; + + /** 叶子类目ID. */ + @JsonProperty("cat_id") + private Long catId; + + /** 商品主图. */ + @JsonProperty("head_imgs") + private List headImgs; + + /** 商品详情图. */ + @JsonProperty("detail_imgs") + private List detailImgs; + + /** 商品标题. */ + private String title; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendResponse.java new file mode 100644 index 0000000000..f6e921198b --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductBrandRecommendResponse.java @@ -0,0 +1,32 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ProductBrandRecommendResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 4350605866373432810L; + + /** 品牌ID. */ + @JsonProperty("brand_id") + private Long brandId; + + /** 品牌中文名. */ + @JsonProperty("brand_name_chinese") + private String brandNameChinese; + + /** 品牌英文名. */ + @JsonProperty("brand_name_english") + private String brandNameEnglish; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyParam.java new file mode 100644 index 0000000000..3a7ef9bb60 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyParam.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.channel.bean.product; + +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 +public class ProductCategoryClassifyParam implements Serializable { + + private static final long serialVersionUID = 4665563979720739777L; + + /** 请求类型. */ + @JsonProperty("req_type") + private Integer reqType; + + /** 商品标题. */ + private String title; + + /** 商品主图,至少一个. */ + @JsonProperty("head_imgs") + private List headImgs; + + /** 类目ID,请求类型为2时必填. */ + @JsonProperty("cat_id") + private Long catId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyResponse.java new file mode 100644 index 0000000000..46b579ab79 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryClassifyResponse.java @@ -0,0 +1,48 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ProductCategoryClassifyResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 8258747142248203374L; + + /** 推荐类目. */ + private List categories; + + /** 是否类目错放. */ + @JsonProperty("wrong_cat") + private Boolean wrongCat; + + @Data + @NoArgsConstructor + public static class CategoryInfo { + /** 多级类目. */ + private List cats; + } + + @Data + @NoArgsConstructor + public static class CategoryLevel { + @JsonProperty("cat_id") + private Long catId; + + @JsonProperty("cat_name") + private String catName; + + @JsonProperty("is_shop_no_audit") + private Boolean shopNoAudit; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckParam.java new file mode 100644 index 0000000000..ed3d399e42 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckParam.java @@ -0,0 +1,22 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 发品前校验请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ProductCategoryPreCheckParam implements Serializable { + + private static final long serialVersionUID = 5155253060483296766L; + + /** 叶子类目ID. */ + @JsonProperty("cat_id") + private Long catId; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckResponse.java new file mode 100644 index 0000000000..ca2dfc3fcb --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductCategoryPreCheckResponse.java @@ -0,0 +1,29 @@ +package me.chanjar.weixin.channel.bean.product; + +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 ProductCategoryPreCheckResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7136603000806024499L; + + /** 校验是否通过. */ + @JsonProperty("all_pass") + private Boolean allPass; + + /** 失败原因列表. */ + @JsonProperty("fail_reasons") + private List failReasons; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeParam.java new file mode 100644 index 0000000000..9a24eccf16 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeParam.java @@ -0,0 +1,33 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 获取商品移动应用跳转 scheme 码请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ProductSchemeParam implements Serializable { + + private static final long serialVersionUID = 613832623081127830L; + + /** 商品ID. */ + @JsonProperty("product_id") + private String productId; + + /** 来源appid. */ + @JsonProperty("from_appid") + private String fromAppid; + + /** 过期时间(秒). */ + private Integer expire; + + /** 附加信息. */ + @JsonProperty("ext_info") + private String extInfo; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeResponse.java new file mode 100644 index 0000000000..367ee8795a --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductSchemeResponse.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import me.chanjar.weixin.channel.bean.base.WxChannelBaseResponse; + +/** + * 获取商品移动应用跳转 scheme 码响应. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +@EqualsAndHashCode(callSuper = true) +public class ProductSchemeResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7310433919100539990L; + + /** 商品跳转scheme码. */ + private String openlink; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowParam.java new file mode 100644 index 0000000000..6c52c6b16e --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowParam.java @@ -0,0 +1,51 @@ +package me.chanjar.weixin.channel.bean.product; + +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 +public class ProductStockFlowParam implements Serializable { + + private static final long serialVersionUID = -407227347279113050L; + + /** 内部商品ID. */ + @JsonProperty("product_id") + private String productId; + + /** 内部sku_id. */ + @JsonProperty("sku_id") + private String skuId; + + /** 库存类型. */ + @JsonProperty("stock_type") + private Integer stockType; + + /** 达人finder_id. */ + @JsonProperty("finder_id") + private String finderId; + + /** 开始时间戳(秒). */ + @JsonProperty("begin_time") + private Long beginTime; + + /** 结束时间戳(秒). */ + @JsonProperty("end_time") + private Long endTime; + + /** 库存事件类型列表. */ + @JsonProperty("op_type_list") + private List opTypeList; + + /** 翻页上下文. */ + @JsonProperty("next_key") + private String nextKey; +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowResponse.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowResponse.java new file mode 100644 index 0000000000..b6b5cdbd78 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductStockFlowResponse.java @@ -0,0 +1,37 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.JsonNode; +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 ProductStockFlowResponse extends WxChannelBaseResponse { + + private static final long serialVersionUID = 7600529379926896515L; + + /** 库存流水数据. */ + private StockFlowData data; + + @Data + @NoArgsConstructor + public static class StockFlowData { + /** 库存流水列表. */ + @JsonProperty("stock_flow_info_list") + private List stockFlowInfoList; + + /** 翻页上下文. */ + @JsonProperty("next_key") + private String nextKey; + } +} diff --git a/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductTimingSaleParam.java b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductTimingSaleParam.java new file mode 100644 index 0000000000..a1d66dc993 --- /dev/null +++ b/weixin-java-channel/src/main/java/me/chanjar/weixin/channel/bean/product/ProductTimingSaleParam.java @@ -0,0 +1,26 @@ +package me.chanjar.weixin.channel.bean.product; + +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品立即开售请求参数. + * + * @author GitHub Copilot + */ +@Data +@NoArgsConstructor +public class ProductTimingSaleParam implements Serializable { + + private static final long serialVersionUID = -7185451543781817487L; + + /** 商品ID. */ + @JsonProperty("product_id") + private String productId; + + /** 定时开售任务ID. */ + @JsonProperty("task_id") + private Long taskId; +} 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..748a77f8e2 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 @@ -145,10 +145,36 @@ public interface Spu { String SPU_H5URL_URL = "https://api.weixin.qq.com/channels/ec/product/h5url/get"; /** 获取商品二维码 */ String SPU_QRCODE_URL = "https://api.weixin.qq.com/channels/ec/product/qrcode/get"; + /** 获取商品移动应用跳转scheme码 */ + String SPU_SCHEME_URL = "https://api.weixin.qq.com/channels/ec/product/scheme/get"; /** 获取商品口令 */ String SPU_TAGLINK_URL = "https://api.weixin.qq.com/channels/ec/product/taglink/get"; + /** 商品类目推荐 */ + String SPU_CATEGORY_CLASSIFY_URL = "https://api.weixin.qq.com/channels/ec/product/category/classify"; + /** 商品立即开售 */ + String SPU_BEGIN_TIMING_SALE_URL = "https://api.weixin.qq.com/channels/ec/product/begintimingsale"; + /** 取消商品开售 */ + String SPU_CANCEL_TIMING_SALE_URL = "https://api.weixin.qq.com/channels/ec/product/canceltimingsale"; + /** 站内外商品属性映射 */ + String SPU_EXTERNAL_PRODUCT_MAPPING_URL = "https://api.weixin.qq.com/channels/ec/product/externalproductmapping"; + /** 发品前校验 */ + String SPU_CATEGORY_PRE_CHECK_URL = "https://api.weixin.qq.com/channels/ec/product/categoryprecheck"; + /** 获取商品上架策略 */ + String SPU_AUDIT_STRATEGY_GET_URL = "https://api.weixin.qq.com/channels/ec/product/auditstrategy/get"; + /** 设置商品上架策略 */ + String SPU_AUDIT_STRATEGY_SET_URL = "https://api.weixin.qq.com/channels/ec/product/auditstrategy/set"; + /** 获取商品提审限额 */ + String SPU_GET_AUDIT_QUOTA_URL = "https://api.weixin.qq.com/channels/ec/product/getauditquota"; + /** 商品属性映射及推荐 */ + String SPU_EXTERNAL_PRODUCT_MAPPING_NEW_URL = "https://api.weixin.qq.com/channels/ec/product/externalproductmappingnew"; + /** 商品品牌推荐 */ + String SPU_PRODUCT_BRAND_RECOMMEND_URL = "https://api.weixin.qq.com/channels/ec/product/productbrandrecommend"; + /** 新增第三方货源信息 */ + String SPU_ADD_PRODUCT_THIRD_PARTY_SOURCE_URL = "https://api.weixin.qq.com/channels/ec/product/addproductthirdpartysource"; /** 获取实时库存 */ String SPU_GET_STOCK_URL = "https://api.weixin.qq.com/channels/ec/product/stock/get"; + /** 获取库存流水 */ + String SPU_GET_STOCK_FLOW_URL = "https://api.weixin.qq.com/channels/ec/product/stock/getflow"; /** 获取实时库存 */ String SPU_GET_STOCK_BATCH_URL = "https://api.weixin.qq.com/channels/ec/product/stock/batchget"; /** 更新商品库存 */ diff --git a/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/product/ProductApiBeanTest.java b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/product/ProductApiBeanTest.java new file mode 100644 index 0000000000..c6f0382d9d --- /dev/null +++ b/weixin-java-channel/src/test/java/me/chanjar/weixin/channel/bean/product/ProductApiBeanTest.java @@ -0,0 +1,69 @@ +package me.chanjar.weixin.channel.bean.product; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertNotNull; + +import java.util.Collections; +import me.chanjar.weixin.channel.util.JsonUtils; +import org.testng.annotations.Test; + +/** + * 新增商品管理接口参数/响应模型测试. + * + * @author GitHub Copilot + */ +public class ProductApiBeanTest { + + @Test + public void testEncodeProductSchemeParam() { + ProductSchemeParam param = new ProductSchemeParam(); + param.setProductId("12345"); + param.setFromAppid("wx123"); + param.setExpire(300); + param.setExtInfo("ext"); + + String json = JsonUtils.encode(param); + assertNotNull(json); + assertEquals(json.contains("\"product_id\":\"12345\""), true); + assertEquals(json.contains("\"from_appid\":\"wx123\""), true); + assertEquals(json.contains("\"expire\":300"), true); + } + + @Test + public void testDecodeProductAuditQuotaResponse() { + String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"audit_quota\":{\"avail_quota\":5,\"total_quota\":10}}"; + ProductAuditQuotaResponse response = JsonUtils.decode(json, ProductAuditQuotaResponse.class); + assertNotNull(response); + assertNotNull(response.getAuditQuota()); + assertEquals(response.getAuditQuota().getAvailQuota().intValue(), 5); + assertEquals(response.getAuditQuota().getTotalQuota().intValue(), 10); + } + + @Test + public void testEncodeExternalProductMappingNewParam() { + ExternalProductMappingNewParam.ExternalAttribute attr = new ExternalProductMappingNewParam.ExternalAttribute(); + attr.setKey("材质"); + attr.setValue("棉"); + + ExternalProductMappingNewParam param = new ExternalProductMappingNewParam(); + param.setCatId(6261L); + param.setHeadImgs(Collections.singletonList("https://img.example.com/a.png")); + param.setTitle("测试标题"); + param.setExternalAttributes(Collections.singletonList(attr)); + + String json = JsonUtils.encode(param); + assertNotNull(json); + assertEquals(json.contains("\"cat_id\":6261"), true); + assertEquals(json.contains("\"external_attributes\""), true); + } + + @Test + public void testDecodeProductStockFlowResponse() { + String json = "{\"errcode\":0,\"errmsg\":\"ok\",\"data\":{\"next_key\":\"nk\",\"stock_flow_info_list\":[{\"op_time\":1}]}}"; + ProductStockFlowResponse response = JsonUtils.decode(json, ProductStockFlowResponse.class); + assertNotNull(response); + assertNotNull(response.getData()); + assertEquals(response.getData().getNextKey(), "nk"); + assertEquals(response.getData().getStockFlowInfoList().size(), 1); + } +}