diff --git a/src/Starward/Pages/SelfQueryPage.xaml.cs b/src/Starward/Pages/SelfQueryPage.xaml.cs index f091778d7..59218ebe7 100644 --- a/src/Starward/Pages/SelfQueryPage.xaml.cs +++ b/src/Starward/Pages/SelfQueryPage.xaml.cs @@ -563,9 +563,17 @@ private void LoadMonthQueryItems(int type, string month) } if (gameBiz.ToGame() is GameBiz.ZZZ) { - ZZZQueryItemList = dapper.Query(""" + var list = ZZZQueryItemList = dapper.Query(""" SELECT * FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND DateTime LIKE @month ORDER BY DateTime DESC; """, new { uid, type, month = month + "%" }).ToList(); + if (type is (int)ZZZQueryType.PurchaseGift) + { + foreach (var item in list) + { + item.Reason = item.ItemName; + } + } + ZZZQueryItemList = list; MonthAddNum = ZZZQueryItemList.Where(x => x.AddNum > 0).Sum(x => x.AddNum); MonthSubNum = ZZZQueryItemList.Where(x => x.AddNum < 0).Sum(x => x.AddNum); } diff --git a/src/Starward/Services/SelfQueryService.cs b/src/Starward/Services/SelfQueryService.cs index 80b1460e5..a1971b9d5 100644 --- a/src/Starward/Services/SelfQueryService.cs +++ b/src/Starward/Services/SelfQueryService.cs @@ -280,12 +280,22 @@ public List GetZZZUids() public (long Add, long Sub) GetZZZQueryItemsNumSum(long uid, ZZZQueryType type) { using var dapper = _databaseService.CreateConnection(); - long add = dapper.QueryFirstOrDefault(""" - SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum>0; - """, new { uid, type }); - long sub = dapper.QueryFirstOrDefault(""" - SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum<0; - """, new { uid, type }); + long add = 0, sub = 0; + if (type is ZZZQueryType.PurchaseGift) + { + add = dapper.QueryFirstOrDefault(""" + SELECT COUNT(*) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type; + """, new { uid, type }); + } + else + { + add = dapper.QueryFirstOrDefault(""" + SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum>0; + """, new { uid, type }); + sub = dapper.QueryFirstOrDefault(""" + SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum<0; + """, new { uid, type }); + } return (add, sub); }