Browse Source
重复实现(合并分支与本分支各写了一份): - amazon/vc/shop:VcShopSource 与 AmazonVcShopSource 重复, 保留带内部翻页的 VcShopSource,删除 AmazonVcShopSource; 同时去掉它按 status==1 过滤的行为(统一遵守“只转发”约定) - amazon/vc/dto:删除不再引用的 AmazonVcShopDto 补齐: - AmazonVcSubPlatform 接上 VcOrderSource(合并分支已实现 VC 订单, 但子平台未声明),现在 VC 支持 订单/商品/店铺 三项 全库已无同名重复类,BUILD SUCCESS。 Co-Authored-By: Claude <noreply@anthropic.com>feature/supplier-lingxing
4 changed files with 15 additions and 144 deletions
@ -1,53 +0,0 @@ |
|||||||
package common.ecommerce.lingxing.platform.amazon.vc.dto; |
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty; |
|
||||||
import lombok.Getter; |
|
||||||
import lombok.Setter; |
|
||||||
|
|
||||||
/** |
|
||||||
* 领星 · 亚马逊 VC 店铺({@code /basicOpen/platformAuth/vcSeller/pageList} 的 {@code data[]})。 |
|
||||||
* |
|
||||||
* <p>唯一键 {@code vc_store_id},后续查 VC Listing 时用它指定店铺。</p> |
|
||||||
*/ |
|
||||||
@Getter |
|
||||||
@Setter |
|
||||||
@JsonIgnoreProperties(ignoreUnknown = true) |
|
||||||
public class AmazonVcShopDto { |
|
||||||
|
|
||||||
/** 账号 ID。 */ |
|
||||||
@JsonProperty("account_id") |
|
||||||
private Long accountId; |
|
||||||
|
|
||||||
/** SELLER_ID。 */ |
|
||||||
@JsonProperty("seller_id") |
|
||||||
private String sellerId; |
|
||||||
|
|
||||||
/** 账号名称。 */ |
|
||||||
@JsonProperty("account_name") |
|
||||||
private String accountName; |
|
||||||
|
|
||||||
/** 站点简称,如 na。 */ |
|
||||||
@JsonProperty("region") |
|
||||||
private String region; |
|
||||||
|
|
||||||
/** 站点名称,如 北美洲。 */ |
|
||||||
@JsonProperty("region_name") |
|
||||||
private String regionName; |
|
||||||
|
|
||||||
/** VC 店铺 id,后续接口的入参。 */ |
|
||||||
@JsonProperty("vc_store_id") |
|
||||||
private String vcStoreId; |
|
||||||
|
|
||||||
/** 店铺名称。 */ |
|
||||||
@JsonProperty("name") |
|
||||||
private String name; |
|
||||||
|
|
||||||
/** 店铺授权服务状态:-1 删除,0 暂停同步,1 正常同步,2 授权异常。 */ |
|
||||||
@JsonProperty("status") |
|
||||||
private Integer status; |
|
||||||
|
|
||||||
/** 站点 id。 */ |
|
||||||
@JsonProperty("mid") |
|
||||||
private Integer mid; |
|
||||||
} |
|
||||||
@ -1,84 +0,0 @@ |
|||||||
package common.ecommerce.lingxing.platform.amazon.vc.shop; |
|
||||||
|
|
||||||
import common.ecommerce.capability.AggregatorCapable.SubChannel; |
|
||||||
import common.ecommerce.http.HttpRequest; |
|
||||||
import common.ecommerce.http.HttpResponse; |
|
||||||
import common.ecommerce.lingxing.LingxingApi; |
|
||||||
import common.ecommerce.lingxing.http.LingxingEnvelope; |
|
||||||
import common.ecommerce.lingxing.platform.LingxingCall; |
|
||||||
import common.ecommerce.lingxing.platform.amazon.vc.dto.AmazonVcShopDto; |
|
||||||
import common.ecommerce.lingxing.platform.shop.LingxingShopSource; |
|
||||||
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; |
|
||||||
|
|
||||||
/** |
|
||||||
* 领星 · 亚马逊 VC 店铺列表。 |
|
||||||
* |
|
||||||
* <p>接口 {@code /basicOpen/platformAuth/vcSeller/pageList}:POST,{@code offset}/{@code length} |
|
||||||
* 分页,{@code length} 上限 200,令牌桶容量 1。</p> |
|
||||||
* |
|
||||||
* <p>SDK 只做转发,<b>不按状态过滤</b>;调用方按 {@link SubChannel#status()} 自行决定用哪些。</p> |
|
||||||
*/ |
|
||||||
public final class AmazonVcShopSource implements LingxingShopSource { |
|
||||||
|
|
||||||
/** 领星侧 Amazon VC 的 platform_code。 */ |
|
||||||
private static final int AMAZON_VC_PLATFORM_CODE = 10035; |
|
||||||
|
|
||||||
private static final int MAX_PAGE_SIZE = 200; |
|
||||||
|
|
||||||
@Override |
|
||||||
public List<SubChannel> shops(LingxingCall call) { |
|
||||||
List<SubChannel> out = new ArrayList<SubChannel>(); |
|
||||||
int offset = 0; |
|
||||||
while (true) { |
|
||||||
Map<String, Object> body = new LinkedHashMap<String, Object>(); |
|
||||||
body.put("offset", offset); |
|
||||||
body.put("length", MAX_PAGE_SIZE); |
|
||||||
|
|
||||||
HttpRequest req = call.signed(LingxingApi.SHOP_LIST_AMAZON_VC, body, "shops.list"); |
|
||||||
HttpResponse resp = call.execute(req); |
|
||||||
LingxingEnvelope envelope = call.envelope(resp, "shops.list"); |
|
||||||
|
|
||||||
List<AmazonVcShopDto> page = call.json().listAt(envelope.body(), "data", AmazonVcShopDto.class); |
|
||||||
for (AmazonVcShopDto shop : page) { |
|
||||||
if (shop.getVcStoreId() == null) { |
|
||||||
continue; |
|
||||||
} |
|
||||||
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(); |
|
||||||
boolean hasMore = page.size() >= MAX_PAGE_SIZE |
|
||||||
&& (envelope.total() < 0 || offset < envelope.total()); |
|
||||||
if (!hasMore) { |
|
||||||
break; |
|
||||||
} |
|
||||||
} |
|
||||||
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…
Reference in new issue