Browse Source

fix(lingxing): ¥ 符号统一按日元处理,CNY 视为人民币

约定:渠道只给货币符号时,¥ / ¥ 一律映射 JPY;
人民币由平台以 ISO 代码 CNY(或 RMB)返回,显式映射 CNY。

涉及 SC 之外的全部商品实现:
- AmazonVcProductSource
- WalmartProductSource
- TemuProductSource
- ShopifyProductSource

此前 ¥ 返回 null 导致价格被置空,现可正常落库。

Co-Authored-By: Claude <noreply@anthropic.com>
feature/supplier-lingxing
chenchuchuan 3 weeks ago
parent
commit
6a22e9057c
  1. 11
      lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java
  2. 9
      lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java
  3. 11
      lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java
  4. 7
      lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java

11
lingxing/src/main/java/common/ecommerce/lingxing/platform/amazon/vc/product/AmazonVcProductSource.java

@ -88,8 +88,8 @@ public final class AmazonVcProductSource implements LingxingProductSource {
* </ul> * </ul>
* *
* <p><b>币种说明</b>:VC 只给货币符号({@code price_currency_icon}),不给 ISO 代码。 * <p><b>币种说明</b>:VC 只给货币符号({@code price_currency_icon}),不给 ISO 代码。
* 这里按符号反推常见币种,反推不出时 currency 为 null、price 也为 null, * 按符号反推常见币种;约定 {@code ¥} 符号一律视为日元(人民币以 ISO 代码 {@code CNY} 返回)。
* 原值保留在 attributes 里。改由店铺币种兜底需要账户信息,当前不猜。</p> * 反推不出时 currency 为 null、price 也为 null,原值保留在 attributes 里。</p>
*/ */
private ProductListing toProductListing(AmazonVcListingDto dto, LingxingCall call) { private ProductListing toProductListing(AmazonVcListingDto dto, LingxingCall call) {
ZoneId zone = ZoneId.of(call.ctx().account().marketplaceZone()); ZoneId zone = ZoneId.of(call.ctx().account().marketplaceZone());
@ -179,8 +179,11 @@ public final class AmazonVcProductSource implements LingxingProductSource {
return "GBP"; return "GBP";
} }
if ("¥".equals(s) || "¥".equals(s)) { if ("¥".equals(s) || "¥".equals(s)) {
// 人民币与日元共用符号,无法区分;返回 null 避免误判 // 约定:¥ 符号按日元处理;人民币由平台以 ISO 代码 CNY 返回
return null; return "JPY";
}
if ("CNY".equalsIgnoreCase(s) || "RMB".equalsIgnoreCase(s)) {
return "CNY";
} }
if ("C$".equals(s) || "CA$".equals(s)) { if ("C$".equals(s) || "CA$".equals(s)) {
return "CAD"; return "CAD";

9
lingxing/src/main/java/common/ecommerce/lingxing/platform/shopify/product/ShopifyProductSource.java

@ -207,7 +207,7 @@ public final class ShopifyProductSource implements LingxingProductSource {
return attrs; return attrs;
} }
/** 货币符号 → ISO;¥/¥ 无法区分人民币与日元,返回 null。 */ /** 货币符号 → ISO;约定 ¥ 符号视为日元,人民币以 ISO 代码 CNY 返回。 */
private static String currencyOf(String icon) { private static String currencyOf(String icon) {
if (icon == null) { if (icon == null) {
return null; return null;
@ -222,6 +222,13 @@ public final class ShopifyProductSource implements LingxingProductSource {
if ("£".equals(s)) { if ("£".equals(s)) {
return "GBP"; return "GBP";
} }
if ("¥".equals(s) || "¥".equals(s)) {
// 约定:¥ 符号按日元处理;人民币由平台以 ISO 代码 CNY 返回
return "JPY";
}
if ("CNY".equalsIgnoreCase(s) || "RMB".equalsIgnoreCase(s)) {
return "CNY";
}
return null; return null;
} }

11
lingxing/src/main/java/common/ecommerce/lingxing/platform/temu/product/TemuProductSource.java

@ -119,8 +119,8 @@ public final class TemuProductSource implements LingxingProductSource {
* </ul> * </ul>
* *
* <p><b>价格说明</b>:Temu 要求上报「申报价」,{@code supplyPriceList} 按时间区间分段, * <p><b>价格说明</b>:Temu 要求上报「申报价」,{@code supplyPriceList} 按时间区间分段,
* 取 {@code endStr} 为空(当前生效)或开始时间最晚的一条。币种字段是符号「¥」, * 取 {@code endStr} 为空(当前生效)或开始时间最晚的一条。
* 无法区分人民币/日元,按符号映射为 null 时不填金额。</p> * 币种按约定:{@code ¥} 符号视为日元,ISO 代码 {@code CNY} 视为人民币。</p>
*/ */
private ProductListing toProductListing(TemuListingDto dto, LingxingCall call) { private ProductListing toProductListing(TemuListingDto dto, LingxingCall call) {
TemuSupplyPriceDto price = currentSupplyPrice(dto.getSupplyPriceList()); TemuSupplyPriceDto price = currentSupplyPrice(dto.getSupplyPriceList());
@ -240,6 +240,13 @@ public final class TemuProductSource implements LingxingProductSource {
if ("£".equals(s)) { if ("£".equals(s)) {
return "GBP"; return "GBP";
} }
if ("¥".equals(s) || "¥".equals(s)) {
// 约定:¥ 符号按日元处理;人民币由平台以 ISO 代码 CNY 返回
return "JPY";
}
if ("CNY".equalsIgnoreCase(s) || "RMB".equalsIgnoreCase(s)) {
return "CNY";
}
return null; return null;
} }

7
lingxing/src/main/java/common/ecommerce/lingxing/platform/walmart/product/WalmartProductSource.java

@ -217,6 +217,13 @@ public final class WalmartProductSource implements LingxingProductSource {
if ("MXN".equals(s) || "MX$".equals(s)) { if ("MXN".equals(s) || "MX$".equals(s)) {
return "MXN"; return "MXN";
} }
if ("¥".equals(s) || "¥".equals(s)) {
// 约定:¥ 符号按日元处理;人民币由平台以 ISO 代码 CNY 返回
return "JPY";
}
if ("CNY".equalsIgnoreCase(s) || "RMB".equalsIgnoreCase(s)) {
return "CNY";
}
return null; return null;
} }

Loading…
Cancel
Save