|
|
|
@ -68,9 +68,14 @@ class LingxingLiveSmokeTest { |
|
|
|
// ================================================
|
|
|
|
// ================================================
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 10008 = Walmart;TikTok 10011、eBay 10003、Amazon SC 10001,按需改。 |
|
|
|
* 领星平台码:10008 = Walmart;TikTok 10011、eBay 10003、Amazon SC 10001,按需改。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>Target / BestBuy / AEPH / Michaels / ECHO / LOS-DLI-US 等平台在领星侧 |
|
|
|
|
|
|
|
* <b>没有独立平台码</b>。这类平台把本常量置为 {@code null} 或 {@code 0} 即可: |
|
|
|
|
|
|
|
* 请求体不带 {@code platform_code},店铺与订单都只按 {@code store_id} 过滤, |
|
|
|
|
|
|
|
* 业务平台由 {@link #smokePlatform()} 兜底成 {@link Platform#CUSTOM}。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private static final int PLATFORM_CODE = 10034; |
|
|
|
private static final Integer PLATFORM_CODE = 0; |
|
|
|
private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; |
|
|
|
private static final String BASE_URL = LingxingConstants.PRODUCTION_BASE_URL; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -102,12 +107,18 @@ class LingxingLiveSmokeTest { |
|
|
|
* <p>订单接口按店铺 id 过滤,而各子平台的 id 口径不同(亚马逊 SC 是数字 {@code sid}, |
|
|
|
* <p>订单接口按店铺 id 过滤,而各子平台的 id 口径不同(亚马逊 SC 是数字 {@code sid}, |
|
|
|
* 多平台是 {@code store_id})。所以这里直接从店铺列表取,和亚马逊 SC/VC 的做法一致; |
|
|
|
* 多平台是 {@code store_id})。所以这里直接从店铺列表取,和亚马逊 SC/VC 的做法一致; |
|
|
|
* {@code STORE_ID} 填了则优先用它,仅作为「指定某一家店」的覆盖手段。</p> |
|
|
|
* {@code STORE_ID} 填了则优先用它,仅作为「指定某一家店」的覆盖手段。</p> |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p><b>没有平台码的平台</b>(Target / BestBuy / AEPH / Michaels / ECHO / |
|
|
|
|
|
|
|
* LOS-DLI-US 等):把 {@link #PLATFORM_CODE} 置为 {@code null} 或 {@code 0}。 |
|
|
|
|
|
|
|
* 此时店铺列表不带 {@code platform_code} 过滤,会返回该领星账号下所有平台的店铺, |
|
|
|
|
|
|
|
* 每行都打印了真实的 {@code platform_code};订单查询只发 {@code store_id}, |
|
|
|
|
|
|
|
* 照样能拉到数据。想固定到某一家店时,从打印结果里挑一个 {@code store_id} |
|
|
|
|
|
|
|
* 填到 {@link #STORE_ID} 即可。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Test |
|
|
|
@Test |
|
|
|
void pullsOnePageOfOrders() { |
|
|
|
void pullsOnePageOfOrders() { |
|
|
|
requireCredentials(); |
|
|
|
requireCredentials(); |
|
|
|
LingxingAdapter adapter = adapter(); |
|
|
|
LingxingAdapter adapter = adapter(); |
|
|
|
|
|
|
|
|
|
|
|
List<SubChannel> shops = listShops(adapter); |
|
|
|
List<SubChannel> shops = listShops(adapter); |
|
|
|
String storeId = resolveStoreId(shops); |
|
|
|
String storeId = resolveStoreId(shops); |
|
|
|
if (storeId == null) { |
|
|
|
if (storeId == null) { |
|
|
|
@ -124,7 +135,7 @@ class LingxingLiveSmokeTest { |
|
|
|
.pageSize(20) |
|
|
|
.pageSize(20) |
|
|
|
.build()); |
|
|
|
.build()); |
|
|
|
|
|
|
|
|
|
|
|
System.out.println("[orders] platform_code=" + PLATFORM_CODE |
|
|
|
System.out.println("[orders] platform_code=" + platformCodeLabel() |
|
|
|
+ " store_id=" + storeId |
|
|
|
+ " store_id=" + storeId |
|
|
|
+ " window=" + from + " .. " + to |
|
|
|
+ " window=" + from + " .. " + to |
|
|
|
+ " items=" + page.size() + " nextCursor=" + page.nextCursor()); |
|
|
|
+ " items=" + page.size() + " nextCursor=" + page.nextCursor()); |
|
|
|
@ -517,16 +528,24 @@ class LingxingLiveSmokeTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 按 platform_code 列店铺,并打印该子平台下已授权的店铺。 |
|
|
|
* 按 {@code PLATFORM_CODE} 列店铺,并打印该子平台下已授权的店铺。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>没有平台码时不带 {@code platform_code} 过滤,会返回该领星账号下所有平台的店铺; |
|
|
|
|
|
|
|
* 每行打印响应里的真实 {@code platform_code},方便挑出目标店铺并回填。</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<SubChannel> listShops(LingxingAdapter adapter) { |
|
|
|
private List<SubChannel> listShops(LingxingAdapter adapter) { |
|
|
|
ChannelAccount discovery = account(LingxingConstants.toPlatform(LingxingLiveSmokeTest.PLATFORM_CODE), LingxingLiveSmokeTest.PLATFORM_CODE, "0"); |
|
|
|
ChannelAccount discovery = account("0"); |
|
|
|
List<SubChannel> shops = adapter.listSubChannels(context(discovery, "smoke-shops-")); |
|
|
|
List<SubChannel> shops = adapter.listSubChannels(context(discovery, "smoke-shops-")); |
|
|
|
System.out.println("[shops] platform_code=" + LingxingLiveSmokeTest.PLATFORM_CODE + " count=" + shops.size()); |
|
|
|
System.out.println("[shops] platform_code=" + platformCodeLabel() |
|
|
|
|
|
|
|
+ " count=" + shops.size() |
|
|
|
|
|
|
|
+ (hasPlatformCode() ? "" : "(未按平台过滤,返回账号下全部店铺)")); |
|
|
|
for (SubChannel shop : shops) { |
|
|
|
for (SubChannel shop : shops) { |
|
|
|
|
|
|
|
Object platformName = shop.attributes().get("platform_name"); |
|
|
|
System.out.println(" store_id=" + shop.externalStoreId() |
|
|
|
System.out.println(" store_id=" + shop.externalStoreId() |
|
|
|
+ " name=" + shop.name() |
|
|
|
+ " platform_code=" + shop.platformCode() |
|
|
|
+ " platform=" + shop.platform()); |
|
|
|
+ " platform=" + shop.platform() |
|
|
|
|
|
|
|
+ " platform_name=" + (platformName == null ? "-" : platformName) |
|
|
|
|
|
|
|
+ " name=" + shop.name()); |
|
|
|
} |
|
|
|
} |
|
|
|
return shops; |
|
|
|
return shops; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -551,7 +570,12 @@ class LingxingLiveSmokeTest { |
|
|
|
System.out.println("[orders] 没有已授权店铺,跳过(也可在 STORE_ID 里直接填 store_id)"); |
|
|
|
System.out.println("[orders] 没有已授权店铺,跳过(也可在 STORE_ID 里直接填 store_id)"); |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
return shops.get(0).externalStoreId(); |
|
|
|
String storeId = shops.get(0).externalStoreId(); |
|
|
|
|
|
|
|
if (!hasPlatformCode()) { |
|
|
|
|
|
|
|
System.out.println("[orders] 未指定 platform_code,取店铺列表第一条 store_id=" |
|
|
|
|
|
|
|
+ storeId + "(真实 platform_code=" + shops.get(0).platformCode() + ")"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return storeId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static boolean containsStore(List<SubChannel> shops, String storeId) { |
|
|
|
private static boolean containsStore(List<SubChannel> shops, String storeId) { |
|
|
|
@ -607,10 +631,41 @@ class LingxingLiveSmokeTest { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 是否配置了平台码。{@code null} 与 {@code 0} 都表示领星侧没有独立平台码。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static boolean hasPlatformCode() { |
|
|
|
|
|
|
|
return PLATFORM_CODE != null && PLATFORM_CODE != 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 没有平台码时 {@code ChannelAccount.platformCode} 显式传 null, |
|
|
|
|
|
|
|
* 让订单 / 店铺请求体省略 {@code platform_code},只按 {@code store_id} 过滤。 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static Integer platformCodeOrNull() { |
|
|
|
|
|
|
|
return hasPlatformCode() ? PLATFORM_CODE : null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 业务平台:有平台码时按码映射;没有码时兜底 {@link Platform#CUSTOM}。 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* <p>{@code AccountKey} 不接受 null 平台,而且能力路由正是按业务平台选子平台, |
|
|
|
|
|
|
|
* 所以必须有个具体值;{@code CUSTOM} 对应领星自定义平台(10009)的实现, |
|
|
|
|
|
|
|
* 订单与店铺走同一套多平台接口,不影响查询。</p> |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private static Platform smokePlatform() { |
|
|
|
|
|
|
|
return hasPlatformCode() ? LingxingConstants.toPlatform(PLATFORM_CODE) : Platform.CUSTOM; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 日志展示用:无平台码时说明这次只按 store_id 过滤。 */ |
|
|
|
|
|
|
|
private static String platformCodeLabel() { |
|
|
|
|
|
|
|
return hasPlatformCode() ? String.valueOf(PLATFORM_CODE) : "未指定(仅按 store_id 过滤)"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 按 {@code PLATFORM_CODE} 构造账户,店铺 id 由调用方决定。 |
|
|
|
* 按 {@code PLATFORM_CODE} 构造账户,店铺 id 由调用方决定。 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private ChannelAccount account(String storeId) { |
|
|
|
private ChannelAccount account(String storeId) { |
|
|
|
return account(LingxingConstants.toPlatform(PLATFORM_CODE), PLATFORM_CODE, storeId); |
|
|
|
return account(smokePlatform(), platformCodeOrNull(), storeId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ChannelAccount amazonAccount(String sid) { |
|
|
|
private ChannelAccount amazonAccount(String sid) { |
|
|
|
@ -625,7 +680,10 @@ class LingxingLiveSmokeTest { |
|
|
|
return account(Platform.WALMART_SC, 10008, storeId); |
|
|
|
return account(Platform.WALMART_SC, 10008, storeId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ChannelAccount account(Platform platform, int platformCode, String storeId) { |
|
|
|
/** |
|
|
|
|
|
|
|
* @param platformCode 领星 platform_code;null 表示不带该过滤条件 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private ChannelAccount account(Platform platform, Integer platformCode, String storeId) { |
|
|
|
return ChannelAccount.builder() |
|
|
|
return ChannelAccount.builder() |
|
|
|
.key(AccountKey.of(ChannelProvider.LINGXING, platform, "oms-smoke-001")) |
|
|
|
.key(AccountKey.of(ChannelProvider.LINGXING, platform, "oms-smoke-001")) |
|
|
|
.externalStoreId(storeId) |
|
|
|
.externalStoreId(storeId) |
|
|
|
|