Browse Source

feat(shop): SubChannel 补齐店铺标准字段,SC/VC 全字段映射

SubChannel 新增(均有注释说明对应领星字段):
- sellerId      SC/VC 的 seller_id
- accountName   account_name
- status        原始授权状态(不再只保留正常店铺后在结果里丢失状态)
- region        SC/VC 的 region,如 na / eu
- regionName    VC 的 region_name,如 北美洲
- country       SC 的 country
- marketplaceId SC 的 marketplace_id
- marketplaceNum mid
- attributes    其余平台特有字段(seller_account_id / has_ads_setting / account_id)

保留旧的四参构造器,已有调用方无需改动;新增 Builder 便于扩展。

用途:调用方构造 ChannelAccount 时可直接从 SubChannel 取 region/country,
不必再硬编码 marketplaceZone。

Co-Authored-By: Claude <noreply@anthropic.com>
feature/supplier-lingxing
chenchuchuan 3 weeks ago
parent
commit
a4135f5862
  1. 178
      core/src/main/java/common/ecommerce/capability/AggregatorCapable.java
  2. 30
      lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/shop/AmazonScShopSource.java
  3. 26
      lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/shop/AmazonVcShopSource.java

178
core/src/main/java/common/ecommerce/capability/AggregatorCapable.java

@ -28,7 +28,14 @@ public interface AggregatorCapable extends PlatformAdapter {
@Override @Override
boolean supports(ChannelAccount account, Capability capability); boolean supports(ChannelAccount account, Capability capability);
/** 子渠道。 */ /**
* 子店铺信息。
*
* <p>前四个字段用于构造 {@code ChannelAccount}({@code platformCode + externalStoreId})
* 与路由;其余字段是各平台店铺列表接口的原始信息,按需取用。</p>
*
* <p>不支持的字段为 null;平台特有的其余字段放 {@link #attributes()},键名与平台一致。</p>
*/
final class SubChannel { final class SubChannel {
private final int platformCode; private final int platformCode;
@ -36,11 +43,54 @@ public interface AggregatorCapable extends PlatformAdapter {
private final Platform platform; private final Platform platform;
private final String name; 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<String, Object> attributes;
public SubChannel(int platformCode, String externalStoreId, Platform platform, String name) { 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.<String, Object>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<String, Object> attributes) {
this.platformCode = platformCode; this.platformCode = platformCode;
this.externalStoreId = externalStoreId; this.externalStoreId = externalStoreId;
this.platform = platform; this.platform = platform;
this.name = name; 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<String, Object>(attributes));
}
public static Builder builder() {
return new Builder();
} }
public int platformCode() { public int platformCode() {
@ -58,5 +108,131 @@ public interface AggregatorCapable extends PlatformAdapter {
public String name() { public String name() {
return 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<String, Object> 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<String, Object> 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<String, Object> attributes) {
this.attributes = attributes == null
? java.util.Collections.<String, Object>emptyMap() : attributes;
return this;
}
public SubChannel build() {
return new SubChannel(platformCode, externalStoreId, platform, name,
sellerId, accountName, status, region, regionName, country,
marketplaceId, marketplaceNum, attributes);
}
}
} }
} }

30
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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 领星 · 亚马逊 SC 店铺列表。 * 领星 · 亚马逊 SC 店铺列表。
@ -41,12 +43,30 @@ public final class AmazonScShopSource implements LingxingShopSource {
continue; continue;
} }
// platformCode 取领星侧 Amazon SC 的平台码 10001;externalStoreId 用领星店铺 id(sid) // platformCode 取领星侧 Amazon SC 的平台码 10001;externalStoreId 用领星店铺 id(sid)
out.add(new SubChannel( out.add(SubChannel.builder()
AMAZON_SC_PLATFORM_CODE, .platformCode(AMAZON_SC_PLATFORM_CODE)
String.valueOf(shop.getSid()), .externalStoreId(String.valueOf(shop.getSid()))
Platform.AMAZON_SC, .platform(Platform.AMAZON_SC)
shop.getName() == null ? shop.getSellerId() : shop.getName())); .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); return Collections.unmodifiableList(out);
} }
/** 未标准化的原始字段:只保留有值的。 */
private static Map<String, Object> attributesOf(AmazonScShopDto shop) {
Map<String, Object> attrs = new LinkedHashMap<String, Object>();
attrs.put("seller_account_id", shop.getSellerAccountId());
attrs.put("has_ads_setting", shop.getHasAdsSetting());
attrs.values().removeAll(Collections.singleton(null));
return attrs;
}
} }

26
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) { || shop.getStatus() != STATUS_ACTIVE) {
continue; continue;
} }
out.add(new SubChannel( out.add(SubChannel.builder()
AMAZON_VC_PLATFORM_CODE, .platformCode(AMAZON_VC_PLATFORM_CODE)
shop.getVcStoreId(), .externalStoreId(shop.getVcStoreId())
Platform.AMAZON_VC, .platform(Platform.AMAZON_VC)
shop.getName() == null ? shop.getSellerId() : shop.getName())); .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(); offset += page.size();
@ -67,4 +75,12 @@ public final class AmazonVcShopSource implements LingxingShopSource {
} }
return Collections.unmodifiableList(out); return Collections.unmodifiableList(out);
} }
/** 未标准化的原始字段:只保留有值的。 */
private static Map<String, Object> attributesOf(AmazonVcShopDto shop) {
Map<String, Object> attrs = new LinkedHashMap<String, Object>();
attrs.put("account_id", shop.getAccountId());
attrs.values().removeAll(Collections.singleton(null));
return attrs;
}
} }

Loading…
Cancel
Save