qinchaoyue 1 month ago
parent
commit
52a4247784

+ 5 - 1
src/Hotline.Share/Tools/ListExtensions.cs

@@ -53,7 +53,11 @@ public static class ListExtensions
             }
             else if (property.PropertyType == typeof(double?))
             {
-                property.SetValue(sumLine, list.Sum(m => (double)property.GetValue(m)));
+                property.SetValue(sumLine, list.Sum(m => (double?)property.GetValue(m)));
+            }
+            else if (property.PropertyType == typeof(double))
+            {
+                property.SetValue(sumLine, list.Sum(m => (double?)property.GetValue(m)));
             }
         }
         list.Add(sumLine);

+ 9 - 3
test/Hotline.Tests/Application/BiSnapshotApplicationTest.cs

@@ -69,9 +69,15 @@ public class BiSnapshotApplicationTest : TestBase
         {
             StartTime = DateTime.Now.AddDays(-30),
             EndTime = DateTime.Now,
-            //IndustryId = "08dd5bc7-6d22-478c-8955-aea3b6d59df6"
         };
-        var items = await _biSnapshotApplication.GetCountyRedPackStatistics(inDto).ToListAsync();
-        items.Count.ShouldNotBe(0);
+        var items = await _biSnapshotApplication.GetCountyRedPackStatistics(inDto);
+
+        var transposedItems = items.SelectMany(item => item.GetType().GetProperties()
+            .Select(prop => new { Property = prop.Name, Value = prop.GetValue(item) }))
+            .GroupBy(x => x.Property)
+            .ToDictionary(g => g.Key, g => g.Select(x => x.Value).ToList());
+
+        transposedItems.ShouldNotBeNull();
+        transposedItems.Count.ShouldNotBe(0);
     }
 }