Compare commits
No commits in common. "7a25a685a5ae9c0ed94a8be28a6220a821021a04" and "87a6d4080258e6f22f7b72e9adb522c1e78d8a3e" have entirely different histories.
7a25a685a5
...
87a6d40802
|
|
@ -21,7 +21,7 @@ export class SyncTmsJob implements IJob {
|
|||
shipmentModel: Repository<Shipment>
|
||||
|
||||
async onTick() {
|
||||
const shipments: Shipment[] = await this.shipmentModel.findBy({ tracking_provider: 'freightwaves', finished: false });
|
||||
const shipments:Shipment[] = await this.shipmentModel.findBy({ tracking_provider: 'freightwaves',finished: false });
|
||||
const results = await Promise.all(
|
||||
shipments.map(async shipment => {
|
||||
return await this.logisticsService.updateFreightwavesShipmentState(shipment);
|
||||
|
|
|
|||
|
|
@ -140,10 +140,10 @@ interface QueryOrderResponseData {
|
|||
}
|
||||
|
||||
// 修改订单响应数据接口
|
||||
interface ModifyOrderResponseData extends CreateOrderResponseData { }
|
||||
interface ModifyOrderResponseData extends CreateOrderResponseData {}
|
||||
|
||||
// 订单退款响应数据接口
|
||||
interface RefundOrderResponseData { }
|
||||
interface RefundOrderResponseData {}
|
||||
|
||||
@Provide()
|
||||
export class FreightwavesService {
|
||||
|
|
@ -180,11 +180,11 @@ export class FreightwavesService {
|
|||
};
|
||||
|
||||
// 记录请求前的详细信息
|
||||
console.log(`Sending request to: ${this.config.apiBaseUrl}${url}`, JSON.stringify({
|
||||
console.log(`Sending request to: ${this.config.apiBaseUrl}${url}`,JSON.stringify({
|
||||
headers,
|
||||
data
|
||||
}))
|
||||
console.log('Request data:', `${this.config.apiBaseUrl}${url}`, data, headers);
|
||||
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}`,
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ export class LogisticsService {
|
|||
}
|
||||
|
||||
|
||||
//"expressFinish": 0, //是否快递创建完成(1:完成 0:未完成,需要轮询 2:失败)
|
||||
//"expressFinish": 0, //是否快递创建完成(1:完成 0:未完成,需要轮询 2:失败)
|
||||
async updateFreightwavesShipmentState(shipment: Shipment) {
|
||||
try {
|
||||
const data = await this.freightwavesService.queryOrder({ shipOrderId: shipment.order_id.toString() });
|
||||
|
|
@ -372,7 +372,7 @@ export class LogisticsService {
|
|||
// }
|
||||
// }
|
||||
|
||||
resShipmentOrder = await this.mepShipment(data, order);
|
||||
resShipmentOrder =await this.mepShipment(data,order);
|
||||
|
||||
// if (data.shipmentPlatform === 'uniuni') {
|
||||
// // 添加运单
|
||||
|
|
@ -385,7 +385,7 @@ export class LogisticsService {
|
|||
// }
|
||||
|
||||
// 记录物流信息,并将订单状态转到完成
|
||||
if (resShipmentOrder.status === 'SUCCESS' || resShipmentOrder.code === '00000200') {
|
||||
if (resShipmentOrder.status === 'SUCCESS'||resShipmentOrder.code === '00000200') {
|
||||
order.orderStatus = ErpOrderStatus.COMPLETED;
|
||||
} else {
|
||||
throw new Error('运单生成失败');
|
||||
|
|
@ -398,17 +398,11 @@ export class LogisticsService {
|
|||
const shipmentRepo = manager.getRepository(Shipment);
|
||||
const tracking_provider = data.shipmentPlatform; // todo: id未确定,后写进常数
|
||||
|
||||
let co: any;
|
||||
let unique_id: any;
|
||||
let state: any;
|
||||
let co:any;
|
||||
if (data.shipmentPlatform === 'uniuni') {
|
||||
co = resShipmentOrder.data.tno;
|
||||
unique_id = resShipmentOrder.data.uni_order_sn;
|
||||
state = resShipmentOrder.data.uni_status_code;
|
||||
} else {
|
||||
}else{
|
||||
co = resShipmentOrder.data?.shipOrderId;
|
||||
unique_id = resShipmentOrder.data?.shipOrderId;
|
||||
state = ErpOrderStatus.COMPLETED;
|
||||
}
|
||||
// 同步物流信息到woocommerce
|
||||
const site = await this.siteService.get(Number(order.siteId), true);
|
||||
|
|
@ -421,10 +415,10 @@ export class LogisticsService {
|
|||
const shipment = await shipmentRepo.save({
|
||||
tracking_provider: tracking_provider,
|
||||
tracking_id: res.data.tracking_id,
|
||||
unique_id: unique_id,
|
||||
unique_id: resShipmentOrder.data.uni_order_sn,
|
||||
stockPointId: String(data.stockPointId), // todo
|
||||
state: state,
|
||||
return_tracking_number: co,
|
||||
state: resShipmentOrder.data.uni_status_code,
|
||||
return_tracking_number: resShipmentOrder.data.tno,
|
||||
fee: data.details.shipmentFee,
|
||||
order: order
|
||||
});
|
||||
|
|
@ -433,7 +427,7 @@ export class LogisticsService {
|
|||
}
|
||||
|
||||
// 同步订单状态到woocommerce
|
||||
if (order.source_type != "shopyy") {
|
||||
if(order.source_type!="shopyy"){
|
||||
if (order.status !== OrderStatus.COMPLETED) {
|
||||
await this.wpService.updateOrder(site, order.externalOrderId, {
|
||||
status: OrderStatus.COMPLETED,
|
||||
|
|
@ -693,7 +687,7 @@ export class LogisticsService {
|
|||
|
||||
|
||||
|
||||
async mepShipment(data: ShipmentBookDTO, order: Order) {
|
||||
async mepShipment(data: ShipmentBookDTO,order:Order) {
|
||||
try {
|
||||
const stock_point = await this.stockPointModel.findOneBy({ id: data.stockPointId });
|
||||
let resShipmentOrder;
|
||||
|
|
@ -735,7 +729,7 @@ export class LogisticsService {
|
|||
// 根据TMS系统对接说明文档格式化参数
|
||||
const reqBody: any = {
|
||||
shipCompany: 'UPSYYZ7000NEW',
|
||||
partnerOrderNumber: order.siteId + '-' + order.externalOrderId,
|
||||
partnerOrderNumber: order.externalOrderId ,
|
||||
warehouseId: '25072621030107400060',
|
||||
shipper: {
|
||||
name: data.details.origin.contact_name, // 姓名
|
||||
|
|
@ -778,7 +772,7 @@ export class LogisticsService {
|
|||
weightUnit: (data.details.packaging_properties.packages[0].measurements.weight.unit === 'kg' ? 'KG' : 'LB') as 'KG' | 'LB' // 重量单位(LB,KG)
|
||||
},
|
||||
currency: 'CAD', // 币种(默认CAD)
|
||||
description: '订单编号:' + order.externalOrderId // 包裹描述(确保是字符串类型)
|
||||
description: '订单编号:'+order.externalOrderId // 包裹描述(确保是字符串类型)
|
||||
}
|
||||
],
|
||||
signService: 0
|
||||
|
|
|
|||
Loading…
Reference in New Issue