From ca0b5e63a76ef8a41f39ed030cffcd6abefb92c6 Mon Sep 17 00:00:00 2001 From: tikkhun Date: Sat, 10 Jan 2026 15:48:39 +0800 Subject: [PATCH] =?UTF-8?q?refactor(shopyy):=20=E7=BB=9F=E4=B8=80=E8=B4=A6?= =?UTF-8?q?=E5=8D=95=E5=9C=B0=E5=9D=80=E5=AD=97=E6=AE=B5=E5=90=8D=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=A9=BA=E5=80=BC=E6=A3=80=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 billing_address 字段重命名为 bill_address 以保持命名一致性 在订单映射方法中添加空值检查防止空对象错误 --- src/adapter/shopyy.adapter.ts | 8 +++++--- src/dto/shopyy.dto.ts | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/adapter/shopyy.adapter.ts b/src/adapter/shopyy.adapter.ts index 2843547..5e90320 100644 --- a/src/adapter/shopyy.adapter.ts +++ b/src/adapter/shopyy.adapter.ts @@ -227,8 +227,10 @@ export class ShopyyAdapter implements ISiteAdapter { // ========== 订单映射方法 ========== mapPlatformToUnifiedOrder(item: ShopyyOrder): UnifiedOrderDTO { + console.log(item) + if(!item) throw new Error('订单数据不能为空') // 提取账单和送货地址 如果不存在则为空对象 - const billing = (item as any).billing_address || {}; + const billing = (item).bill_address || {}; const shipping = (item as any).shipping_address || {}; // 构建账单地址对象 @@ -237,7 +239,7 @@ export class ShopyyAdapter implements ISiteAdapter { last_name: billing.last_name || item.lastname || '', fullname: billing.name || `${item.firstname} ${item.lastname}`.trim(), company: billing.company || '', - email: item.customer_email || item.email || '', + email: item.customer_email || item.email || '',√ phone: billing.phone || (item as any).telephone || '', address_1: billing.address1 || item.payment_address || '', address_2: billing.address2 || '', @@ -440,7 +442,7 @@ export class ShopyyAdapter implements ISiteAdapter { } // 更新账单地址 - params.billing_address = params.billing_address || {}; + params.billing_address = params?.billing_address || {}; if (data.billing.first_name !== undefined) { params.billing_address.first_name = data.billing.first_name; } diff --git a/src/dto/shopyy.dto.ts b/src/dto/shopyy.dto.ts index b434fa8..37bd5e7 100644 --- a/src/dto/shopyy.dto.ts +++ b/src/dto/shopyy.dto.ts @@ -200,7 +200,7 @@ export interface ShopyyOrder { customer_email?: string; email?: string; // 地址字段 - billing_address?: { + bill_address?: { first_name?: string; last_name?: string; name?: string; -- 2.40.1