mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 01:19:19 +08:00
refactor: 发布类目属性改用 pdd.goods.cat.rule.get
This commit is contained in:
+6
-6
@@ -10,7 +10,7 @@ import top.xyquan.ecomdmbbackend.common.response.ApiResponse;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
||||
@@ -19,7 +19,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishParentSpecVO;
|
||||
@@ -68,11 +68,11 @@ public class PddGoodsPublishController {
|
||||
return ApiResponse.success("获取成功", publishService.getCostTemplateDetail(query));
|
||||
}
|
||||
|
||||
@PostMapping("/meta/cat-template")
|
||||
@PostMapping("/meta/cat-rule")
|
||||
@RequirePermission(value = "channel:pdd:goods:create", description = "创建拼多多商品", allowSuper = true)
|
||||
public ApiResponse<PddPublishCatTemplateVO> getCatTemplate(
|
||||
@Valid @RequestBody PddPublishCatTemplateQueryDTO query) {
|
||||
return ApiResponse.success("获取成功", publishService.getCatTemplate(query));
|
||||
public ApiResponse<PddPublishCatRuleVO> getCatRule(
|
||||
@Valid @RequestBody PddPublishCatRuleQueryDTO query) {
|
||||
return ApiResponse.success("获取成功", publishService.getCatRule(query));
|
||||
}
|
||||
|
||||
@PostMapping("/meta/specs")
|
||||
|
||||
+4
-1
@@ -3,8 +3,11 @@ package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 类目发布规则查询(pdd.goods.cat.rule.get)。
|
||||
*/
|
||||
@Data
|
||||
public class PddPublishCatTemplateQueryDTO {
|
||||
public class PddPublishCatRuleQueryDTO {
|
||||
|
||||
@NotNull(message = "渠道店铺ID不能为空")
|
||||
private Long pddShopId;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/** 属性条件展示:父属性 refPid + 可选父属性值 vids。 */
|
||||
@Data
|
||||
public class PddPublishCatPropertyShowConditionVO {
|
||||
|
||||
private Long parentRefPid;
|
||||
private List<Long> parentVids;
|
||||
}
|
||||
+22
-8
@@ -4,22 +4,36 @@ import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类目发布属性规则项(来自 cat.rule.get → goods_properties_rule.properties)。
|
||||
*/
|
||||
@Data
|
||||
public class PddPublishCatPropertyVO {
|
||||
|
||||
private Long templatePid;
|
||||
private String name;
|
||||
private String nameAlias;
|
||||
private Long refPid;
|
||||
private Long specId;
|
||||
private Long parentId;
|
||||
/** 销售属性对应的父规格 id */
|
||||
private Long parentSpecId;
|
||||
private Boolean required;
|
||||
private Boolean sale;
|
||||
private Integer controlType;
|
||||
private Integer feature;
|
||||
private Integer valueType;
|
||||
private String valueUnit;
|
||||
/** SKU 维度属性(发品时入参在 sku 下) */
|
||||
private Boolean sku;
|
||||
private Boolean important;
|
||||
private Boolean canNote;
|
||||
/**
|
||||
* 属性值类型:0 文本;1 数值;2 数值范围;3 二维乘积;4 三维乘积;
|
||||
* 5/6 年月日单/双;7/8 年月单/双;9 材质成分表。
|
||||
*/
|
||||
private Integer propertyValueType;
|
||||
private String maxValue;
|
||||
private String minValue;
|
||||
private Integer valuePrecision;
|
||||
/** 可选单位列表 */
|
||||
private List<String> valueUnits;
|
||||
private Integer inputMaxNum;
|
||||
private Integer chooseMaxNum;
|
||||
private Integer requiredRuleType;
|
||||
private String requiredRule;
|
||||
private List<PddPublishCatPropertyShowConditionVO> showCondition;
|
||||
private List<PddPublishCatPropertyValueVO> values;
|
||||
}
|
||||
|
||||
+2
-1
@@ -11,6 +11,7 @@ public class PddPublishCatPropertyValueVO {
|
||||
private String value;
|
||||
private Long specId;
|
||||
private String extendInfo;
|
||||
private Boolean parent;
|
||||
private List<Long> parentVids;
|
||||
private Integer groupId;
|
||||
private String groupName;
|
||||
}
|
||||
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类目发布规则(属性规则 + SKU 规则摘要)。
|
||||
*/
|
||||
@Data
|
||||
public class PddPublishCatRuleVO {
|
||||
|
||||
/** 多个销售属性是否需要同时传 */
|
||||
private Boolean chooseAllQualifySpec;
|
||||
|
||||
/** 允许自定义的销售属性数量 */
|
||||
private Long inputMaxSpecNum;
|
||||
|
||||
/** 同商品下规格值加和上限(goods_sku_rule.spec_num_limit) */
|
||||
private Integer specNumLimit;
|
||||
|
||||
/** 团购价最高差倍率 */
|
||||
private Double priceRangeRatio;
|
||||
|
||||
private List<PddPublishCatPropertyVO> properties;
|
||||
}
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PddPublishCatTemplateVO {
|
||||
|
||||
private Long id;
|
||||
private Long maxSkuNum;
|
||||
private Long inputMaxSpecNum;
|
||||
private Long singleSpecValueNum;
|
||||
private Boolean singleItem;
|
||||
private List<PddPublishCatPropertyVO> properties;
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.service;
|
||||
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||
@@ -11,7 +11,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishTransferImageDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddGoodsPublishResultVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatAuthVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||
@@ -34,7 +34,7 @@ public interface PddGoodsPublishService {
|
||||
|
||||
PddPublishCostTemplateDetailVO getCostTemplateDetail(PddPublishCostTemplateDetailQueryDTO query);
|
||||
|
||||
PddPublishCatTemplateVO getCatTemplate(PddPublishCatTemplateQueryDTO query);
|
||||
PddPublishCatRuleVO getCatRule(PddPublishCatRuleQueryDTO query);
|
||||
|
||||
List<PddPublishParentSpecVO> listParentSpecs(PddPublishSpecQueryDTO query);
|
||||
|
||||
|
||||
+38
-24
@@ -16,7 +16,7 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.Pdd
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddGoodsPublishSkuPropertyDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatAuthQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCostTemplateDetailQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatTemplateQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishCatRuleQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishLogisticsQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishShopCatQueryDTO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.dto.publish.PddPublishSpecIdCreateDTO;
|
||||
@@ -29,7 +29,8 @@ import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddP
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyValueVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCostTemplateDetailVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatTemplateVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatPropertyShowConditionVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatRuleVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishCatVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsPageVO;
|
||||
import top.xyquan.ecomdmbbackend.modules.channel.pdd.goods.model.vo.publish.PddPublishLogisticsTemplateVO;
|
||||
@@ -206,15 +207,15 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PddPublishCatTemplateVO getCatTemplate(PddPublishCatTemplateQueryDTO query) {
|
||||
public PddPublishCatRuleVO getCatRule(PddPublishCatRuleQueryDTO query) {
|
||||
ShopAuth ctx = requireShopAuth(query.getPddShopId());
|
||||
try {
|
||||
var tpl = publishPopApiClient.getCatTemplate(ctx.mallId(), ctx.accessToken(), query.getCatId());
|
||||
return mapCatTemplate(tpl);
|
||||
var rule = publishPopApiClient.getCatRule(ctx.mallId(), ctx.accessToken(), query.getCatId());
|
||||
return mapCatRule(rule);
|
||||
} catch (BusinessException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw wrapPop("查询类目属性模板失败", e);
|
||||
throw wrapPop("查询类目发布规则失败", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -695,31 +696,43 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
return parts.isEmpty() ? null : String.join(";", parts);
|
||||
}
|
||||
|
||||
private PddPublishCatTemplateVO mapCatTemplate(PddGoodsPublishPopApiClient.CatTemplate tpl) {
|
||||
PddPublishCatTemplateVO vo = new PddPublishCatTemplateVO();
|
||||
vo.setId(tpl.id());
|
||||
vo.setMaxSkuNum(tpl.maxSkuNum());
|
||||
vo.setInputMaxSpecNum(tpl.inputMaxSpecNum());
|
||||
vo.setSingleSpecValueNum(tpl.singleSpecValueNum());
|
||||
vo.setSingleItem(tpl.singleItem());
|
||||
private PddPublishCatRuleVO mapCatRule(PddGoodsPublishPopApiClient.CatRule rule) {
|
||||
PddPublishCatRuleVO vo = new PddPublishCatRuleVO();
|
||||
vo.setChooseAllQualifySpec(rule.chooseAllQualifySpec());
|
||||
vo.setInputMaxSpecNum(rule.inputMaxSpecNum());
|
||||
vo.setSpecNumLimit(rule.specNumLimit());
|
||||
vo.setPriceRangeRatio(rule.priceRangeRatio());
|
||||
List<PddPublishCatPropertyVO> props = new ArrayList<>();
|
||||
if (tpl.properties() != null) {
|
||||
for (var p : tpl.properties()) {
|
||||
if (rule.properties() != null) {
|
||||
for (var p : rule.properties()) {
|
||||
PddPublishCatPropertyVO pv = new PddPublishCatPropertyVO();
|
||||
pv.setTemplatePid(p.templatePid());
|
||||
pv.setName(p.name());
|
||||
pv.setNameAlias(p.nameAlias());
|
||||
pv.setRefPid(p.refPid());
|
||||
pv.setSpecId(p.specId());
|
||||
pv.setParentId(p.parentId());
|
||||
pv.setParentSpecId(p.parentSpecId());
|
||||
pv.setRequired(p.required());
|
||||
pv.setSale(p.sale());
|
||||
pv.setControlType(p.controlType());
|
||||
pv.setFeature(p.feature());
|
||||
pv.setValueType(p.valueType());
|
||||
pv.setValueUnit(p.valueUnit());
|
||||
pv.setSku(p.sku());
|
||||
pv.setImportant(p.important());
|
||||
pv.setCanNote(p.canNote());
|
||||
pv.setPropertyValueType(p.propertyValueType());
|
||||
pv.setMaxValue(p.maxValue());
|
||||
pv.setMinValue(p.minValue());
|
||||
pv.setValuePrecision(p.valuePrecision());
|
||||
pv.setValueUnits(p.valueUnits());
|
||||
pv.setInputMaxNum(p.inputMaxNum());
|
||||
pv.setChooseMaxNum(p.chooseMaxNum());
|
||||
pv.setRequiredRuleType(p.requiredRuleType());
|
||||
pv.setRequiredRule(p.requiredRule());
|
||||
List<PddPublishCatPropertyShowConditionVO> showConds = new ArrayList<>();
|
||||
if (p.showCondition() != null) {
|
||||
for (var c : p.showCondition()) {
|
||||
PddPublishCatPropertyShowConditionVO cv = new PddPublishCatPropertyShowConditionVO();
|
||||
cv.setParentRefPid(c.parentRefPid());
|
||||
cv.setParentVids(c.parentVids());
|
||||
showConds.add(cv);
|
||||
}
|
||||
}
|
||||
pv.setShowCondition(showConds);
|
||||
List<PddPublishCatPropertyValueVO> values = new ArrayList<>();
|
||||
if (p.values() != null) {
|
||||
for (var v : p.values()) {
|
||||
@@ -728,8 +741,9 @@ public class PddGoodsPublishServiceImpl implements PddGoodsPublishService {
|
||||
vv.setValue(v.value());
|
||||
vv.setSpecId(v.specId());
|
||||
vv.setExtendInfo(v.extendInfo());
|
||||
vv.setParent(v.parent());
|
||||
vv.setParentVids(v.parentVids());
|
||||
vv.setGroupId(v.groupId());
|
||||
vv.setGroupName(v.groupName());
|
||||
values.add(vv);
|
||||
}
|
||||
}
|
||||
|
||||
+4
@@ -27,7 +27,11 @@ public final class PddPopApiTypes {
|
||||
/** 平台全量类目树(无需 accessToken) */
|
||||
public static final String GOODS_CATS_GET = "pdd.goods.cats.get";
|
||||
public static final String GOODS_LOGISTICS_TEMPLATE_GET = "pdd.goods.logistics.template.get";
|
||||
/** @deprecated 已废弃,请用 {@link #GOODS_CAT_RULE_GET} */
|
||||
@Deprecated
|
||||
public static final String GOODS_CAT_TEMPLATE_GET = "pdd.goods.cat.template.get";
|
||||
/** 类目商品发布规则(含属性,替代 cat.template.get) */
|
||||
public static final String GOODS_CAT_RULE_GET = "pdd.goods.cat.rule.get";
|
||||
public static final String GOODS_SPEC_GET = "pdd.goods.spec.get";
|
||||
public static final String GOODS_SPEC_ID_GET = "pdd.goods.spec.id.get";
|
||||
public static final String ONE_EXPRESS_COST_TEMPLATE = "pdd.one.express.cost.template";
|
||||
|
||||
+63
-38
@@ -4,7 +4,7 @@ import com.pdd.pop.sdk.http.api.pop.request.PddGoodsAddRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsEditGoodsCommitRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSubmitGoodsCommitRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsAuthorizationCatsRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsCatTemplateGetRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsCatRuleGetRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsImageUploadRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsLogisticsTemplateGetRequest;
|
||||
import com.pdd.pop.sdk.http.api.pop.request.PddGoodsSpecGetRequest;
|
||||
@@ -14,7 +14,7 @@ import com.pdd.pop.sdk.http.api.pop.response.PddGoodsAddResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsEditGoodsCommitResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSubmitGoodsCommitResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsAuthorizationCatsResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsCatTemplateGetResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsCatRuleGetResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsImageUploadResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsLogisticsTemplateGetResponse;
|
||||
import com.pdd.pop.sdk.http.api.pop.response.PddGoodsSpecGetResponse;
|
||||
@@ -32,7 +32,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品发布域 POP:类目/运费模板/属性模板/规格/传图/新增/平台草稿。
|
||||
* 商品发布域 POP:类目/运费模板/发布规则(属性)/规格/传图/新增/平台草稿。
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@@ -90,17 +90,17 @@ public class PddGoodsPublishPopApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
/** 叶子类目属性模板。 */
|
||||
public CatTemplate getCatTemplate(Long mallId, String accessToken, Long catId) throws Exception {
|
||||
/** 叶子类目发布规则(属性 + SKU 限制等)。 */
|
||||
public CatRule getCatRule(Long mallId, String accessToken, Long catId) throws Exception {
|
||||
if (catId == null) {
|
||||
throw new BusinessException("类目ID不能为空");
|
||||
}
|
||||
return invokeSupport.invoke(PddPopApiTypes.GOODS_CAT_TEMPLATE_GET, mallId, client -> {
|
||||
PddGoodsCatTemplateGetRequest request = new PddGoodsCatTemplateGetRequest();
|
||||
return invokeSupport.invoke(PddPopApiTypes.GOODS_CAT_RULE_GET, mallId, client -> {
|
||||
PddGoodsCatRuleGetRequest request = new PddGoodsCatRuleGetRequest();
|
||||
request.setCatId(catId);
|
||||
PddGoodsCatTemplateGetResponse response = client.syncInvoke(request, accessToken);
|
||||
invokeSupport.assertNoError(response, PddPopApiTypes.GOODS_CAT_TEMPLATE_GET);
|
||||
return mapCatTemplate(response);
|
||||
PddGoodsCatRuleGetResponse response = client.syncInvoke(request, accessToken);
|
||||
invokeSupport.assertNoError(response, PddPopApiTypes.GOODS_CAT_RULE_GET);
|
||||
return mapCatRule(response);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -555,14 +555,17 @@ public class PddGoodsPublishPopApiClient {
|
||||
Collections.unmodifiableList(houseAreas));
|
||||
}
|
||||
|
||||
private CatTemplate mapCatTemplate(PddGoodsCatTemplateGetResponse response) {
|
||||
if (response == null || response.getOpenApiResponse() == null) {
|
||||
return new CatTemplate(null, null, null, null, null, List.of());
|
||||
private CatRule mapCatRule(PddGoodsCatRuleGetResponse response) {
|
||||
if (response == null || response.getCatRuleGetResponse() == null) {
|
||||
return new CatRule(null, null, null, null, List.of());
|
||||
}
|
||||
var body = response.getOpenApiResponse();
|
||||
var root = response.getCatRuleGetResponse();
|
||||
var propRule = root.getGoodsPropertiesRule();
|
||||
var skuRule = root.getGoodsSkuRule();
|
||||
|
||||
List<CatProperty> props = new ArrayList<>();
|
||||
if (body.getProperties() != null) {
|
||||
for (var p : body.getProperties()) {
|
||||
if (propRule != null && propRule.getProperties() != null) {
|
||||
for (var p : propRule.getProperties()) {
|
||||
if (p == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -572,35 +575,52 @@ public class PddGoodsPublishPopApiClient {
|
||||
if (v == null) {
|
||||
continue;
|
||||
}
|
||||
Integer groupId = v.getGroup() != null ? v.getGroup().getId() : null;
|
||||
String groupName = v.getGroup() != null ? v.getGroup().getName() : null;
|
||||
values.add(new CatPropertyValue(
|
||||
v.getVid(), v.getValue(), v.getSpecId(), v.getExtendInfo(),
|
||||
v.getIsParent(), v.getParentVids()));
|
||||
v.getParentVids(), groupId, groupName));
|
||||
}
|
||||
}
|
||||
List<CatPropertyShowCondition> showConds = new ArrayList<>();
|
||||
if (p.getShowCondition() != null) {
|
||||
for (var c : p.getShowCondition()) {
|
||||
if (c == null) {
|
||||
continue;
|
||||
}
|
||||
showConds.add(new CatPropertyShowCondition(c.getParentRefPid(), c.getParentVids()));
|
||||
}
|
||||
}
|
||||
List<String> units = p.getValueUnit() != null
|
||||
? List.copyOf(p.getValueUnit())
|
||||
: List.of();
|
||||
props.add(new CatProperty(
|
||||
p.getId(),
|
||||
p.getName(),
|
||||
p.getNameAlias(),
|
||||
p.getRefPid(),
|
||||
p.getSpecId(),
|
||||
p.getParentId(),
|
||||
p.getParentSpecId(),
|
||||
Boolean.TRUE.equals(p.getRequired()),
|
||||
Boolean.TRUE.equals(p.getIsSale()),
|
||||
p.getControlType(),
|
||||
p.getFeature(),
|
||||
p.getValueType(),
|
||||
p.getValueUnit(),
|
||||
Boolean.TRUE.equals(p.getIsSku()),
|
||||
Boolean.TRUE.equals(p.getIsImportant()),
|
||||
Boolean.TRUE.equals(p.getCanNote()),
|
||||
p.getPropertyValueType(),
|
||||
p.getMaxValue(),
|
||||
p.getMinValue(),
|
||||
p.getValuePrecision(),
|
||||
units,
|
||||
p.getInputMaxNum(),
|
||||
p.getChooseMaxNum(),
|
||||
p.getRequiredRuleType(),
|
||||
p.getRequiredRule(),
|
||||
Collections.unmodifiableList(showConds),
|
||||
Collections.unmodifiableList(values)));
|
||||
}
|
||||
}
|
||||
return new CatTemplate(
|
||||
body.getId(),
|
||||
body.getMaxSkuNum(),
|
||||
body.getInputMaxSpecNum(),
|
||||
body.getSingleSpecValueNum(),
|
||||
body.getIsSingleItem(),
|
||||
return new CatRule(
|
||||
propRule != null ? propRule.getChooseAllQualifySpec() : null,
|
||||
propRule != null ? propRule.getInputMaxSpecNum() : null,
|
||||
skuRule != null ? skuRule.getSpecNumLimit() : null,
|
||||
skuRule != null ? skuRule.getPriceRangeRatio() : null,
|
||||
Collections.unmodifiableList(props));
|
||||
}
|
||||
|
||||
@@ -665,18 +685,23 @@ public class PddGoodsPublishPopApiClient {
|
||||
String province, String city, String town) {
|
||||
}
|
||||
|
||||
public record CatTemplate(Long id, Long maxSkuNum, Long inputMaxSpecNum, Long singleSpecValueNum,
|
||||
Boolean singleItem, List<CatProperty> properties) {
|
||||
public record CatRule(Boolean chooseAllQualifySpec, Long inputMaxSpecNum, Integer specNumLimit,
|
||||
Double priceRangeRatio, List<CatProperty> properties) {
|
||||
}
|
||||
|
||||
public record CatProperty(Long templatePid, String name, String nameAlias, Long refPid, Long specId,
|
||||
Long parentId, boolean required, boolean sale, Integer controlType,
|
||||
Integer feature, Integer valueType, String valueUnit,
|
||||
Integer inputMaxNum, Integer chooseMaxNum, List<CatPropertyValue> values) {
|
||||
public record CatProperty(String name, Long refPid, Long parentSpecId, boolean required, boolean sale,
|
||||
boolean sku, boolean important, boolean canNote, Integer propertyValueType,
|
||||
String maxValue, String minValue, Integer valuePrecision,
|
||||
List<String> valueUnits, Integer inputMaxNum, Integer chooseMaxNum,
|
||||
Integer requiredRuleType, String requiredRule,
|
||||
List<CatPropertyShowCondition> showCondition, List<CatPropertyValue> values) {
|
||||
}
|
||||
|
||||
public record CatPropertyShowCondition(Long parentRefPid, List<Long> parentVids) {
|
||||
}
|
||||
|
||||
public record CatPropertyValue(Long vid, String value, Long specId, String extendInfo,
|
||||
Boolean parent, List<Long> parentVids) {
|
||||
List<Long> parentVids, Integer groupId, String groupName) {
|
||||
}
|
||||
|
||||
public record ParentSpecItem(Long catId, Long parentSpecId, String parentSpecName) {
|
||||
|
||||
@@ -66,7 +66,7 @@ pdd:
|
||||
shop-window-seconds: 60
|
||||
app-burst-limit: 800
|
||||
app-burst-window-seconds: 10
|
||||
pdd.goods.cat.template.get:
|
||||
pdd.goods.cat.rule.get:
|
||||
shop-limit: 6000
|
||||
shop-window-seconds: 60
|
||||
app-burst-limit: 800
|
||||
|
||||
Reference in New Issue
Block a user