Skip to content

Commit

Permalink
fix the bug where ZZZ self query doesn't show correct name of purchas…
Browse files Browse the repository at this point in the history
…e gift
  • Loading branch information
Scighost committed Aug 26, 2024
1 parent 29ef207 commit 4fdf5c3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/Starward/Pages/SelfQueryPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -563,9 +563,17 @@ private void LoadMonthQueryItems(int type, string month)
}
if (gameBiz.ToGame() is GameBiz.ZZZ)
{
ZZZQueryItemList = dapper.Query<ZZZQueryItem>("""
var list = ZZZQueryItemList = dapper.Query<ZZZQueryItem>("""
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);
}
Expand Down
22 changes: 16 additions & 6 deletions src/Starward/Services/SelfQueryService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,22 @@ public List<long> GetZZZUids()
public (long Add, long Sub) GetZZZQueryItemsNumSum(long uid, ZZZQueryType type)
{
using var dapper = _databaseService.CreateConnection();
long add = dapper.QueryFirstOrDefault<long>("""
SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum>0;
""", new { uid, type });
long sub = dapper.QueryFirstOrDefault<long>("""
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<long>("""
SELECT COUNT(*) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type;
""", new { uid, type });
}
else
{
add = dapper.QueryFirstOrDefault<long>("""
SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum>0;
""", new { uid, type });
sub = dapper.QueryFirstOrDefault<long>("""
SELECT IFNULL(SUM(AddNum), 0) FROM ZZZQueryItem WHERE Uid=@uid AND Type=@type AND AddNum<0;
""", new { uid, type });
}
return (add, sub);
}

Expand Down

0 comments on commit 4fdf5c3

Please sign in to comment.