refactor(logistics): 移除已注释的订单完成处理逻辑
This commit is contained in:
parent
ac17f9f224
commit
fe5d4bf2f0
|
|
@ -377,68 +377,68 @@ export class LogisticsService {
|
||||||
// resShipmentOrder = await this.uniExpressService.createShipment(reqBody);
|
// resShipmentOrder = await this.uniExpressService.createShipment(reqBody);
|
||||||
|
|
||||||
// // 记录物流信息,并将订单状态转到完成
|
// // 记录物流信息,并将订单状态转到完成
|
||||||
if (resShipmentOrder.status === 'SUCCESS') {
|
// if (resShipmentOrder.status === 'SUCCESS') {
|
||||||
order.orderStatus = ErpOrderStatus.COMPLETED;
|
// order.orderStatus = ErpOrderStatus.COMPLETED;
|
||||||
} else {
|
// } else {
|
||||||
throw new Error('运单生成失败');
|
// throw new Error('运单生成失败');
|
||||||
}
|
// }
|
||||||
const dataSource = this.dataSourceManager.getDataSource('default');
|
// const dataSource = this.dataSourceManager.getDataSource('default');
|
||||||
let transactionError = undefined;
|
// let transactionError = undefined;
|
||||||
let shipmentId = undefined;
|
// let shipmentId = undefined;
|
||||||
await dataSource.transaction(async manager => {
|
// await dataSource.transaction(async manager => {
|
||||||
const orderRepo = manager.getRepository(Order);
|
// const orderRepo = manager.getRepository(Order);
|
||||||
const shipmentRepo = manager.getRepository(Shipment);
|
// const shipmentRepo = manager.getRepository(Shipment);
|
||||||
const tracking_provider = 'UniUni'; // todo: id未确定,后写进常数
|
// const tracking_provider = 'UniUni'; // todo: id未确定,后写进常数
|
||||||
|
|
||||||
// 同步物流信息到woocommerce
|
// // 同步物流信息到woocommerce
|
||||||
const site = await this.siteService.get(Number(order.siteId), true);
|
// const site = await this.siteService.get(Number(order.siteId), true);
|
||||||
const res = await this.wpService.createShipment(site, order.externalOrderId, {
|
// const res = await this.wpService.createShipment(site, order.externalOrderId, {
|
||||||
tracking_number: resShipmentOrder.data.tno,
|
// tracking_number: resShipmentOrder.data.tno,
|
||||||
tracking_provider: tracking_provider,
|
// tracking_provider: tracking_provider,
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (order.orderStatus === ErpOrderStatus.COMPLETED) {
|
// if (order.orderStatus === ErpOrderStatus.COMPLETED) {
|
||||||
const shipment = await shipmentRepo.save({
|
// const shipment = await shipmentRepo.save({
|
||||||
tracking_provider: tracking_provider,
|
// tracking_provider: tracking_provider,
|
||||||
tracking_id: res.data.tracking_id,
|
// tracking_id: res.data.tracking_id,
|
||||||
unique_id: resShipmentOrder.data.uni_order_sn,
|
// unique_id: resShipmentOrder.data.uni_order_sn,
|
||||||
stockPointId: String(data.stockPointId), // todo
|
// stockPointId: String(data.stockPointId), // todo
|
||||||
state: resShipmentOrder.data.uni_status_code,
|
// state: resShipmentOrder.data.uni_status_code,
|
||||||
return_tracking_number: resShipmentOrder.data.tno,
|
// return_tracking_number: resShipmentOrder.data.tno,
|
||||||
fee: data.details.shipmentFee,
|
// fee: data.details.shipmentFee,
|
||||||
order: order
|
// order: order
|
||||||
});
|
// });
|
||||||
order.shipmentId = shipment.id;
|
// order.shipmentId = shipment.id;
|
||||||
shipmentId = shipment.id;
|
// shipmentId = shipment.id;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 同步订单状态到woocommerce
|
// // 同步订单状态到woocommerce
|
||||||
if (order.status !== OrderStatus.COMPLETED) {
|
// if (order.status !== OrderStatus.COMPLETED) {
|
||||||
await this.wpService.updateOrder(site, order.externalOrderId, {
|
// await this.wpService.updateOrder(site, order.externalOrderId, {
|
||||||
status: OrderStatus.COMPLETED,
|
// status: OrderStatus.COMPLETED,
|
||||||
});
|
// });
|
||||||
order.status = OrderStatus.COMPLETED;
|
// order.status = OrderStatus.COMPLETED;
|
||||||
}
|
// }
|
||||||
order.orderStatus = ErpOrderStatus.COMPLETED;
|
// order.orderStatus = ErpOrderStatus.COMPLETED;
|
||||||
|
|
||||||
await orderRepo.save(order);
|
// await orderRepo.save(order);
|
||||||
}).catch(error => {
|
// }).catch(error => {
|
||||||
transactionError = error
|
// transactionError = error
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (transactionError !== undefined) {
|
// if (transactionError !== undefined) {
|
||||||
console.log('err', transactionError);
|
// console.log('err', transactionError);
|
||||||
throw transactionError;
|
// throw transactionError;
|
||||||
}
|
// }
|
||||||
|
|
||||||
// 更新产品发货信息
|
// // 更新产品发货信息
|
||||||
this.orderService.updateOrderSales(order.id, sales);
|
// this.orderService.updateOrderSales(order.id, sales);
|
||||||
|
|
||||||
return {
|
// return {
|
||||||
data: {
|
// data: {
|
||||||
shipmentId
|
// shipmentId
|
||||||
}
|
// }
|
||||||
};
|
// };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (resShipmentOrder.status === 'SUCCESS') {
|
if (resShipmentOrder.status === 'SUCCESS') {
|
||||||
await this.uniExpressService.deleteShipment(resShipmentOrder.data.tno);
|
await this.uniExpressService.deleteShipment(resShipmentOrder.data.tno);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue