fix(logistics): 修复物流服务中的错误处理和快递公司字段
修复freightwaves服务中的错误响应处理,增加错误码检查 添加courierCompany字段到物流DTO以支持不同快递公司 移除订单服务中注释掉的saveOrderSale调用 更新物流服务中使用courierCompany代替硬编码的shipCompany
This commit is contained in:
parent
51b59ca176
commit
0a14a7c1ae
|
|
@ -23,6 +23,10 @@ export class ShipmentBookDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
@Rule(RuleType.string())
|
@Rule(RuleType.string())
|
||||||
shipmentPlatform: string;
|
shipmentPlatform: string;
|
||||||
|
|
||||||
|
@ApiProperty()
|
||||||
|
@Rule(RuleType.string())
|
||||||
|
courierCompany: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ShipmentFeeBookDTO {
|
export class ShipmentFeeBookDTO {
|
||||||
|
|
@ -30,6 +34,8 @@ export class ShipmentFeeBookDTO {
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
shipmentPlatform: string;
|
shipmentPlatform: string;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
|
courierCompany: string;
|
||||||
|
@ApiProperty()
|
||||||
stockPointId: number;
|
stockPointId: number;
|
||||||
@ApiProperty()
|
@ApiProperty()
|
||||||
sender: string;
|
sender: string;
|
||||||
|
|
|
||||||
|
|
@ -247,6 +247,9 @@ export class FreightwavesService {
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this.sendRequest<RateTryResponseData>('/shipService/order/rateTry', requestData);
|
const response = await this.sendRequest<RateTryResponseData>('/shipService/order/rateTry', requestData);
|
||||||
|
if (response.code !== '00000200') {
|
||||||
|
throw new Error(response.msg);
|
||||||
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -262,7 +265,10 @@ export class FreightwavesService {
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this.sendRequest<CreateOrderResponseData>('/shipService/order/createOrder', requestData);
|
const response = await this.sendRequest<CreateOrderResponseData>('/shipService/order/createOrder', requestData);
|
||||||
return response;
|
if (response.code !== '00000200') {
|
||||||
|
throw new Error(response.msg);
|
||||||
|
}
|
||||||
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -295,6 +301,9 @@ export class FreightwavesService {
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await this.sendRequest<ModifyOrderResponseData>('/shipService/order/modifyOrder', requestData);
|
const response = await this.sendRequest<ModifyOrderResponseData>('/shipService/order/modifyOrder', requestData);
|
||||||
|
if (response.code !== '00000200') {
|
||||||
|
throw new Error(response.msg);
|
||||||
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,6 +318,9 @@ export class FreightwavesService {
|
||||||
partner: this.config.partner,
|
partner: this.config.partner,
|
||||||
};
|
};
|
||||||
const response = await this.sendRequest<RefundOrderResponseData>('/shipService/order/refundOrder', requestData);
|
const response = await this.sendRequest<RefundOrderResponseData>('/shipService/order/refundOrder', requestData);
|
||||||
|
if (response.code !== '00000200') {
|
||||||
|
throw new Error(response.msg);
|
||||||
|
}
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -733,7 +733,8 @@ export class LogisticsService {
|
||||||
if (data.shipmentPlatform === 'freightwaves') {
|
if (data.shipmentPlatform === 'freightwaves') {
|
||||||
// 根据TMS系统对接说明文档格式化参数
|
// 根据TMS系统对接说明文档格式化参数
|
||||||
const reqBody: any = {
|
const reqBody: any = {
|
||||||
shipCompany: 'UPSYYZ7000NEW',
|
// shipCompany: 'UPSYYZ7000NEW',
|
||||||
|
shipCompany: data.courierCompany || "",
|
||||||
partnerOrderNumber: order.siteId + '-' + order.externalOrderId,
|
partnerOrderNumber: order.siteId + '-' + order.externalOrderId,
|
||||||
warehouseId: '25072621030107400060',
|
warehouseId: '25072621030107400060',
|
||||||
shipper: {
|
shipper: {
|
||||||
|
|
@ -798,6 +799,7 @@ export class LogisticsService {
|
||||||
};
|
};
|
||||||
|
|
||||||
resShipmentOrder = await this.freightwavesService.createOrder(reqBody); // 创建订单
|
resShipmentOrder = await this.freightwavesService.createOrder(reqBody); // 创建订单
|
||||||
|
|
||||||
//tms只返回了物流订单号,需要查询一次来获取完整的物流信息
|
//tms只返回了物流订单号,需要查询一次来获取完整的物流信息
|
||||||
const queryRes = await this.freightwavesService.queryOrder({ shipOrderId: resShipmentOrder.shipOrderId }); // 查询订单
|
const queryRes = await this.freightwavesService.queryOrder({ shipOrderId: resShipmentOrder.shipOrderId }); // 查询订单
|
||||||
resShipmentOrder.push(queryRes);
|
resShipmentOrder.push(queryRes);
|
||||||
|
|
@ -826,7 +828,8 @@ export class LogisticsService {
|
||||||
const address = shipments?.address;
|
const address = shipments?.address;
|
||||||
// 转换为RateTryRequest格式
|
// 转换为RateTryRequest格式
|
||||||
const r = {
|
const r = {
|
||||||
shipCompany: 'UPSYYZ7000NEW', // 必填,但ShipmentFeeBookDTO中缺少
|
//shipCompany: 'UPSYYZ7000NEW', // 必填,但ShipmentFeeBookDTO中缺少
|
||||||
|
shipCompany: data.courierCompany || "",
|
||||||
partnerOrderNumber: `order-${Date.now()}`, // 必填,使用时间戳生成
|
partnerOrderNumber: `order-${Date.now()}`, // 必填,使用时间戳生成
|
||||||
warehouseId: '25072621030107400060', // 可选,使用stockPointId转换
|
warehouseId: '25072621030107400060', // 可选,使用stockPointId转换
|
||||||
shipper: {
|
shipper: {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue