From 05a2ca8cfbbebba645fad9f3979bf61aa28c8e6f Mon Sep 17 00:00:00 2001 From: zhuotianyuan Date: Sat, 17 Jan 2026 11:03:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=E5=92=8C=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=86=85=E5=AE=B9=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复测试文件中错误的方法调用,从testQueryOrder改为testCreateOrder 调整订单内容格式,移除SKU显示并简化格式 修正电话号码字段的类型断言问题 修复日期格式错误,从mm改为MM 更新API基础URL和端点路径 移除不必要的日志对象调用,改用console.log --- src/adapter/shopyy.adapter.ts | 4 ++-- src/service/freightwaves.service.ts | 16 ++++++++-------- src/service/order.service.ts | 4 ++-- test-freightwaves.js | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/adapter/shopyy.adapter.ts b/src/adapter/shopyy.adapter.ts index b5321a6..ec50ea8 100644 --- a/src/adapter/shopyy.adapter.ts +++ b/src/adapter/shopyy.adapter.ts @@ -244,7 +244,7 @@ export class ShopyyAdapter implements ISiteAdapter { fullname: billing.name || `${item.firstname} ${item.lastname}`.trim(), company: billing.company || '', email: item.customer_email || item.email || '', - phone: billing.phone || (item as any).telephone || '', + phone: billing.phone || item.telephone || '', address_1: billing.address1 || item.payment_address || '', address_2: billing.address2 || '', city: billing.city || item.payment_city || '', @@ -275,7 +275,7 @@ export class ShopyyAdapter implements ISiteAdapter { state: shipping.province || item.shipping_zone || '', postcode: shipping.zip || item.shipping_postcode || '', method_title: item.payment_method || '', - phone: shipping.phone || (item as any).telephone || '', + phone: shipping.phone || item.telephone || '', country: shipping.country_name || shipping.country_code || diff --git a/src/service/freightwaves.service.ts b/src/service/freightwaves.service.ts index 10900ef..dfb0ef6 100644 --- a/src/service/freightwaves.service.ts +++ b/src/service/freightwaves.service.ts @@ -172,7 +172,7 @@ export class FreightwavesService { private async sendRequest(url: string, data: any): Promise> { try { // 设置请求头 - 使用太平洋时间 (America/Los_Angeles) - const date = dayjs().tz('America/Los_Angeles').format('YYYY-mm-dd HH:mm:ss'); + const date = dayjs().tz('America/Los_Angeles').format('YYYY-MM-DD HH:mm:ss'); const headers = { 'Content-Type': 'application/json', 'requestDate': date, @@ -180,11 +180,11 @@ export class FreightwavesService { }; // 记录请求前的详细信息 - this.log(`Sending request to: ${this.config.apiBaseUrl}${url}`, { + console.log(`Sending request to: ${this.config.apiBaseUrl}${url}`,JSON.stringify({ headers, data - }); - + })) + console.log('Request data:', `${this.config.apiBaseUrl}${url}`, data,headers); // 发送请求 - 临时禁用SSL证书验证以解决UNABLE_TO_VERIFY_LEAF_SIGNATURE错误 const response = await axios.post>( `${this.config.apiBaseUrl}${url}`, @@ -267,7 +267,7 @@ export class FreightwavesService { partner: this.config.partner, }; - const response = await this.sendRequest('/shipService/order/createOrder?apipost_id=0422aa', requestData); + const response = await this.sendRequest('shipService/order/rateTry', requestData); return response.data; } @@ -325,13 +325,13 @@ export class FreightwavesService { // 设置必要的配置 this.setConfig({ appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt', - apiBaseUrl: 'https://tms.freightwaves.ca', + apiBaseUrl: 'http://tms.freightwaves.ca:8901/', partner: '25072621035200000060' }); // 准备测试数据 const testParams: Omit = { - shipCompany: 'DHL', + shipCompany: '', partnerOrderNumber: `test-order-${Date.now()}`, warehouseId: '25072621035200000060', shipper: { @@ -423,7 +423,7 @@ export class FreightwavesService { // 设置必要的配置 this.setConfig({ appSecret: 'gELCHguGmdTLo!zfihfM91hae8G@9Sz23Mh6pHrt', - apiBaseUrl: 'https://tms.freightwaves.ca', + apiBaseUrl: 'http://freightwaves.ca:8901/shipService/order/rateTry', partner: '25072621035200000060' }); diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 586a5b4..d3660a5 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -2512,7 +2512,7 @@ export class OrderService { const boxCount = items.reduce((total, item) => total + item.quantity, 0); // 构建订单内容 - const orderContent = items.map(item => `${item.name} (${item.sku || ''}) x ${item.quantity}`).join('; '); + const orderContent = items.map(item => `${item.name} x ${item.quantity}`).join('; '); // 构建姓名地址 const shipping = order.shipping; @@ -2544,7 +2544,7 @@ export class OrderService { '姓名地址': nameAddress, '邮箱': order.customer_email || '', '号码': phone, - '订单内容': this.removeLastParenthesesContent(orderContent), + '订单内容': orderContent, '盒数': boxCount, '换盒数': exchangeBoxCount, '换货内容': exchangeContent, diff --git a/test-freightwaves.js b/test-freightwaves.js index c41c661..9236bcf 100644 --- a/test-freightwaves.js +++ b/test-freightwaves.js @@ -9,7 +9,7 @@ async function testFreightwavesService() { // Call the test method console.log('Starting test for createOrder method...'); - const result = await service.testQueryOrder(); + const result = await service.testCreateOrder(); console.log('Test completed successfully!'); console.log('Result:', result);