fix(pdd): sku_list 对齐 POP 文档(spec_id_list 字符串、price/multi_price 分数字符串)
Made-with: Cursor
This commit is contained in:
parent
b88f812ceb
commit
532e5fc78e
|
|
@ -15,7 +15,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼多多发布:POP 凭证仅来自本次请求的 {@link ExternalGoodsUpsertRequest#getPddPopAuth()};不依赖 {@code o_shop}。
|
* 拼多多发布:POP 凭证仅来自本次请求的 {@link ExternalGoodsUpsertRequest#getPddPopAuth()};不依赖 {@code o_shop}。
|
||||||
* 可选自动拉取类目规则与 spec.id;图书等 {@code input_max_spec_num=0} 类目可走无规格单 SKU({@code sku_list} 项不传 {@code spec_id_list}/{@code spec_detail_list})。
|
* 可选自动拉取类目规则与 spec.id;图书等 {@code input_max_spec_num=0} 类目可走无规格单 SKU({@code sku_list} 与 POP 文档一致:{@code spec_id_list} 字符串 {@code "[]"},{@code price}/{@code multi_price} 分数字符串)。
|
||||||
*
|
*
|
||||||
* @author guochengyu
|
* @author guochengyu
|
||||||
*/
|
*/
|
||||||
|
|
@ -108,7 +108,7 @@ public class ExternalPddPublishService {
|
||||||
specAuto = true;
|
specAuto = true;
|
||||||
} else if (PddOpenApiSupport.isNoSpecBookCatRule(ar.getCatRuleRaw()) && skuRows.size() == 1) {
|
} else if (PddOpenApiSupport.isNoSpecBookCatRule(ar.getCatRuleRaw()) && skuRows.size() == 1) {
|
||||||
noSpecBookPublish = true;
|
noSpecBookPublish = true;
|
||||||
autoDetail = "类目 input_max_spec_num=0:拼多多无规格发品(单 sku_list,不传 spec_id_list/spec_detail_list,未调用 spec.id.get)";
|
autoDetail = "类目 input_max_spec_num=0:拼多多无规格发品(单 sku_list,spec_id_list=\"[]\" 字符串,price/multi_price 分数字符串,未调用 spec.id.get)";
|
||||||
log.info("[PDD] no-spec book publish shopId={} outGoodsId={}", req.getShopId(), req.getOutGoodsId());
|
log.info("[PDD] no-spec book publish shopId={} outGoodsId={}", req.getShopId(), req.getOutGoodsId());
|
||||||
} else if (PddOpenApiSupport.isNoSpecBookCatRule(ar.getCatRuleRaw())) {
|
} else if (PddOpenApiSupport.isNoSpecBookCatRule(ar.getCatRuleRaw())) {
|
||||||
log.info("[PDD] publish skipped shopId={} outGoodsId={} reason=no-spec-requires-single-sku skuCount={}",
|
log.info("[PDD] publish skipped shopId={} outGoodsId={} reason=no-spec-requires-single-sku skuCount={}",
|
||||||
|
|
|
||||||
|
|
@ -112,8 +112,9 @@ public class PddGoodsAddParamBuilder {
|
||||||
JSONObject sku = new JSONObject();
|
JSONObject sku = new JSONObject();
|
||||||
sku.put("is_onsale", 1);
|
sku.put("is_onsale", 1);
|
||||||
sku.put("limit_quantity", 999L);
|
sku.put("limit_quantity", 999L);
|
||||||
sku.put("multi_price", groupFen);
|
// POP 文档:sku_list 内 multi_price / price 为分数字符串,如 "1900"、"2200"
|
||||||
sku.put("price", singleFen);
|
sku.put("multi_price", fenAsSkuPriceString(groupFen));
|
||||||
|
sku.put("price", fenAsSkuPriceString(singleFen));
|
||||||
sku.put("quantity", row.getStockQty() != null ? row.getStockQty().longValue() : 0L);
|
sku.put("quantity", row.getStockQty() != null ? row.getStockQty().longValue() : 0L);
|
||||||
sku.put("weight", row.getWeightGram() != null ? row.getWeightGram() : 1000L);
|
sku.put("weight", row.getWeightGram() != null ? row.getWeightGram() : 1000L);
|
||||||
sku.put("spec_id_list", ov.getSpecIdList());
|
sku.put("spec_id_list", ov.getSpecIdList());
|
||||||
|
|
@ -151,8 +152,9 @@ public class PddGoodsAddParamBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拼多多「无规格」发品(如图书 {@code input_max_spec_num=0}):仅一条 {@code sku_list},
|
* 拼多多「无规格」发品(如图书 {@code input_max_spec_num=0}):仅一条 {@code sku_list}。
|
||||||
* SKU 对象不传 {@code spec_id_list}、{@code spec_detail_list};根级 {@code is_sku=false},不调用 {@code spec.id.get}。
|
* 与 POP 文档一致:{@code spec_id_list} 为<strong>字符串</strong>形式的 JSON 数组,无规格为 {@code "[]"}(有规格如 {@code "[25]"});
|
||||||
|
* {@code price}/{@code multi_price} 为<strong>分数字符串</strong>;不传 {@code spec_detail_list};根级 {@code is_sku=false}。
|
||||||
* <p>调用方须保证过滤后仅 1 条有效 SKU。</p>
|
* <p>调用方须保证过滤后仅 1 条有效 SKU。</p>
|
||||||
*/
|
*/
|
||||||
public String buildParamJsonNoSpecBook(OGoods goods, List<OGoodsSku> skus, ExternalGoodsUpsertRequest req,
|
public String buildParamJsonNoSpecBook(OGoods goods, List<OGoodsSku> skus, ExternalGoodsUpsertRequest req,
|
||||||
|
|
@ -230,10 +232,11 @@ public class PddGoodsAddParamBuilder {
|
||||||
JSONObject sku = new JSONObject();
|
JSONObject sku = new JSONObject();
|
||||||
sku.put("is_onsale", 1);
|
sku.put("is_onsale", 1);
|
||||||
sku.put("limit_quantity", 999L);
|
sku.put("limit_quantity", 999L);
|
||||||
sku.put("multi_price", groupFen);
|
sku.put("multi_price", fenAsSkuPriceString(groupFen));
|
||||||
sku.put("price", singleFen);
|
sku.put("price", fenAsSkuPriceString(singleFen));
|
||||||
sku.put("quantity", qty);
|
sku.put("quantity", qty);
|
||||||
sku.put("weight", row.getWeightGram() != null ? row.getWeightGram() : 1000L);
|
sku.put("weight", row.getWeightGram() != null ? row.getWeightGram() : 1000L);
|
||||||
|
sku.put("spec_id_list", "[]");
|
||||||
sku.put("thumb_url", StringUtils.hasText(row.getSkuImageUrl()) ? row.getSkuImageUrl() : carousel.get(0));
|
sku.put("thumb_url", StringUtils.hasText(row.getSkuImageUrl()) ? row.getSkuImageUrl() : carousel.get(0));
|
||||||
if (StringUtils.hasText(row.getOuterErpSkuId())) {
|
if (StringUtils.hasText(row.getOuterErpSkuId())) {
|
||||||
sku.put("out_sku_sn", row.getOuterErpSkuId());
|
sku.put("out_sku_sn", row.getOuterErpSkuId());
|
||||||
|
|
@ -376,6 +379,11 @@ public class PddGoodsAddParamBuilder {
|
||||||
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
return yuan.multiply(BigDecimal.valueOf(100)).setScale(0, RoundingMode.HALF_UP).longValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** POP 文档示例中 sku_list 的 price、multi_price 为分数字符串。 */
|
||||||
|
private static String fenAsSkuPriceString(long fen) {
|
||||||
|
return Long.toString(fen);
|
||||||
|
}
|
||||||
|
|
||||||
private static BigDecimal firstNonNull(BigDecimal a, BigDecimal b) {
|
private static BigDecimal firstNonNull(BigDecimal a, BigDecimal b) {
|
||||||
return a != null ? a : b;
|
return a != null ? a : b;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue