zksu
/
API
forked from yoone/API
1
0
Fork 0

refactor(订单服务): 替换console.log为logger并移除重复日志

移除重复的console.log调用,统一使用logger进行日志记录
清理调试日志并优化日志级别使用
This commit is contained in:
zhuotianyuan 2026-01-23 17:02:10 +08:00
parent 5f16801f98
commit e8424afd91
1 changed files with 4 additions and 14 deletions

View File

@ -141,8 +141,7 @@ export class OrderService {
updated: 0, updated: 0,
errors: [] errors: []
}; };
console.log('开始进入循环同步订单', result.length, '个订单') this.logger.info('开始进入循环同步订单', result.length, '个订单')
console.log('开始进入循环同步订单', result.length, '个订单')
// 遍历每个订单进行同步 // 遍历每个订单进行同步
for (const order of result) { for (const order of result) {
try { try {
@ -151,7 +150,7 @@ export class OrderService {
where: { externalOrderId: String(order.id), siteId: siteId }, where: { externalOrderId: String(order.id), siteId: siteId },
}); });
if (!existingOrder) { if (!existingOrder) {
console.log("数据库中不存在", order.id, '订单状态:', order.status) this.logger.debug("数据库中不存在", order.id, '订单状态:', order.status)
} }
// 同步单个订单 // 同步单个订单
await this.syncSingleOrder(siteId, order); await this.syncSingleOrder(siteId, order);
@ -176,9 +175,7 @@ export class OrderService {
syncResult.processed++; syncResult.processed++;
} }
} }
console.log('同步完成', syncResult.updated, 'created:', syncResult.created) this.logger.info('同步完成', syncResult.updated, 'created:', syncResult.created)
this.logger.debug('syncOrders result', syncResult)
return syncResult; return syncResult;
} }
@ -216,7 +213,7 @@ export class OrderService {
where: { externalOrderId: String(order.id), siteId: siteId }, where: { externalOrderId: String(order.id), siteId: siteId },
}); });
if (!existingOrder) { if (!existingOrder) {
console.log("数据库不存在", siteId, "订单:", order.id, '订单状态:' + order.status) this.logger.debug("数据库不存在", siteId, "订单:", order.id, '订单状态:' + order.status)
} }
// 同步单个订单 // 同步单个订单
await this.syncSingleOrder(siteId, order, true); await this.syncSingleOrder(siteId, order, true);
@ -770,7 +767,6 @@ export class OrderService {
}); });
return orderSale return orderSale
}).filter(v => v !== null) }).filter(v => v !== null)
console.log("orderSales", orderSales)
if (orderSales.length > 0) { if (orderSales.length > 0) {
await this.orderSaleModel.save(orderSales); await this.orderSaleModel.save(orderSales);
} }
@ -1562,7 +1558,6 @@ export class OrderService {
GROUP BY os.productId GROUP BY os.productId
`; `;
console.log('------3.5-----', pcSql, pcParams, exceptPackage);
const pcResults = await this.orderSaleModel.query(pcSql, pcParams); const pcResults = await this.orderSaleModel.query(pcSql, pcParams);
const pcMap = new Map<number, any>(); const pcMap = new Map<number, any>();
@ -2641,13 +2636,9 @@ export class OrderService {
if (!fs.existsSync(downloadsDir)) { if (!fs.existsSync(downloadsDir)) {
fs.mkdirSync(downloadsDir, { recursive: true }); fs.mkdirSync(downloadsDir, { recursive: true });
} }
const filePath = path.join(downloadsDir, fileName); const filePath = path.join(downloadsDir, fileName);
// 写入文件 // 写入文件
fs.writeFileSync(filePath, csvContent, 'utf8'); fs.writeFileSync(filePath, csvContent, 'utf8');
console.log(`数据已成功导出至 ${filePath}`);
return filePath; return filePath;
} }
@ -2658,7 +2649,6 @@ export class OrderService {
return csvContent; return csvContent;
} catch (error) { } catch (error) {
console.error('导出CSV时出错:', error);
throw new Error(`导出CSV文件失败: ${error.message}`); throw new Error(`导出CSV文件失败: ${error.message}`);
} }
} }