From ce574ac42ff660ec8c0a10cf000c4743b113c0cc Mon Sep 17 00:00:00 2001 From: LyMysterious Date: Thu, 29 May 2025 22:50:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=89=8B=E7=BB=AD=E8=B4=B9=E8=AE=A1?= =?UTF-8?q?=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RoBot.Core/Utils.cs | 24 +++++++++++++++++++ XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs | 13 +++++++--- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/RoBot.Core/Utils.cs b/RoBot.Core/Utils.cs index 92148ab..bab69d5 100644 --- a/RoBot.Core/Utils.cs +++ b/RoBot.Core/Utils.cs @@ -37,6 +37,30 @@ return value * multiplier; } + /// + /// 计算手续费 + /// + /// + /// + public static decimal CalculateFee(decimal amount) + { + decimal rate = 0; + + if (amount < 500_0000) // 0 ~ 499w + rate = 0.05m; // 5% + else if (amount < 1000_0000) // 500 ~ 999w + rate = 0.10m; // 10% + else if (amount < 1500_0000) // 1000 ~ 1499w + rate = 0.15m; // 15% + else if (amount < 2000_0000) // 1500 ~ 1999w + rate = 0.20m; // 20% + else // 2000w以上 + rate = 0.30m; // 30% + + return amount * rate; + } + + } } diff --git a/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs b/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs index 916277d..6397107 100644 --- a/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs +++ b/XiaoXiaoRoBot/Cmd/QueryGoodsUpShopPriceCmd.cs @@ -84,22 +84,29 @@ namespace RoBot.Start.Cmd string msg = ""; decimal totalPrice = 0; + decimal fee = 0; // 打印结果 foreach (var item in results) { var current = RedisHelper.Client.HGet(RedisPrefix.GoodsKey, item.Name); if (current is not null) { + int num = item.Num.Value > 10 ? 10 : item.Num.Value; decimal nicePrice = current.Price - 100000; - totalPrice += Convert.ToDecimal(nicePrice * item.Num); - msg += $"确认坊市上架{item.Name} {(int)current.Price - 100000} {item.Num}\n"; + totalPrice += Convert.ToDecimal(nicePrice * num); + + fee += Math.Round(Utils.CalculateFee(nicePrice) * num, 0); + + msg += $"确认坊市上架{item.Name} {(int)current.Price - 100000} {num}\n"; } } if (string.IsNullOrWhiteSpace(msg) is false) { msg += "\r\n"; msg += "使用前请先@小小查看坊市药材,过完一遍以获取最新价格\r\n当前价格为坊市价格-10w\r\n"; - msg += $"总价值约:{Utils.FormatNumberToChineseUnit(totalPrice)}"; + msg += $"总价值约:{Utils.FormatNumberToChineseUnit(totalPrice)}\r\n"; + msg += $"手续费约:{Utils.FormatNumberToChineseUnit(fee)}\r\n"; + msg += $"到账约:{Utils.FormatNumberToChineseUnit(totalPrice - fee)}"; var systemConfig = GlobalConfig.ConfigSetting; var bot = GlobalConfig.BotContext; await bot.SendMsg((uint)systemConfig.GroupQQ, msg);