From a62d892b4ba0854c3c6b1d5f99a49dd8b86cf3b0 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:11:55 +0000 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=B7=E6=A0=BC=E8=8C=83?= =?UTF-8?q?=E5=9B=B4=E9=99=90=E5=88=B6=EF=BC=8C=E7=A1=AE=E4=BF=9D=E4=B8=8D?= =?UTF-8?q?=E8=B6=85=E8=BF=87decimal(20,8)=E6=9C=80=E5=A4=A7=E8=8C=83?= =?UTF-8?q?=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Infrastructure/Services/MarketDataService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssetManager.Infrastructure/Services/MarketDataService.cs b/AssetManager.Infrastructure/Services/MarketDataService.cs index 78d0c12..87102ac 100644 --- a/AssetManager.Infrastructure/Services/MarketDataService.cs +++ b/AssetManager.Infrastructure/Services/MarketDataService.cs @@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService source = "Tiingo"; } - // 写入缓存,保留8位小数,避免字段超出范围 + // 写入缓存,保留8位小数,强制转换为12位整数+8位小数,避免MySql字段溢出 var cacheEntity = new MarketPriceCache { Id = cacheKey, Symbol = symbol.ToUpper(), AssetType = assetType.ToUpper(), - Price = Math.Round(response.Price, 8), - PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose, 8) : null, + Price = Math.Round(Math.Clamp(response.Price, 0, 999999999999.99999999m), 8), + PreviousClose = response.PreviousClose > 0 ? Math.Round(Math.Clamp(response.PreviousClose.Value, 0, 999999999999.99999999m), 8) : null, Source = source, FetchedAt = DateTime.Now, ExpiredAt = GetCacheExpirationTime(assetType)