Browse Source

feat(product): SKU 搜索条件(平台 SKU / 本地 SKU)

SDK 层(core):
- 新增 ProductSearchField:PLATFORM_SKU / LOCAL_SKU,只定义跨平台语义一致的维度
- ProductQuery 增加 searchField / searchValue(单值模糊)/ searchValues(多值精确)
  - 有搜索值但没 searchField 直接抛异常
  - 单值与多值互斥,同时设置直接抛异常
  - 新增 hasSearch() 与 toBuilder()

领星层(lingxing):
- LingxingProductSearchMapper:语义 → 平台枚举值
    沃尔玛/eBay   1 / 3
    AliExpress    1 / 5   (实测;文档写 3 但查不到)
    Temu/SHEIN/TikTok  9 / 8
    Shopify/Target     1 / 本地 SKU 待核对
    亚马逊 SC     "seller_sku" / "sku"(字符串)
- LingxingProductSearchBody:三种请求形态
    camelCase(沃尔玛/eBay/Temu/SHEIN/TikTok/AliExpress)
    snake_case(Shopify/Target)
    amazonSc:search_value 数组 + exact_search 开关
- 八个商品 Source 接入;平台不支持的维度抛 ValidationException,不静默忽略

亚马逊 VC 不支持搜索(接入时会因 Mapper 抛异常而显式失败)。

Co-Authored-By: Claude <noreply@anthropic.com>
feature/supplier-lingxing
chenchuchuan 2 weeks ago
parent
commit
fdc55b3f54
  1. 77
      core/src/main/java/common/ecommerce/model/product/ProductQuery.java
  2. 23
      core/src/main/java/common/ecommerce/model/product/ProductSearchField.java
  3. 42
      lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java
  4. 27
      lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java
  5. 27
      lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java
  6. 80
      lingxing/src/main/java/common/ecommerce/lingxing/platform/multiplatform/product/LingxingProductSearchBody.java
  7. 81
      lingxing/src/main/java/common/ecommerce/lingxing/platform/multiplatform/product/LingxingProductSearchMapper.java
  8. 26
      lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java
  9. 27
      lingxing/src/main/java/common/ecommerce/lingxing/platform/target/product/TargetProductSource.java
  10. 27
      lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java
  11. 26
      lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java
  12. 27
      lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java

77
core/src/main/java/common/ecommerce/model/product/ProductQuery.java

