修改配置
This commit is contained in:
parent
47750a72a3
commit
11799310ca
|
|
@ -126,7 +126,7 @@ public class ExternalPddPublishService {
|
|||
if (props.isAutoFetchCatRule() && !catFetched) {
|
||||
try {
|
||||
JSONObject body = new JSONObject();
|
||||
body.put("cat_id", catId);
|
||||
body.put("cat_id", String.valueOf(catId));
|
||||
String raw = pddPopClient.invoke(gateway, cred.getAppKey(), cred.getAppSecret(), cred.getAccessToken(),
|
||||
"pdd.goods.cat.rule.get", JSON.toJSONString(body));
|
||||
catRuleSnippet = PddOpenApiSupport.snippet(raw, 2000);
|
||||
|
|
|
|||
|
|
@ -72,8 +72,12 @@ public class PddCatRuleSpecAutoResolver {
|
|||
* 调用 pdd.goods.cat.rule.get
|
||||
*/
|
||||
public String fetchCatRuleJson(PddShopCredential cred, String gatewayUrl, long catId) throws Exception {
|
||||
if (catId <= 0) {
|
||||
throw new IllegalArgumentException("cat_id 必须为正数,当前=" + catId);
|
||||
}
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("cat_id", catId);
|
||||
// 与 POP 文档示例一致:param_json 内 cat_id 使用字符串,避免网关报「cat_id 不能为空」
|
||||
p.put("cat_id", String.valueOf(catId));
|
||||
return popClient.invoke(
|
||||
gatewayUrl,
|
||||
cred.getAppKey(),
|
||||
|
|
@ -102,7 +106,7 @@ public class PddCatRuleSpecAutoResolver {
|
|||
throw new IllegalStateException("无法解析 SKU 规格名:outSkuId=" + row.getOuterErpSkuId());
|
||||
}
|
||||
JSONObject p = new JSONObject();
|
||||
p.put("cat_id", catId);
|
||||
p.put("cat_id", String.valueOf(catId));
|
||||
p.put("parent_spec_id", parentSpecId);
|
||||
p.put("spec_name", specName.trim());
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import java.math.BigDecimal;
|
|||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 将 Canonical 落库结果组装为 pdd.goods.add 的 param_json。
|
||||
|
|
@ -55,7 +56,8 @@ public class PddGoodsAddParamBuilder {
|
|||
|
||||
JSONObject root = new JSONObject();
|
||||
root.put("auto_fill_spu_property", true);
|
||||
root.put("cat_id", catId);
|
||||
// POP 文档示例多为字符串型 cat_id,网关对纯数字字段部分场景校验更稳
|
||||
root.put("cat_id", String.valueOf(catId));
|
||||
root.put("cost_template_id", costTpl);
|
||||
root.put("country_id", props.getDefaultCountryId());
|
||||
root.put("goods_type", props.getDefaultGoodsType());
|
||||
|
|
@ -154,11 +156,27 @@ public class PddGoodsAddParamBuilder {
|
|||
return props.getDefaultShipmentLimitSecond();
|
||||
}
|
||||
|
||||
/**
|
||||
* categoryCode 对应映射须为正数;若键存在但值为 null/≤0,再尝试 {@code DEFAULT}。
|
||||
*/
|
||||
private static Long resolveCatId(String categoryCode, ExternalPddProperties props) {
|
||||
if (StringUtils.hasText(categoryCode) && props.getCategoryMap().containsKey(categoryCode)) {
|
||||
return props.getCategoryMap().get(categoryCode);
|
||||
Map<String, Long> m = props.getCategoryMap();
|
||||
if (m == null || m.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return props.getCategoryMap().get("DEFAULT");
|
||||
Long v = pickPositiveCatId(m, categoryCode);
|
||||
if (v != null) {
|
||||
return v;
|
||||
}
|
||||
return pickPositiveCatId(m, "DEFAULT");
|
||||
}
|
||||
|
||||
private static Long pickPositiveCatId(Map<String, Long> m, String key) {
|
||||
if (!StringUtils.hasText(key) || !m.containsKey(key)) {
|
||||
return null;
|
||||
}
|
||||
Long v = m.get(key);
|
||||
return (v != null && v > 0) ? v : null;
|
||||
}
|
||||
|
||||
private static Long resolveCostTemplate(String logisticsTemplateCode, ExternalPddProperties props) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue