diff --git a/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java new file mode 100644 index 0000000..1b2ec66 --- /dev/null +++ b/lingxing/src/test/java/common/ecommerce/lingxing/probe/ListingParamProbeTest.java @@ -0,0 +1,165 @@ +package common.ecommerce.lingxing.probe; + +import common.ecommerce.http.HttpRequest; +import common.ecommerce.http.HttpResponse; +import common.ecommerce.http.HttpTransport; +import common.ecommerce.http.JacksonJsonCodec; +import common.ecommerce.http.OkHttpTransport; +import common.ecommerce.lingxing.LingxingApi; +import common.ecommerce.lingxing.LingxingConstants; +import common.ecommerce.lingxing.auth.LingxingTokenClient; +import common.ecommerce.lingxing.http.LingxingEnvelope; +import common.ecommerce.lingxing.http.LingxingRateLimiter; +import common.ecommerce.lingxing.http.LingxingRequestFactory; +import common.ecommerce.lingxing.platform.LingxingCall; +import common.ecommerce.model.ChannelProvider; +import common.ecommerce.model.Platform; +import common.ecommerce.model.account.AccountKey; +import common.ecommerce.model.account.ChannelAccount; +import common.ecommerce.sdk.ChannelConnection; +import common.ecommerce.sdk.ChannelContext; +import common.ecommerce.spi.AccessToken; +import common.ecommerce.spi.ChannelSecret; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.EnabledIfSystemProperty; + +import java.time.Clock; +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.Map; + +/** + * 只读探针(收尾第三轮):Target 时间窗上限与单边窗口。 + * + *
默认跳过;用 {@code -Dlingxing.probe=true} 显式开启。只做查询。
+ */ +@EnabledIfSystemProperty(named = "lingxing.probe", matches = "true") +class ListingParamProbeTest { + + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); + private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; + + private static final JacksonJsonCodec JSON = new JacksonJsonCodec(); + private final HttpTransport transport = new OkHttpTransport("common-ecommerce-param-probe"); + + private static final String TARGET_STORE = "110593321260223488"; + private static final String TEMU_STORE = "110544498784182784"; + + @Test + void targetWindowLimits() { + requireCredentials(); + LingxingCall call = call(Platform.TARGET, 0, TARGET_STORE); + System.out.println("\n===== TARGET 时间窗上限 ====="); + for (int days : new int[]{30, 31, 60, 90, 180, 365}) { + Map默认跳过;用 {@code -Dlingxing.probe=true} 显式开启。
+ * + *只做查询。会打印请求体(截断)与统一模型的关键字段, + * 便于对照接口文档核对分页、日期、SKU 搜索三项参数。
+ */ +@EnabledIfSystemProperty(named = "lingxing.probe", matches = "true") +class ListingSmokeProbeTest { + + // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=... + private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", ""); + private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", ""); + private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; + + private static final JacksonJsonCodec JSON = new JacksonJsonCodec(); + private final LoggingTransport transport = new LoggingTransport(new OkHttpTransport("common-ecommerce-listing-probe")); + private final InMemoryTokenStore tokens = new InMemoryTokenStore(); + + /** 平台 → 实测店铺 id,取自 ShopListProbeTest 的输出。 */ + private static final Object[][] TARGETS = { + {Platform.AMAZON_SC, 10001, "127524991355697152", "AMZ-TOY-US"}, + {Platform.AMAZON_VC, 10035, "134543850419473408", "AMZ-CL-US"}, + {Platform.WALMART_SC, 10008, "110528861382225920", "WMT-CYB-US"}, + {Platform.EBAY, 10003, "110627593325390848", "EBA-STE-US"}, + {Platform.TIKTOK, 10011, "110541661459314688", "TTK-STE"}, + {Platform.TEMU, 10024, "110544498784182784", "TEMU OFFICE DIRECT"}, + {Platform.SHEIN, 10028, "110541676737748480", "SHE-JCK-US"}, + {Platform.ALIEXPRESS, 0, "", "全部阿里店铺(接口不需要 store)"}, + // shopify/variantList 下真正有商品的是 SPF-BM(10002),Target DVS 是空店 + {Platform.TARGET, 0, "110593321260223488", "SPF-BM"}, + }; + + /** + * 列表页不传时间窗:部分平台的数据很久没更新(Temu 最近更新时间早于窗口), + * 传窄窗口会得到 0 条,看不出字段映射。时间窗参数另行核对,见 {@link ListingParamProbeTest}。 + */ + @Test + void pullOnePagePerPlatform() { + Assumptions.assumeTrue(!APP_KEY.trim().isEmpty() && !APP_SECRET.trim().isEmpty(), + "未提供 -Dlingxing.probe.appKey / -Dlingxing.probe.appSecret,跳过探针"); + ChannelSdk sdk = sdk(); + + for (Object[] row : TARGETS) { + Platform platform = (Platform) row[0]; + int code = (Integer) row[1]; + String storeId = (String) row[2]; + String label = (String) row[3]; + System.out.println("\n================ " + platform + " / " + label + " ================"); + + ChannelAccount account = account(platform, code, storeId); + AccountKey key = account.key(); + ChannelConnection conn = connection(); + + try { + sdk.capabilities(key); + Page只做查询,不创建、不修改任何数据。
* - *用法:填好下面四个常量后运行
+ *用法:通过系统属性提供凭据后运行(凭据不入库)
*- * mvn -pl lingxing test -Dtest=SearchFieldProbeTest -DfailIfNoTests=false + * mvn -pl lingxing test -Dtest=SearchFieldProbeTest -DfailIfNoTests=false \ + * -Dlingxing.probe=true \ + * -Dlingxing.probe.appKey=你的appId -Dlingxing.probe.appSecret=你的appSecret ** *
输出会告诉你:对同一个 SKU 值,哪个 searchField 编码能命中;
@@ -48,8 +50,9 @@ import java.util.Map;
class SearchFieldProbeTest {
// ==================== 填写这里 ====================
- private static final String APP_KEY = "ak_MWoHJz2tcIwKF";
- private static final String APP_SECRET = "YOUkd5efWJSK71jLvDyz+g==";
+ // 真实凭据不入库:本地跑探针时用 -Dlingxing.probe.appKey=... -Dlingxing.probe.appSecret=...
+ private static final String APP_KEY = System.getProperty("lingxing.probe.appKey", "");
+ private static final String APP_SECRET = System.getProperty("lingxing.probe.appSecret", "");
/** AliExpress 探针开关:该接口不需要店铺 id,只要 app 下有阿里商品就能查。 */
private static final boolean PROBE_ALIEXPRESS = true;
@@ -58,7 +61,7 @@ class SearchFieldProbeTest {
* Target 店铺的 storeId。可选——文档里 store_ids 不是必填项,
* 不填就查该 app 下全部店铺的商品。
*/
- private static final String TARGET_STORE_ID = "110593321260223488";
+ private static final String TARGET_STORE_ID = "";
/** AliExpress 的领星 platform_code(待实测确认;该码不影响商品接口调用)。 */
private static final int ALIEXPRESS_PLATFORM_CODE = 0;
@@ -117,15 +120,18 @@ class SearchFieldProbeTest {
Map