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