From f9d24203c6afd455778be22c566729a82f009d98 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:08:57 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=8C=E6=83=85?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E5=AD=97=E6=AE=B5=E6=BA=A2=E5=87=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=EF=BC=9A=E4=BB=B7=E6=A0=BC=E4=BF=9D=E7=95=998?= =?UTF-8?q?=E4=BD=8D=E5=B0=8F=E6=95=B0=EF=BC=8C=E5=AD=97=E6=AE=B5=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E6=89=A9=E5=B1=95=E4=B8=BA20=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Data/MarketPriceCache.cs | 4 ++-- AssetManager.Infrastructure/Services/MarketDataService.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AssetManager.Data/MarketPriceCache.cs b/AssetManager.Data/MarketPriceCache.cs index a264d99..4fd676d 100644 --- a/AssetManager.Data/MarketPriceCache.cs +++ b/AssetManager.Data/MarketPriceCache.cs @@ -29,13 +29,13 @@ public class MarketPriceCache /// /// 最新价格 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)] public decimal Price { get; set; } /// /// 前收盘价(计算当日涨跌幅用) /// - [SugarColumn(DecimalDigits = 8, IsNullable = true)] + [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)] public decimal? PreviousClose { get; set; } /// diff --git a/AssetManager.Infrastructure/Services/MarketDataService.cs b/AssetManager.Infrastructure/Services/MarketDataService.cs index 88c76f0..78d0c12 100644 --- a/AssetManager.Infrastructure/Services/MarketDataService.cs +++ b/AssetManager.Infrastructure/Services/MarketDataService.cs @@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService source = "Tiingo"; } - // 写入缓存 + // 写入缓存,保留8位小数,避免字段超出范围 var cacheEntity = new MarketPriceCache { Id = cacheKey, Symbol = symbol.ToUpper(), AssetType = assetType.ToUpper(), - Price = response.Price, - PreviousClose = response.PreviousClose, + Price = Math.Round(response.Price, 8), + PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose, 8) : null, Source = source, FetchedAt = DateTime.Now, ExpiredAt = GetCacheExpirationTime(assetType) From a62d892b4ba0854c3c6b1d5f99a49dd8b86cf3b0 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:11:55 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=B7=E6=A0=BC?= =?UTF-8?q?=E8=8C=83=E5=9B=B4=E9=99=90=E5=88=B6=EF=BC=8C=E7=A1=AE=E4=BF=9D?= =?UTF-8?q?=E4=B8=8D=E8=B6=85=E8=BF=87decimal(20,8)=E6=9C=80=E5=A4=A7?= =?UTF-8?q?=E8=8C=83=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)