From ea609525f298ea8d32d7fe5919f42877a7599cb8 Mon Sep 17 00:00:00 2001 From: hjhan Date: Mon, 26 Jan 2026 17:35:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(SwapModule):=20=E6=B7=BB=E5=8A=A0=E9=98=B6?= =?UTF-8?q?=E6=A2=AF=E8=B4=B9=E7=8E=87=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=E7=9A=84=E8=AF=A6=E7=BB=86=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在解析线下费率前记录原始值和空值检查结果 - 记录百分比格式识别和转换过程中的详细信息 - 添加解析成功和失败情况的日志输出 - 记录直接解析小数格式的处理过程 - 添加最终设置OfflineRate值的日志记录 - 完善空值情况下的日志输出 --- .../Modules/SwapModule/SwapRateService.cs | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/YLErpDAL/Modules/SwapModule/SwapRateService.cs b/YLErpDAL/Modules/SwapModule/SwapRateService.cs index 518644e6..e016f5ed 100644 --- a/YLErpDAL/Modules/SwapModule/SwapRateService.cs +++ b/YLErpDAL/Modules/SwapModule/SwapRateService.cs @@ -310,28 +310,48 @@ namespace YLErp.Modules.SwapModule // 处理线下费率 var offlineRate = reader.GetString("线下费率"); + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,原始线下费率值: '{offlineRate}', IsNullOrEmpty: {string.IsNullOrEmpty(offlineRate)}"); + if (!string.IsNullOrEmpty(offlineRate)) { + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,线下费率非空,准备解析: '{offlineRate}'"); decimal rate = 0; if (offlineRate.EndsWith("%")) { + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,线下费率是百分比格式: '{offlineRate}'"); offlineRate = offlineRate.Replace("%", ""); if (decimal.TryParse(offlineRate, out rate)) { rate /= 100; + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,百分比解析成功: {offlineRate}% -> {rate}"); + } + else + { + LogFactory.GetLogger("导入阶梯费率").Error($"第{rowIndex}行,百分比数值解析失败: '{offlineRate}'"); + rate = 0; } } else { + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,线下费率不是百分比格式: '{offlineRate}', 尝试直接解析"); // 如果不是百分比格式,直接尝试解析为小数 if (!decimal.TryParse(offlineRate, out rate)) { // 解析失败时的处理 - LogFactory.GetLogger("导入阶梯费率").Error($"第{rowIndex}行,线下费率解析失败:{offlineRate}"); + LogFactory.GetLogger("导入阶梯费率").Error($"第{rowIndex}行,线下费率解析失败: '{offlineRate}'"); rate = 0; } + else + { + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,直接解析成功: {offlineRate} -> {rate}"); + } } swapRate.OfflineRate = rate; + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,最终设置OfflineRate为: {rate}"); + } + else + { + LogFactory.GetLogger("导入阶梯费率").Info($"第{rowIndex}行,线下费率为null或空字符串"); } ValidateSwapRate(swapRate);