feat(erp-api): 开启 external.pdd.publish-enabled 并补全默认映射模板;upsert 增加 PDD 配置与结果摘要日志
Made-with: Cursor
This commit is contained in:
parent
d1cf874ab8
commit
931eb62022
|
|
@ -80,6 +80,15 @@ public class ExternalGoodsController extends BaseController {
|
||||||
return AjaxResult.error("platform不合法");
|
return AjaxResult.error("platform不合法");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (EnumShopType.PDD.equals(platform)) {
|
||||||
|
log.info("[external/goods/upsert] pdd.publish-enabled={} gatewayHost={} categoryMapKeys={}",
|
||||||
|
externalPddProperties.isPublishEnabled(),
|
||||||
|
safeHostForLog(externalPddProperties.getGatewayUrl()),
|
||||||
|
externalPddProperties.getCategoryMap() != null
|
||||||
|
? externalPddProperties.getCategoryMap().keySet().toString()
|
||||||
|
: "null");
|
||||||
|
}
|
||||||
|
|
||||||
if (EnumShopType.PDD.equals(platform) && externalPddProperties.isPublishEnabled()) {
|
if (EnumShopType.PDD.equals(platform) && externalPddProperties.isPublishEnabled()) {
|
||||||
if (req.getPddPopAuth() == null) {
|
if (req.getPddPopAuth() == null) {
|
||||||
return AjaxResult.error("参数错误:开启拼多多发布时 pddPopAuth 不能为空");
|
return AjaxResult.error("参数错误:开启拼多多发布时 pddPopAuth 不能为空");
|
||||||
|
|
@ -95,8 +104,10 @@ public class ExternalGoodsController extends BaseController {
|
||||||
log.info("[external/goods/upsert] response shopId={} outGoodsId={} erpGoodsId={} platform={}",
|
log.info("[external/goods/upsert] response shopId={} outGoodsId={} erpGoodsId={} platform={}",
|
||||||
req.getShopId(), req.getOutGoodsId(), vo.getGoodsId(), req.getPlatform());
|
req.getShopId(), req.getOutGoodsId(), vo.getGoodsId(), req.getPlatform());
|
||||||
if (EnumShopType.PDD.equals(platform)) {
|
if (EnumShopType.PDD.equals(platform)) {
|
||||||
log.info("[external/goods/upsert] pddPublish attempted={} success={}",
|
log.info("[external/goods/upsert] pddPublish attempted={} success={} message={}",
|
||||||
vo.getPddPublishAttempted(), vo.getPddPublishSuccess());
|
vo.getPddPublishAttempted(),
|
||||||
|
vo.getPddPublishSuccess(),
|
||||||
|
truncateLog(vo.getPddPublishMessage(), 800));
|
||||||
}
|
}
|
||||||
return AjaxResult.success(vo);
|
return AjaxResult.success(vo);
|
||||||
}
|
}
|
||||||
|
|
@ -123,6 +134,26 @@ public class ExternalGoodsController extends BaseController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String safeHostForLog(String gatewayUrl) {
|
||||||
|
if (!StringUtils.hasText(gatewayUrl)) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
java.net.URI u = java.net.URI.create(gatewayUrl.trim());
|
||||||
|
String h = u.getHost();
|
||||||
|
return h != null ? h : gatewayUrl.trim();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return gatewayUrl.trim();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String truncateLog(String s, int max) {
|
||||||
|
if (s == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return s.length() <= max ? s : s.substring(0, max) + "...";
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean hasMainVisual(ExternalGoodsUpsertRequest req) {
|
private static boolean hasMainVisual(ExternalGoodsUpsertRequest req) {
|
||||||
if (StringUtils.hasText(req.getMainImage())) {
|
if (StringUtils.hasText(req.getMainImage())) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,20 @@ external:
|
||||||
goods:
|
goods:
|
||||||
log-full-request: true
|
log-full-request: true
|
||||||
|
|
||||||
|
# 拼多多 POP:upsert 落库后是否调用 pdd.goods.add(须与 maindata yundt.maindata.erp-open.default-category-code 等对齐)
|
||||||
|
pdd:
|
||||||
|
publish-enabled: true
|
||||||
|
gateway-url: https://gw-api.pinduoduo.com/api/router
|
||||||
|
# 发布前可选拉类目规则(诊断用)
|
||||||
|
auto-fetch-cat-rule: false
|
||||||
|
# sku-overrides 为空时按类目规则 + spec.id 自动拼规格(与 SKU 条数一致时才继续调 goods.add)
|
||||||
|
auto-resolve-spec-ids-when-sku-overrides-empty: true
|
||||||
|
# categoryCode(请求体)-> 拼多多叶子类目 cat_id;DEFAULT 与 maindata 默认 categoryCode 一致,0 表示未配置须改为真实 ID
|
||||||
|
category-map:
|
||||||
|
DEFAULT: 0
|
||||||
|
# logisticsTemplateCode -> cost_template_id;0 表示未配置须改为店铺运费模板 ID
|
||||||
|
cost-template-map:
|
||||||
|
DEFAULT: 0
|
||||||
|
sku-overrides: []
|
||||||
|
|
||||||
# 说明:对外商品接口见 temp/yunxi-erp-open-goods-upsert-api.md;Nacos 对齐见 temp/erp-open-erp-api-nacos-yunxi-reference.md
|
# 说明:对外商品接口见 temp/yunxi-erp-open-goods-upsert-api.md;Nacos 对齐见 temp/erp-open-erp-api-nacos-yunxi-reference.md
|
||||||
|
|
|
||||||
|
|
@ -39,10 +39,14 @@ external:
|
||||||
# 生产上线后改为 false
|
# 生产上线后改为 false
|
||||||
log-full-request: true
|
log-full-request: true
|
||||||
|
|
||||||
# 拼多多:默认关闭发布;开启时请取消注释并补全 category-map / cost-template-map / sku-overrides
|
# 拼多多 POP:与 jar 内 application.yml 对齐;Nacos 下发会覆盖本地
|
||||||
#pdd:
|
pdd:
|
||||||
# publish-enabled: false
|
publish-enabled: true
|
||||||
# gateway-url: https://gw-api.pinduoduo.com/api/router
|
gateway-url: https://gw-api.pinduoduo.com/api/router
|
||||||
# category-map: {}
|
auto-fetch-cat-rule: false
|
||||||
# cost-template-map: {}
|
auto-resolve-spec-ids-when-sku-overrides-empty: true
|
||||||
# sku-overrides: []
|
category-map:
|
||||||
|
DEFAULT: 0
|
||||||
|
cost-template-map:
|
||||||
|
DEFAULT: 0
|
||||||
|
sku-overrides: []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue