From e8424afd91c304acf56aedf6da1b567e8d0570f9 Mon Sep 17 00:00:00 2001 From: zhuotianyuan Date: Fri, 23 Jan 2026 17:02:10 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=AE=A2=E5=8D=95=E6=9C=8D=E5=8A=A1):?= =?UTF-8?q?=20=E6=9B=BF=E6=8D=A2console.log=E4=B8=BAlogger=E5=B9=B6?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E9=87=8D=E5=A4=8D=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 移除重复的console.log调用,统一使用logger进行日志记录 清理调试日志并优化日志级别使用 --- src/service/order.service.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/service/order.service.ts b/src/service/order.service.ts index 41e15b3..321221c 100644 --- a/src/service/order.service.ts +++ b/src/service/order.service.ts @@ -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(); @@ -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}`); } }