@ -1,10 +1,23 @@
package common.ecommerce.model.product; package common.ecommerce.model.product;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects; import java.util.Objects;
/** /**
* 商品查询条件。 * 商品查询条件。
*
* <p>支持两类过滤:</p>
* <ul>
* <li><b>时间窗</b>:{@link #updatedAfter()} / {@link #updatedBefore()}</li>
* <li><b>按 SKU 搜索</b>:{@link #searchField()} + 单值或多值</li>
* </ul>
*
* <p>搜索有两种形态:{@link #searchValue()} 是<b>单个模糊</b>匹配,
* {@link #searchValues()} 是<b>多个精确</b>匹配。两者互斥,同时设置时以多值为准。
* 平台不支持对应形态时由适配器显式报错,不做静默忽略。</p>
*/ */
public final class ProductQuery { public final class ProductQuery {
@ -12,12 +25,24 @@ public final class ProductQuery {
private final Instant updatedBefore; private final Instant updatedBefore;
private final int pageSize; private final int pageSize;
private final String cursor; private final String cursor;
private final ProductSearchField searchField;
private final String searchValue;
private final List<String> searchValues;
private ProductQuery(Builder b) { private ProductQuery(Builder b) {
this.updatedAfter = b.updatedAfter; this.updatedAfter = b.updatedAfter;
this.updatedBefore = b.updatedBefore; this.updatedBefore = b.updatedBefore;
this.pageSize = b.pageSize; this.pageSize = b.pageSize;
this.cursor = b.cursor; this.cursor = b.cursor;
this.searchField = b.searchField;
this.searchValue = b.searchValue;
this.searchValues = Collections.unmodifiableList(new ArrayList<String>(b.searchValues));
if (searchField == null && (searchValue != null || !searchValues.isEmpty())) {
throw new IllegalArgumentException("searchField is required when searching by SKU");
}
if (searchValue != null && !searchValues.isEmpty()) {
throw new IllegalArgumentException("searchValue (fuzzy) and searchValues (exact) are mutually exclusive");
}
} }
public static Builder builder() { public static Builder builder() {
@ -40,12 +65,46 @@ public final class ProductQuery {
return cursor; return cursor;
} }
/** 搜索维度;为 null 表示不按 SKU 搜索。 */
public ProductSearchField searchField() {
return searchField;
}
/** 单个模糊搜索值;与 {@link #searchValues()} 互斥,可能为 null。 */
public String searchValue() {
return searchValue;
}
/** 多个精确搜索值;未设置时为空列表。 */
public List<String> searchValues() {
return searchValues;
}
/** 是否带了 SKU 搜索条件。 */
public boolean hasSearch() {
return searchField != null && (searchValue != null || !searchValues.isEmpty());
}
public Builder toBuilder() {
return builder()
.updatedAfter(updatedAfter)
.updatedBefore(updatedBefore)
.pageSize(pageSize)
.cursor(cursor)
.searchField(searchField)
.searchValue(searchValue)
.searchValues(searchValues);
}
public static final class Builder { public static final class Builder {
private Instant updatedAfter; private Instant updatedAfter;
private Instant updatedBefore; private Instant updatedBefore;
private int pageSize = 100; private int pageSize = 100;
private String cursor; private String cursor;
private ProductSearchField searchField;
private String searchValue;
private List<String> searchValues = Collections.emptyList();
public Builder updatedAfter(Instant updatedAfter) { public Builder updatedAfter(Instant updatedAfter) {
this.updatedAfter = updatedAfter; this.updatedAfter = updatedAfter;
@ -67,6 +126,24 @@ public final class ProductQuery {
return this; return this;
} }
/** 搜索维度;必须与 {@link #searchValue(String)} 或 {@link #searchValues(List)} 一起用。 */
public Builder searchField(ProductSearchField searchField) {
this.searchField = searchField;
return this;
}
/** 单个模糊搜索。 */
public Builder searchValue(String searchValue) {
this.searchValue = searchValue;
return this;
}
/** 多个精确搜索;与 {@link #searchValue(String)} 互斥。 */
public Builder searchValues(List<String> searchValues) {
this.searchValues = searchValues == null ? Collections.<String>emptyList() : searchValues;
return this;
}
public ProductQuery build() { public ProductQuery build() {
return new ProductQuery(this); return new ProductQuery(this);
} }

23
core/src/main/java/common/ecommerce/model/product/ProductSearchField.java

@ -0,0 +1,23 @@
package common.ecommerce.model.product;
/**
* 商品搜索维度。
*
* <p>只定义<b>跨平台语义一致</b>的维度;各平台自己的数字编码由适配器映射,
* 调用方不感知。见各适配器里的 {@code ProductSearchMapper}。</p>
*
* <ul>
* <li>{@link #PLATFORM_SKU}:平台侧 SKU。领星 {@code msku}、亚马逊 {@code seller_sku}、
* 沃尔玛 {@code sku}。也是 {@link ProductListing#platformSku()} 的来源。</li>
* <li>{@link #LOCAL_SKU}:本地 SKU。领星配对时填的 {@code sku} / {@code local_sku};
* 直连平台没有这个概念。</li>
* </ul>
*/
public enum ProductSearchField {
/** 平台侧 SKU。 */
PLATFORM_SKU,
/** 本地 SKU(领星特有)。 */
LOCAL_SKU
}

42
lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.aliexpress.dto.AliexpressListingDto; import common.ecommerce.lingxing.platform.aliexpress.dto.AliexpressListingDto;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -55,13 +60,12 @@ public final class AliexpressProductSource implements LingxingProductSource {
body.put("isParent", IS_CHILD); body.put("isParent", IS_CHILD);
body.put("offset", offset); body.put("offset", offset);
body.put("length", length); body.put("length", length);
// storeIds 非必填:账户配了才传,由平台侧校验是否必填 // 该接口不需要 storeIds:一次返回当前 app 下全部阿里店铺的商品
String storeId = call.ctx().account().externalStoreId();
if (storeId != null && !storeId.trim().isEmpty()) {
body.put("storeIds", Collections.singletonList(parseStoreId(storeId)));
}
applyTimeWindow(body, query); applyTimeWindow(body, query);
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_ALIEXPRESS, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_ALIEXPRESS, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -78,15 +82,6 @@ public final class AliexpressProductSource implements LingxingProductSource {
return Page.of(out, hasMore ? String.valueOf(nextOffset) : null); return Page.of(out, hasMore ? String.valueOf(nextOffset) : null);
} }
/** storeIds 文档示例是数字数组;能解析成数字就传数字,否则原样传字符串。 */
private static Object parseStoreId(String externalStoreId) {
try {
return Long.valueOf(externalStoreId);
} catch (RuntimeException e) {
return externalStoreId;
}
}
/** 时间窗:start/end 为 yyyy-MM-dd(北京时间的日期)。 */ /** 时间窗:start/end 为 yyyy-MM-dd(北京时间的日期)。 */
private static void applyTimeWindow(Map<String, Object> body, ProductQuery query) { private static void applyTimeWindow(Map<String, Object> body, ProductQuery query) {
Instant from = query.updatedAfter(); Instant from = query.updatedAfter();
@ -269,4 +264,23 @@ public final class AliexpressProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → aliexpress 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.aliexpress(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("aliexpress listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

27
lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.amazon.sc.dto.AmazonScListingDto; import common.ecommerce.lingxing.platform.amazon.sc.dto.AmazonScListingDto;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -66,6 +71,9 @@ public final class AmazonScProductSource implements LingxingProductSource {
LocalDateTime.ofInstant(to, ZoneOffset.UTC))); LocalDateTime.ofInstant(to, ZoneOffset.UTC)));
} }
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_AMAZON_SC, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_AMAZON_SC, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -232,4 +240,23 @@ public final class AmazonScProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → amazon sc 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.amazonSc(query.searchField());
LingxingProductSearchBody.amazonSc(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("amazon sc listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

27
lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.ebay.dto.EbayListingDto; import common.ecommerce.lingxing.platform.ebay.dto.EbayListingDto;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -62,6 +67,9 @@ public final class EbayProductSource implements LingxingProductSource {
} }
applyTimeWindow(body, query); applyTimeWindow(body, query);
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_EBAY, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_EBAY, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -208,4 +216,23 @@ public final class EbayProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → ebay 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.ebay(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("ebay listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

80
lingxing/src/main/java/common/ecommerce/lingxing/platform/multiplatform/product/LingxingProductSearchBody.java

@ -0,0 +1,80 @@
package common.ecommerce.lingxing.platform.multiplatform.product;
import common.ecommerce.model.product.ProductQuery;
import java.util.List;
/**
* 把统一的 SKU 搜索条件拼进领星请求体。
*
* <p>各平台字段名与形态不同:</p>
* <ul>
* <li>沃尔玛 / eBay / Temu / SHEIN / TikTok / AliExpress:{@code searchField}(数字)
* + {@code searchSingleValue}(单值模糊)+ {@code searchValues}(多值精确)</li>
* <li>Shopify / Target:{@code search_field} + {@code search_single_value} + {@code search_values}</li>
* <li>亚马逊 SC:{@code search_field}(字符串)+ {@code search_value}(数组)+ {@code exact_search}</li>
* </ul>
*/
public final class LingxingProductSearchBody {
private LingxingProductSearchBody() {
}
/**
* camelCase 形态:searchField / searchSingleValue / searchValues。
*
* <p>用于 Temu、SHEIN、TikTok、AliExpress、沃尔玛、eBay。</p>
*/
public static void camelCase(java.util.Map<String, Object> body, ProductQuery query, Object fieldValue) {
if (query == null || !query.hasSearch()) {
return;
}
body.put("searchField", fieldValue);
applyValue(body, query, "searchSingleValue", "searchValues");
}
/**
* snake_case 形态:search_field / search_single_value / search_values。
*
* <p>用于 Shopify、Target。</p>
*/
public static void snakeCase(java.util.Map<String, Object> body, ProductQuery query, Object fieldValue) {
if (query == null || !query.hasSearch()) {
return;
}
body.put("search_field", fieldValue);
applyValue(body, query, "search_single_value", "search_values");
}
/**
* 亚马逊 SC 形态:search_field(字符串)+ search_value(数组)+ exact_search。
*
* <p>单值模糊时转成单元素数组并设 {@code exact_search=0};
* 多值时设 {@code exact_search=1}。</p>
*/
public static void amazonSc(java.util.Map<String, Object> body, ProductQuery query, Object fieldValue) {
if (query == null || !query.hasSearch()) {
return;
}
body.put("search_field", fieldValue);
List<String> values = query.searchValues();
if (values.isEmpty()) {
body.put("search_value", java.util.Collections.singletonList(query.searchValue()));
body.put("exact_search", 0);
} else {
body.put("search_value", values);
body.put("exact_search", 1);
}
}
/** 单值模糊与多值精确二选一,已在 ProductQuery 构造时校验。 */
private static void applyValue(java.util.Map<String, Object> body, ProductQuery query,
String singleKey, String multiKey) {
List<String> values = query.searchValues();
if (values.isEmpty()) {
body.put(singleKey, query.searchValue());
} else {
body.put(multiKey, values);
}
}
}

81
lingxing/src/main/java/common/ecommerce/lingxing/platform/multiplatform/product/LingxingProductSearchMapper.java

@ -0,0 +1,81 @@
package common.ecommerce.lingxing.platform.multiplatform.product;
import common.ecommerce.model.product.ProductSearchField;
/**
* 领星侧各平台的「搜索维度 → 平台枚举值」映射。
*
* <p>同一个语义在不同平台下的取值完全不同:</p>
* <pre>
* 平台 SKU 本地 SKU
* 沃尔玛 1 3
* eBay 1 3
* AliExpress 1 5 ← 实测:文档写 3,但 3 查不到
* Temu 9 8
* SHEIN 9 8
* TikTok 9 8
* Shopify/Target 1 待核对(样本 local_sku 为空)
* 亚马逊 SC "seller_sku" "sku" ← 字符串,不是数字
* 亚马逊 VC 不支持搜索
* </pre>
*
* <p>取值来源:领星文档(2026-10 摘录)+ AliExpress 实测(2026-11)。
* 未实测的平台按文档写,联调时用 {@code SearchFieldProbeTest} 逐个核对。</p>
*
* <p>用「按平台命名的方法」而不是「按 platform_code 查表」:每个 Source 只服务一个平台,
* 直接调自己那一个方法即可;AliExpress 的 platform_code 尚未确认,也不影响调用。
* 返回值类型不统一(数字 / 字符串),由各 Source 直接塞进请求体。</p>
*/
public final class LingxingProductSearchMapper {
private LingxingProductSearchMapper() {
}
/** 沃尔玛:1 = MSKU,3 = SKU。 */
public static Object walmart(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 1 : 3;
}
/** eBay:1 = msku,3 = sku。 */
public static Object ebay(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 1 : 3;
}
/** AliExpress:1 = msku,5 = 本地 SKU(实测;文档写 3 但查不到)。 */
public static Object aliexpress(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 1 : 5;
}
/** Temu:9 = MSKU,8 = SKU。 */
public static Object temu(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 9 : 8;
}
/** SHEIN:9 = MSKU,8 = SKU。 */
public static Object shein(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 9 : 8;
}
/** TikTok:9 = MSKU,8 = SKU。 */
public static Object tiktok(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? 9 : 8;
}
/**
* Shopify / Target:1 = msku。
*
* <p>本地 SKU 的编码文档未给出,实测样本 {@code local_sku} 也为空,
* 暂时返回 null 表示不支持;联调时用探针确认后再补。</p>
*/
public static Object shopify(ProductSearchField field) {
if (field == ProductSearchField.PLATFORM_SKU) {
return 1;
}
throw new UnsupportedOperationException("shopify/target listing does not support local sku search yet");
}
/** 亚马逊 SC:字符串 "seller_sku" / "sku"。 */
public static Object amazonSc(ProductSearchField field) {
return field == ProductSearchField.PLATFORM_SKU ? "seller_sku" : "sku";
}
}

26
lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.lingxing.platform.shein.dto.SheinListingDto; import common.ecommerce.lingxing.platform.shein.dto.SheinListingDto;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -45,6 +50,8 @@ public final class SheinProductSource implements LingxingProductSource {
if (storeId != null && !storeId.trim().isEmpty()) { if (storeId != null && !storeId.trim().isEmpty()) {
body.put("storeIds", Collections.singletonList(storeId)); body.put("storeIds", Collections.singletonList(storeId));
} }
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_SHEIN, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_SHEIN, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -232,4 +239,23 @@ public final class SheinProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → shein 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.shein(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("shein listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

27
lingxing/src/main/java/common/ecommerce/lingxing/platform/target/product/TargetProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.lingxing.platform.target.dto.TargetListingDto; import common.ecommerce.lingxing.platform.target.dto.TargetListingDto;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -56,6 +61,9 @@ public final class TargetProductSource implements LingxingProductSource {
// } // }
applyTimeWindow(body, query); applyTimeWindow(body, query);
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_SHOPIFY, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_SHOPIFY, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -276,4 +284,23 @@ public final class TargetProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → shopify/target 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.shopify(query.searchField());
LingxingProductSearchBody.snakeCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("shopify/target listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

27
lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.lingxing.platform.temu.dto.TemuListingDto; import common.ecommerce.lingxing.platform.temu.dto.TemuListingDto;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -52,6 +57,9 @@ public final class TemuProductSource implements LingxingProductSource {
} }
applyTimeWindow(body, query); applyTimeWindow(body, query);
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_TEMU, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_TEMU, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -201,4 +209,23 @@ public final class TemuProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → temu 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.temu(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("temu listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

26
lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java

@ -5,6 +5,11 @@ import common.ecommerce.http.HttpResponse;
import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.lingxing.platform.tiktok.dto.TiktokListingDto; import common.ecommerce.lingxing.platform.tiktok.dto.TiktokListingDto;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -44,6 +49,8 @@ public final class TiktokProductSource implements LingxingProductSource {
if (storeId != null && !storeId.trim().isEmpty()) { if (storeId != null && !storeId.trim().isEmpty()) {
body.put("storeIds", Collections.singletonList(storeId)); body.put("storeIds", Collections.singletonList(storeId));
} }
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_TIKTOK, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_TIKTOK, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -231,4 +238,23 @@ public final class TiktokProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → tiktok 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.tiktok(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("tiktok listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

27
lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java

@ -6,6 +6,11 @@ import common.ecommerce.lingxing.LingxingApi;
import common.ecommerce.lingxing.LingxingConstants; import common.ecommerce.lingxing.LingxingConstants;
import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.http.LingxingEnvelope;
import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.LingxingCall;
import common.ecommerce.error.ChannelException;
import common.ecommerce.error.ValidationException;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchBody;
import common.ecommerce.lingxing.platform.multiplatform.product.LingxingProductSearchMapper;
import common.ecommerce.model.product.ProductQuery;
import common.ecommerce.lingxing.platform.LingxingProductSource; import common.ecommerce.lingxing.platform.LingxingProductSource;
import common.ecommerce.lingxing.platform.walmart.dto.WalmartListingDto; import common.ecommerce.lingxing.platform.walmart.dto.WalmartListingDto;
import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.ChannelProvider;
@ -71,6 +76,9 @@ public final class WalmartProductSource implements LingxingProductSource {
} }
applyTimeWindow(body, query); applyTimeWindow(body, query);
// 按 SKU 搜索:平台不支持的维度直接报错,不静默忽略
applySearch(body, query);
HttpRequest req = call.signed(LingxingApi.LISTING_WALMART, body, "products.pull"); HttpRequest req = call.signed(LingxingApi.LISTING_WALMART, body, "products.pull");
HttpResponse resp = call.execute(req); HttpResponse resp = call.execute(req);
LingxingEnvelope envelope = call.envelope(resp, "products.pull"); LingxingEnvelope envelope = call.envelope(resp, "products.pull");
@ -283,4 +291,23 @@ public final class WalmartProductSource implements LingxingProductSource {
String trimmed = v.trim(); String trimmed = v.trim();
return trimmed.isEmpty() ? null : trimmed; return trimmed.isEmpty() ? null : trimmed;
} }
/** 统一 SKU 搜索 → walmart 的字段形态;未带搜索条件时什么也不做。 */
private static void applySearch(java.util.Map<String, Object> body,
ProductQuery query) {
if (query == null || !query.hasSearch()) {
return;
}
try {
Object fieldValue = LingxingProductSearchMapper.walmart(query.searchField());
LingxingProductSearchBody.camelCase(body, query, fieldValue);
} catch (UnsupportedOperationException e) {
ChannelException.Builder b = ChannelException.builder()
.message("walmart listing does not support search field "
+ query.searchField())
.operation("products.pull")
.retryable(false);
throw new ValidationException(b);
}
}
} }

Loading…
Cancel
Save