From f8320915580a0ab75eb681a1b81677fa664640ab Mon Sep 17 00:00:00 2001 From: chenchuchuan <13554600537@163.com> Date: Tue, 3 Nov 2026 14:55:43 +0800 Subject: [PATCH] =?UTF-8?q?style(lingxing):=20=E5=8D=95=E8=A1=8C=E8=AF=AD?= =?UTF-8?q?=E5=8F=A5=E4=B8=8D=E5=86=8D=E7=A1=AC=E6=8B=86=E5=A4=9A=E8=A1=8C?= =?UTF-8?q?=EF=BC=9BAliExpress=20price=20=E5=8F=AA=E5=81=9A=E5=8D=95?= =?UTF-8?q?=E4=BD=8D=E6=8D=A2=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 代码风格: - 按用户要求,能放一行的语句不拆成两行 (listAt(...)、body.put(...)、字段初始化等 11 处) AliExpress 价格: - 统一模型 price 只取接口自身的 price 字段(单位:分)÷ 100 - 不再用 effectiveSupplyPrice 或 supplyPriceList 替代 / 兜底 - 删除不再使用的 currentSupplyPrice 辅助方法 约定已记入项目记忆:价格只做单位换算,缺字段给 null,原始值留在 attributes。 Co-Authored-By: Claude --- .../ecommerce/lingxing/dto/LingxingOrderDto.java | 3 +- .../product/AliexpressProductSource.java | 53 +++------------------- .../amazon/sc/product/AmazonScProductSource.java | 3 +- .../amazon/vc/product/AmazonVcProductSource.java | 4 +- .../platform/ebay/product/EbayProductSource.java | 3 +- .../platform/shein/product/SheinProductSource.java | 4 +- .../shopify/product/ShopifyProductSource.java | 7 +-- .../lingxing/platform/temu/dto/TemuListingDto.java | 3 +- .../platform/temu/product/TemuProductSource.java | 7 +-- .../tiktok/product/TiktokProductSource.java | 4 +- .../walmart/product/WalmartProductSource.java | 3 +- 11 files changed, 19 insertions(+), 75 deletions(-) diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/dto/LingxingOrderDto.java b/lingxing/src/main/java/common/ecommerce/lingxing/dto/LingxingOrderDto.java index a607ded..dc467fb 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/dto/LingxingOrderDto.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/dto/LingxingOrderDto.java @@ -74,6 +74,5 @@ public class LingxingOrderDto { /** 交易信息。 */ @JsonProperty("transaction_info") - private List transactionInfo = - new ArrayList(); + private List transactionInfo = new ArrayList(); } diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java index 2c52492..80356d3 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/aliexpress/product/AliexpressProductSource.java @@ -6,7 +6,6 @@ import common.ecommerce.lingxing.LingxingApi; import common.ecommerce.lingxing.http.LingxingEnvelope; import common.ecommerce.lingxing.platform.LingxingCall; import common.ecommerce.lingxing.platform.aliexpress.dto.AliexpressListingDto; -import common.ecommerce.lingxing.platform.aliexpress.dto.AliexpressSupplyPriceDto; import common.ecommerce.lingxing.platform.product.LingxingProductSource; import common.ecommerce.model.ChannelProvider; import common.ecommerce.model.product.ProductListing; @@ -44,8 +43,7 @@ public final class AliexpressProductSource implements LingxingProductSource { /** createTime 是北京时间。 */ private static final ZoneId BEIJING = ZoneId.of("Asia/Shanghai"); - private static final DateTimeFormatter DATE_TIME = - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static final DateTimeFormatter DATE_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); private static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd"); @Override @@ -57,16 +55,14 @@ public final class AliexpressProductSource implements LingxingProductSource { body.put("isParent", IS_CHILD); body.put("offset", offset); body.put("length", length); - body.put("storeIds", - Collections.singletonList(parseStoreId(call.ctx().account().externalStoreId()))); + body.put("storeIds", Collections.singletonList(parseStoreId(call.ctx().account().externalStoreId()))); applyTimeWindow(body, query); HttpRequest req = call.signed(LingxingApi.LISTING_ALIEXPRESS, body, "products.pull"); HttpResponse resp = call.execute(req); LingxingEnvelope envelope = call.envelope(resp, "products.pull"); - List dtos = - call.json().listAt(envelope.body(), "data.list", AliexpressListingDto.class); + List dtos = call.json().listAt(envelope.body(), "data.list", AliexpressListingDto.class); List out = new ArrayList(dtos.size()); for (AliexpressListingDto dto : dtos) { out.add(toProductListing(dto, call)); @@ -128,9 +124,7 @@ public final class AliexpressProductSource implements LingxingProductSource { *
  • imageUrls ← {@code skuImage},为空时用 {@code imageUrls}(父体图)
  • *
  • status ← {@code status}(文档只给了「可售」=2,其余归 UNKNOWN)
  • *
  • rawStatus ← {@code statusName} 原值(中文)
  • - *
  • price ← 优先 {@code effectiveSupplyPrice}(已格式化的字符串); - * 缺失时用 {@code price}(单位:分)除以 100 转成标准金额; - * 再缺失时取当前生效的 {@code supplyPriceList} 条目
  • + *
  • price ← {@code price}(单位:分)除以 100 转成标准金额
  • *
  • listedAt ← {@code createTime}(北京时间,按 UTC 换算)
  • *
  • updatedAt ← 无
  • *
  • attributes ← 其余全部原始字段
  • @@ -140,10 +134,7 @@ public final class AliexpressProductSource implements LingxingProductSource { ZoneId zone = ZoneId.of(call.ctx().account().marketplaceZone()); String image = firstNonBlank(dto.getSkuImage(), dto.getImageUrls()); String currency = trimToNull(dto.getCurrencyCode()); - String price = firstNonBlank( - dto.getEffectiveSupplyPrice(), - centsToAmount(dto.getPrice()), - currentSupplyPrice(dto.getSupplyPriceList())); + String price = centsToAmount(dto.getPrice()); return ProductListing.builder() .platform(call.ctx().platform()) @@ -165,8 +156,8 @@ public final class AliexpressProductSource implements LingxingProductSource { /** * 接口的 {@code price} 单位是分,统一模型用标准金额(元),此处除以 100。 * - *

    文档示例 99990000 与 effectiveSupplyPrice 59.99 不一致,属于文档笔误; - * 以「单位分」为准做换算。

    + *

    只做单位换算,不使用 {@code effectiveSupplyPrice} 或 {@code supplyPriceList} + * 作为替代来源。

    */ private static String centsToAmount(Long cents) { if (cents == null) { @@ -175,36 +166,6 @@ public final class AliexpressProductSource implements LingxingProductSource { return java.math.BigDecimal.valueOf(cents, 2).toPlainString(); } - /** 当前生效供货价:优先 endStr 为空,否则取 beginStr 最大的一条。 */ - private static String currentSupplyPrice(List prices) { - if (prices == null || prices.isEmpty()) { - return null; - } - AliexpressSupplyPriceDto best = null; - for (AliexpressSupplyPriceDto p : prices) { - if (p == null || p.getPrice() == null) { - continue; - } - if (p.getEndStr() == null || p.getEndStr().trim().isEmpty()) { - return p.getPrice().toPlainString(); - } - if (best == null || compareBegin(p.getBeginStr(), best.getBeginStr()) > 0) { - best = p; - } - } - return best == null ? null : best.getPrice().toPlainString(); - } - - private static int compareBegin(String a, String b) { - if (a == null) { - return b == null ? 0 : -1; - } - if (b == null) { - return 1; - } - return a.compareTo(b); - } - /** 文档只给了「2 可售」,其余归 UNKNOWN,保留原值在 rawStatus。 */ private static ProductStatus statusOf(Integer status) { if (status == null) { diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java index 72f5f07..730e528 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/sc/product/AmazonScProductSource.java @@ -38,8 +38,7 @@ public final class AmazonScProductSource implements LingxingProductSource { private static final int MAX_PAGE_SIZE = 1000; /** listing_update_date 是零时区时间,格式 Y-m-d H:i:s。 */ - private static final DateTimeFormatter LISTING_TIME = - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + private static final DateTimeFormatter LISTING_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); /** 只有日期的字段,如 on_sale_time / first_order_time。 */ private static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java index 6b0d1f7..ca2fdf1 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java @@ -49,9 +49,7 @@ public final class AmazonVcProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("vc_store_ids", - Collections.singletonList(call.ctx().account().externalStoreId())); - + body.put("vc_store_ids", Collections.singletonList(call.ctx().account().externalStoreId())); HttpRequest req = call.signed(LingxingApi.LISTING_AMAZON_VC, body, "products.pull"); HttpResponse resp = call.execute(req); LingxingEnvelope envelope = call.envelope(resp, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java index 4ee31fc..530158f 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/ebay/product/EbayProductSource.java @@ -55,8 +55,7 @@ public final class EbayProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("store_ids", - Collections.singletonList(call.ctx().account().externalStoreId())); + body.put("store_ids", Collections.singletonList(call.ctx().account().externalStoreId())); applyTimeWindow(body, query); HttpRequest req = call.signed(LingxingApi.LISTING_EBAY, body, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java index 5dbb1d2..acc6848 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/shein/product/SheinProductSource.java @@ -41,9 +41,7 @@ public final class SheinProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("storeIds", - Collections.singletonList(call.ctx().account().externalStoreId())); - + body.put("storeIds", Collections.singletonList(call.ctx().account().externalStoreId())); HttpRequest req = call.signed(LingxingApi.LISTING_SHEIN, body, "products.pull"); HttpResponse resp = call.execute(req); LingxingEnvelope envelope = call.envelope(resp, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java index 1ad1968..79ce639 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java @@ -37,9 +37,7 @@ public final class ShopifyProductSource implements LingxingProductSource { private static final int MAX_PAGE_SIZE = 1000; /** 时间字段格式,文档未给出示例值格式,按 Y-m-d H:i:s 发送。 */ - private static final DateTimeFormatter DATE_TIME = - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - + private static final DateTimeFormatter DATE_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Override public Page products(LingxingCall call, ProductQuery query) { int length = Math.min(query.pageSize() <= 0 ? 100 : query.pageSize(), MAX_PAGE_SIZE); @@ -48,8 +46,7 @@ public final class ShopifyProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("store_ids", - Collections.singletonList(call.ctx().account().externalStoreId())); + body.put("store_ids", Collections.singletonList(call.ctx().account().externalStoreId())); applyTimeWindow(body, query); HttpRequest req = call.signed(LingxingApi.LISTING_SHOPIFY, body, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/dto/TemuListingDto.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/dto/TemuListingDto.java index c18c44c..3c803ae 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/dto/TemuListingDto.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/dto/TemuListingDto.java @@ -164,6 +164,5 @@ public class TemuListingDto { /** 活动价详情。 */ @JsonProperty("promotionalPriceDataList") - private List promotionalPriceDataList = - new ArrayList(); + private List promotionalPriceDataList = new ArrayList(); } diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java index a042b89..226f5bd 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java @@ -37,9 +37,7 @@ public final class TemuProductSource implements LingxingProductSource { private static final int MAX_PAGE_SIZE = 1000; /** 更新时间区间格式。 */ - private static final DateTimeFormatter DATE_TIME = - DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - + private static final DateTimeFormatter DATE_TIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); @Override public Page products(LingxingCall call, ProductQuery query) { int length = Math.min(query.pageSize() <= 0 ? 100 : query.pageSize(), MAX_PAGE_SIZE); @@ -49,8 +47,7 @@ public final class TemuProductSource implements LingxingProductSource { body.put("offset", offset); body.put("length", length); body.put("useCursor", Boolean.FALSE); - body.put("storeIds", - Collections.singletonList(call.ctx().account().externalStoreId())); + body.put("storeIds", Collections.singletonList(call.ctx().account().externalStoreId())); applyTimeWindow(body, query); HttpRequest req = call.signed(LingxingApi.LISTING_TEMU, body, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java index 6260966..bf57455 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/tiktok/product/TiktokProductSource.java @@ -39,9 +39,7 @@ public final class TiktokProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("storeIds", - Collections.singletonList(call.ctx().account().externalStoreId())); - + body.put("storeIds", Collections.singletonList(call.ctx().account().externalStoreId())); HttpRequest req = call.signed(LingxingApi.LISTING_TIKTOK, body, "products.pull"); HttpResponse resp = call.execute(req); LingxingEnvelope envelope = call.envelope(resp, "products.pull"); diff --git a/lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java b/lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java index 20ae14a..306741d 100644 --- a/lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java +++ b/lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java @@ -59,8 +59,7 @@ public final class WalmartProductSource implements LingxingProductSource { Map body = new LinkedHashMap(); body.put("offset", offset); body.put("length", length); - body.put("store_ids", - Collections.singletonList(call.ctx().account().externalStoreId())); + body.put("store_ids", Collections.singletonList(call.ctx().account().externalStoreId())); applyTimeWindow(body, query); HttpRequest req = call.signed(LingxingApi.LISTING_WALMART, body, "products.pull");