refactor(订单服务): 替换console.log为logger并移除重复日志
移除重复的console.log调用,统一使用logger进行日志记录 清理调试日志并优化日志级别使用
This commit is contained in:
parent
5f16801f98
commit
e8424afd91
|
|
@ -141,8 +141,7 @@ export class OrderService {
|
|||
updated: 0,
|
||||
errors: []
|
||||
};
|
||||
console.log('开始进入循环同步订单', result.length, '个订单')
|
||||
console.log('开始进入循环同步订单', result.length, '个订单')
|
||||
this.logger.info('开始进入循环同步订单', result.length, '个订单')
|
||||
// 遍历每个订单进行同步
|
||||
for (const order of result) {
|
||||
try {
|
||||
|
|
@ -151,7 +150,7 @@ export class OrderService {
|
|||
where: { externalOrderId: String(order.id), siteId: siteId },
|
||||
});
|
||||
if (!existingOrder) {
|
||||
console.log("数据库中不存在", order.id, '订单状态:', order.status)
|
||||
this.logger.debug("数据库中不存在", order.id, '订单状态:', order.status)
|
||||
}
|
||||
// 同步单个订单
|
||||
await this.syncSingleOrder(siteId, order);
|
||||
|
|
@ -176,9 +175,7 @@ export class OrderService {
|
|||
syncResult.processed++;
|
||||
}
|
||||
}
|
||||
console.log('同步完成', syncResult.updated, 'created:', syncResult.created)
|
||||
|
||||
this.logger.debug('syncOrders result', syncResult)
|
||||
this.logger.info('同步完成', syncResult.updated, 'created:', syncResult.created)
|
||||
return syncResult;
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +213,7 @@ export class OrderService {
|
|||
where: { externalOrderId: String(order.id), siteId: siteId },
|
||||
});
|
||||
if (!existingOrder) {
|
||||
console.log("数据库不存在", siteId, "订单:", order.id, '订单状态:' + order.status)
|
||||
this.logger.debug("数据库不存在", siteId, "订单:", order.id, '订单状态:' + order.status)
|
||||
}
|
||||
// 同步单个订单
|
||||
await this.syncSingleOrder(siteId, order, true);
|
||||
|
|
@ -770,7 +767,6 @@ export class OrderService {
|
|||
});
|
||||
return orderSale
|
||||
}).filter(v => v !== null)
|
||||
console.log("orderSales", orderSales)
|
||||
if (orderSales.length > 0) {
|
||||
await this.orderSaleModel.save(orderSales);
|
||||
}
|
||||
|
|
@ -1562,7 +1558,6 @@ export class OrderService {
|
|||
GROUP BY os.productId
|
||||
`;
|
||||
|
||||
console.log('------3.5-----', pcSql, pcParams, exceptPackage);
|
||||
const pcResults = await this.orderSaleModel.query(pcSql, pcParams);
|
||||
|
||||
const pcMap = new Map<number, any>();
|
||||
|
|
@ -2641,13 +2636,9 @@ export class OrderService {
|
|||
if (!fs.existsSync(downloadsDir)) {
|
||||
fs.mkdirSync(downloadsDir, { recursive: true });
|
||||
}
|
||||
|
||||
const filePath = path.join(downloadsDir, fileName);
|
||||
|
||||
// 写入文件
|
||||
fs.writeFileSync(filePath, csvContent, 'utf8');
|
||||
|
||||
console.log(`数据已成功导出至 ${filePath}`);
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
|
@ -2658,7 +2649,6 @@ export class OrderService {
|
|||
|
||||
return csvContent;
|
||||
} catch (error) {
|
||||
console.error('导出CSV时出错:', error);
|
||||
throw new Error(`导出CSV文件失败: ${error.message}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue