fix: 修复测试方法调用和订单内容格式
修复测试文件中错误的方法调用,从testQueryOrder改为testCreateOrder 调整订单内容格式,移除SKU显示并简化格式 修正电话号码字段的类型断言问题 修复日期格式错误,从mm改为MM 更新API基础URL和端点路径 移除不必要的日志对象调用,改用console.log
This commit is contained in:
parent
c8236070b0
commit
05a2ca8cfb
|
|
@ -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 ||
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ export class FreightwavesService {
|
|||
private async sendRequest<T>(url: string, data: any): Promise<FreightwavesResponse<T>> {
|
||||
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<FreightwavesResponse<T>>(
|
||||
`${this.config.apiBaseUrl}${url}`,
|
||||
|
|
@ -267,7 +267,7 @@ export class FreightwavesService {
|
|||
partner: this.config.partner,
|
||||
};
|
||||
|
||||
const response = await this.sendRequest<CreateOrderResponseData>('/shipService/order/createOrder?apipost_id=0422aa', requestData);
|
||||
const response = await this.sendRequest<CreateOrderResponseData>('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<CreateOrderRequest, 'partner'> = {
|
||||
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'
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue