diff --git a/core/src/main/java/common/ecommerce/capability/AggregatorCapable.java b/core/src/main/java/common/ecommerce/capability/AggregatorCapable.java index 51aa9dc..ae7d5af 100644 --- a/core/src/main/java/common/ecommerce/capability/AggregatorCapable.java +++ b/core/src/main/java/common/ecommerce/capability/AggregatorCapable.java @@ -28,7 +28,14 @@ public interface AggregatorCapable extends PlatformAdapter { @Override boolean supports(ChannelAccount account, Capability capability); - /** 子渠道。 */ + /** + * 子店铺信息。 + * + *

前四个字段用于构造 {@code ChannelAccount}({@code platformCode + externalStoreId}) + * 与路由;其余字段是各平台店铺列表接口的原始信息,按需取用。

+ * + *

不支持的字段为 null;平台特有的其余字段放 {@link #attributes()},键名与平台一致。

+ */ final class SubChannel { private final int platformCode; @@ -36,11 +43,54 @@ public interface AggregatorCapable extends PlatformAdapter { private final Platform platform; private final String name; + /** 平台卖家 ID:领星 SC 的 {@code seller_id}、VC 的 {@code seller_id}。 */ + private final String sellerId; + /** 账号名:领星 {@code account_name}。 */ + private final String accountName; + /** 店铺授权状态原值:领星 0 暂停 / 1 正常 / 2 授权异常 / -1 删除。 */ + private final Integer status; + /** 站点简称:领星 {@code region},如 na / eu。 */ + private final String region; + /** 站点名称:领星 {@code region_name},如 北美洲。 */ + private final String regionName; + /** 商城所在国家名称:领星 SC 的 {@code country}。 */ + private final String country; + /** 市场 ID:领星 SC 的 {@code marketplace_id}。 */ + private final String marketplaceId; + /** 站点 ID:领星 {@code mid}。 */ + private final Integer marketplaceNum; + /** 平台特有字段。 */ + private final java.util.Map attributes; + public SubChannel(int platformCode, String externalStoreId, Platform platform, String name) { + this(platformCode, externalStoreId, platform, name, + null, null, null, null, null, null, null, null, + java.util.Collections.emptyMap()); + } + + private SubChannel(int platformCode, String externalStoreId, Platform platform, String name, + String sellerId, String accountName, Integer status, + String region, String regionName, String country, + String marketplaceId, Integer marketplaceNum, + java.util.Map attributes) { this.platformCode = platformCode; this.externalStoreId = externalStoreId; this.platform = platform; this.name = name; + this.sellerId = sellerId; + this.accountName = accountName; + this.status = status; + this.region = region; + this.regionName = regionName; + this.country = country; + this.marketplaceId = marketplaceId; + this.marketplaceNum = marketplaceNum; + this.attributes = java.util.Collections.unmodifiableMap( + new java.util.LinkedHashMap(attributes)); + } + + public static Builder builder() { + return new Builder(); } public int platformCode() { @@ -58,5 +108,131 @@ public interface AggregatorCapable extends PlatformAdapter { public String name() { return name; } + + public String sellerId() { + return sellerId; + } + + public String accountName() { + return accountName; + } + + public Integer status() { + return status; + } + + public String region() { + return region; + } + + public String regionName() { + return regionName; + } + + public String country() { + return country; + } + + public String marketplaceId() { + return marketplaceId; + } + + public Integer marketplaceNum() { + return marketplaceNum; + } + + public java.util.Map attributes() { + return attributes; + } + + public static final class Builder { + + private int platformCode; + private String externalStoreId; + private Platform platform; + private String name; + private String sellerId; + private String accountName; + private Integer status; + private String region; + private String regionName; + private String country; + private String marketplaceId; + private Integer marketplaceNum; + private java.util.Map attributes = + java.util.Collections.emptyMap(); + + public Builder platformCode(int platformCode) { + this.platformCode = platformCode; + return this; + } + + public Builder externalStoreId(String externalStoreId) { + this.externalStoreId = externalStoreId; + return this; + } + + public Builder platform(Platform platform) { + this.platform = platform; + return this; + } + + public Builder name(String name) { + this.name = name; + return this; + } + + public Builder sellerId(String sellerId) { + this.sellerId = sellerId; + return this; + } + + public Builder accountName(String accountName) { + this.accountName = accountName; + return this; + } + + public Builder status(Integer status) { + this.status = status; + return this; + } + + public Builder region(String region) { + this.region = region; + return this; + } + + public Builder regionName(String regionName) { + this.regionName = regionName; + return this; + } + + public Builder country(String country) { + this.country = country; + return this; + } + + public Builder marketplaceId(String marketplaceId) { + this.marketplaceId = marketplaceId; + return this; + } + + public Builder marketplaceNum(Integer marketplaceNum) { + this.marketplaceNum = marketplaceNum; + return this; + } + + public Builder attributes(java.util.Map attributes) { + this.attributes = attributes == null + ? java.util.Collections.emptyMap() : attributes; + return this; + } + + public SubChannel build() { + return new SubChannel(platformCode, externalStoreId, platform, name, + sellerId, accountName, status, region, regionName, country, + marketplaceId, marketplaceNum, attributes); + } + } } } diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/shop/AmazonScShopSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/shop/AmazonScShopSource.java index 2b30459..a1368f6 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/shop/AmazonScShopSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/shop/AmazonScShopSource.java @@ -12,7 +12,9 @@ import common.ecommerce.model.Platform; import java.util.ArrayList; import java.util.Collections; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; /** * 领星 · 亚马逊 SC 店铺列表。 @@ -41,12 +43,30 @@ public final class AmazonScShopSource implements LingxingShopSource { continue; } // platformCode 取领星侧 Amazon SC 的平台码 10001;externalStoreId 用领星店铺 id(sid) - out.add(new SubChannel( - AMAZON_SC_PLATFORM_CODE, - String.valueOf(shop.getSid()), - Platform.AMAZON_SC, - shop.getName() == null ? shop.getSellerId() : shop.getName())); + out.add(SubChannel.builder() + .platformCode(AMAZON_SC_PLATFORM_CODE) + .externalStoreId(String.valueOf(shop.getSid())) + .platform(Platform.AMAZON_SC) + .name(shop.getName() == null ? shop.getSellerId() : shop.getName()) + .sellerId(shop.getSellerId()) + .accountName(shop.getAccountName()) + .status(shop.getStatus()) + .region(shop.getRegion()) + .country(shop.getCountry()) + .marketplaceId(shop.getMarketplaceId()) + .marketplaceNum(shop.getMid()) + .attributes(attributesOf(shop)) + .build()); } return Collections.unmodifiableList(out); } + + /** 未标准化的原始字段:只保留有值的。 */ + private static Map attributesOf(AmazonScShopDto shop) { + Map attrs = new LinkedHashMap(); + attrs.put("seller_account_id", shop.getSellerAccountId()); + attrs.put("has_ads_setting", shop.getHasAdsSetting()); + attrs.values().removeAll(Collections.singleton(null)); + return attrs; + } } diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/shop/AmazonVcShopSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/shop/AmazonVcShopSource.java index 771dcfd..2272da1 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/shop/AmazonVcShopSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/shop/AmazonVcShopSource.java @@ -51,11 +51,19 @@ public final class AmazonVcShopSource implements LingxingShopSource { || shop.getStatus() != STATUS_ACTIVE) { continue; } - out.add(new SubChannel( - AMAZON_VC_PLATFORM_CODE, - shop.getVcStoreId(), - Platform.AMAZON_VC, - shop.getName() == null ? shop.getSellerId() : shop.getName())); + out.add(SubChannel.builder() + .platformCode(AMAZON_VC_PLATFORM_CODE) + .externalStoreId(shop.getVcStoreId()) + .platform(Platform.AMAZON_VC) + .name(shop.getName() == null ? shop.getSellerId() : shop.getName()) + .sellerId(shop.getSellerId()) + .accountName(shop.getAccountName()) + .status(shop.getStatus()) + .region(shop.getRegion()) + .regionName(shop.getRegionName()) + .marketplaceNum(shop.getMid()) + .attributes(attributesOf(shop)) + .build()); } offset += page.size(); @@ -67,4 +75,12 @@ public final class AmazonVcShopSource implements LingxingShopSource { } return Collections.unmodifiableList(out); } + + /** 未标准化的原始字段:只保留有值的。 */ + private static Map attributesOf(AmazonVcShopDto shop) { + Map attrs = new LinkedHashMap(); + attrs.put("account_id", shop.getAccountId()); + attrs.values().removeAll(Collections.singleton(null)); + return attrs; + } }