From 6e4f44bbe6627397d5d56b774406d1d4dc11cc61 Mon Sep 17 00:00:00 2001 From: chfei Date: Wed, 4 Nov 2026 17:12:17 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=20User=E8=A1=A8?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E5=95=86=E9=93=BA=E7=BB=AD=E8=B4=B9?= =?UTF-8?q?=E6=9C=80=E4=BD=8E=E6=8A=BD=E4=BD=A3=20OEM=E7=BB=93=E7=AE=97=20?= =?UTF-8?q?=E5=BA=97=E9=93=BA=E7=BB=AD=E8=B4=B9=E6=A0=B9=E6=8D=AE=E6=9C=80?= =?UTF-8?q?=E4=BD=8E=E6=8A=BD=E4=BD=A3=E8=AE=A1=E7=AE=97=E9=BB=98=E8=AE=A4?= =?UTF-8?q?15?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- KJD_WebService/BLL/WXXD/WXUserManage.cs | 17 +++++--- KJD_WebService/Model/UserLoginResultParam.cs | 4 ++ .../Services/Users/UserService.FeeRecord.cs | 39 ++++++++++++------- KJD_WebService/Services/Users/UserService.cs | 4 +- Store.Contracts/User/Entitys/UserEntity.cs | 7 ++++ test/WebServiceTest/ShopTest.cs | 10 ++++- 6 files changed, 59 insertions(+), 22 deletions(-) diff --git a/KJD_WebService/BLL/WXXD/WXUserManage.cs b/KJD_WebService/BLL/WXXD/WXUserManage.cs index 44de741..06ed3e9 100644 --- a/KJD_WebService/BLL/WXXD/WXUserManage.cs +++ b/KJD_WebService/BLL/WXXD/WXUserManage.cs @@ -193,7 +193,7 @@ namespace KJD_Web.BLL.WXXD mySql.Close(); var prodApiUrl = (System.Configuration.ConfigurationManager.ConnectionStrings["ProdApiUrl"]?.ConnectionString).ParseToString(); var orderApiUrl = (System.Configuration.ConfigurationManager.ConnectionStrings["OrderApiUrl"]?.ConnectionString).ParseToString(); - return "{\"code\":200,\"msg\":\"success\",\"prod_api_url\":\"" + prodApiUrl + "\",\"order_api_url\":\"" + orderApiUrl + + return "{\"code\":200,\"msg\":\"success\",\"prod_api_url\":\"" + prodApiUrl + "\",\"order_api_url\":\"" + orderApiUrl + "\",\"data\":" + data + ",\"c\":\"" + EncrypUtil.Encryption(r2) + "\"}"; } mySql.Close(); @@ -551,6 +551,7 @@ namespace KJD_Web.BLL.WXXD refund_postage_per_order = row.Table.Columns.Contains("refund_postage_per_order") ? row["refund_postage_per_order"].ParseToNullableDecimal() : null, gift_oem_amount_per_order = row.Table.Columns.Contains("gift_oem_amount_per_order") ? row["gift_oem_amount_per_order"].ParseToNullableDecimal() : null, sync_logistics_per_order = row.Table.Columns.Contains("sync_logistics_per_order") ? row["sync_logistics_per_order"].ParseToNullableDecimal() : null, + shop_renewal_platform_floor_fee = row.Table.Columns.Contains("shop_renewal_platform_floor_fee") ? row["shop_renewal_platform_floor_fee"].ParseToNullableDecimal() : null, }; var main_authority = row.Table.Columns.Contains("main_authority") ? row["main_authority"].ParseToString() : ""; var main_oem_id = row.Table.Columns.Contains("main_oem_id") ? row["main_oem_id"].ParseToString() : ""; @@ -771,7 +772,7 @@ namespace KJD_Web.BLL.WXXD var gift_oem_amount_per_order = RegexUtils.GetStringQuery(ref inputData, "gift_oem_amount_per_order")?.Replace("'", "\\'"); var sync_logistics_per_order = RegexUtils.GetStringQuery(ref inputData, "sync_logistics_per_order")?.Replace("'", "\\'"); var oem_id = RegexUtils.GetStringQuery(ref inputData, "oem_id")?.Replace("'", "\\'"); - + var shop_renewal_platform_floor_fee = RegexUtils.GetStringQuery(ref inputData, "shop_renewal_platform_floor_fee")?.Replace("'", "\\'"); string conn = System.Configuration.ConfigurationManager.ConnectionStrings["ConnKJD"].ConnectionString; MysqlUtils mySql = new MysqlUtils(conn); string sql = ""; @@ -801,7 +802,13 @@ namespace KJD_Web.BLL.WXXD if (forbidden_page != null) sql += " forbidden_page='" + forbidden_page + "',"; if (shop_points_per_month != null) - sql += " shop_points_per_month=" + shop_points_per_month + ","; + { + sql += " shop_points_per_month=" + Math.Max(10, shop_points_per_month.ParseToDecimal(10)) + ","; + } + if (shop_renewal_platform_floor_fee != null) + { + sql += " shop_renewal_platform_floor_fee=" + Math.Max(10, shop_renewal_platform_floor_fee.ParseToDecimal(15)) + ","; + } if (postage_per_order != null) sql += " postage_per_order=" + postage_per_order + ","; if (refund_postage_per_order != null) @@ -1101,14 +1108,14 @@ namespace KJD_Web.BLL.WXXD if (option_type == "续费") { sql = "SELECT shop_points_per_month FROM `wxxd`.`user` WHERE user_name='" + user_name + "'"; - shopPointsPerMonth = mySql.ExecuteFirstDecimal(sql); // 店铺续费一个月的点数,默认30,可以设置为其他值 + shopPointsPerMonth = mySql.ExecuteFirstDecimal(sql); // 店铺续费一个月的点数,默认30,最低10,可以设置为其他值 if (!string.IsNullOrEmpty(mySql.Message)) { mySql.RollBack(); mySql.Close(); return "{\"code\":501,\"msg\":\"" + mySql.Message + "\"}"; } - shopPointsPerMonth = Math.Max(30, shopPointsPerMonth); + shopPointsPerMonth = Math.Max(10, shopPointsPerMonth); if (delta_points <= 0 || delta_points.ParseToInt().ParseToDecimal() != delta_points || delta_points.ParseToInt() % shopPointsPerMonth.ParseToInt() > 0) { diff --git a/KJD_WebService/Model/UserLoginResultParam.cs b/KJD_WebService/Model/UserLoginResultParam.cs index 287d1f9..21de029 100644 --- a/KJD_WebService/Model/UserLoginResultParam.cs +++ b/KJD_WebService/Model/UserLoginResultParam.cs @@ -108,6 +108,10 @@ namespace KJD_Web.Model /// public decimal? gift_oem_amount_per_order { get; set; } public decimal? sync_logistics_per_order { get; set; } + /// + /// 店铺续租平台保底金额 有OEM 平台默认抽成15 + /// + public decimal? shop_renewal_platform_floor_fee { get; set; } } } \ No newline at end of file diff --git a/KJD_WebService/Services/Users/UserService.FeeRecord.cs b/KJD_WebService/Services/Users/UserService.FeeRecord.cs index c0e4e07..239b0a8 100644 --- a/KJD_WebService/Services/Users/UserService.FeeRecord.cs +++ b/KJD_WebService/Services/Users/UserService.FeeRecord.cs @@ -40,13 +40,9 @@ namespace KJD_Web.Services.Users // 获取OEM下面的所有用户 var users = GetOEMUsers(oem.OemId, true); - var userNames = users - .Select(a => a.UserName) - .Where(a => !string.IsNullOrEmpty(a)) - .Distinct() - .ToList(); + - if (userNames.Count == 0) + if (users.Count == 0) {//todo throw new Exception("没有用户"); } @@ -60,7 +56,7 @@ namespace KJD_Web.Services.Users */ long totalFen = SettleFlowsInternal( trFreeSql, - userNames, + users, oem.AddTime); long rebateFen = totalFen; @@ -99,16 +95,15 @@ namespace KJD_Web.Services.Users /// public long SettleUserFlows(string userName, DbTransaction tarn = null) { - var user = GetUserAndSubUser(userName); - if (user == null) + var users = GetUserAndSubUser(userName); + if (users == null) { throw new Exception("错误的账号"); } using var work = tarn != null ? _freeSql.CreateUnitOfWork(tarn) : _freeSql.CreateUnitOfWork(); var trFreeSql = work.Orm; - var userNames = user.Select(a => a.UserName).ToList(); /* * 普通用户没有OEM创建时间限制。 * * 所以这里传null。 */ - long totalAmount = SettleFlowsInternal(trFreeSql, userNames, null); + long totalAmount = SettleFlowsInternal(trFreeSql, users, null); /* * 普通用户没有余额, * 所以不做任何金额更新。 */ Debug.WriteLine($"用户流水结算:{totalAmount}"); work.Commit(); @@ -124,9 +119,11 @@ namespace KJD_Web.Services.Users /// 当前事务ORM /// 需要结算的用户 /// - private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection userNames, DateTime? oemAddTime) + private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection users, DateTime? oemAddTime) { - if (userNames == null || userNames.Count == 0) { throw new Exception("没有用户"); } + if (users == null || users.Count == 0) { throw new Exception("没有用户"); } + + IEnumerable userNames = users.Select(a => a.UserName); decimal total_amount = 0m; // 总金额(元) decimal rebate_amount = 0m; // 正数部分(累计返利) DateTime now = DateTime.Now; @@ -217,11 +214,23 @@ namespace KJD_Web.Services.Users .ToList(); if (userPoints.Count > 0) { - List ids = userPoints.Select(a => a.Id).ToList(); + var feeMap = users + .GroupBy(a => a.UserName) + .ToDictionary(g => g.Key, g => g.First().ShopRenewalPlatformFloorFee); + List ids = userPoints.Select(a => a.Id).ToList(); decimal userPointsAmount = userPoints.Sum(x => { - return x.DeltaPoints * 1 - ShopRenewFee; //比例1:1 减去固定收取费用 + var fee = feeMap.TryGetValue(x.UserName, out var f) ? f : (decimal?)null; + var net = x.DeltaPoints - (fee ?? ShopRenewFee); // 允许为负 + + if (net < 0m) + { + _logger.Warn( + $"续费返利出现负数:UserName={x.UserName}, DeltaPoints={x.DeltaPoints}, Fee={fee ?? ShopRenewFee}, Net={net}"); + } + + return net; // 允许出现负数 });//累计返利 diff --git a/KJD_WebService/Services/Users/UserService.cs b/KJD_WebService/Services/Users/UserService.cs index 66faa01..fc59ef9 100644 --- a/KJD_WebService/Services/Users/UserService.cs +++ b/KJD_WebService/Services/Users/UserService.cs @@ -25,7 +25,7 @@ namespace KJD_Web.Services.Users /// /// 商铺续费每月30 /// - private const int MinShopPointsPerMonth = 30; + private const int MinShopPointsPerMonth = 10; private const int UserNameMaxLength = 20; private const int ShopIdMaxLength = 50; private const int RemarkMaxLength = 255; @@ -59,10 +59,12 @@ namespace KJD_Web.Services.Users if (mainUser != null) { user.OemId = mainUser.OemId; + user.ShopPointsPerMonth = mainUser.ShopPointsPerMonth; user.PostagePerOrder = mainUser.PostagePerOrder; user.RefundPostagePerOrder = mainUser.RefundPostagePerOrder; user.GiftOemAmountPerOrder = mainUser.GiftOemAmountPerOrder; user.SyncLogisticsPerOrder = mainUser.SyncLogisticsPerOrder; + user.ShopRenewalPlatformFloorFee = mainUser.ShopRenewalPlatformFloorFee; } } } diff --git a/Store.Contracts/User/Entitys/UserEntity.cs b/Store.Contracts/User/Entitys/UserEntity.cs index 0fc08fb..576d5ac 100644 --- a/Store.Contracts/User/Entitys/UserEntity.cs +++ b/Store.Contracts/User/Entitys/UserEntity.cs @@ -160,6 +160,13 @@ namespace Store.Contracts.User.Entitys [Column(Name = "sync_logistics_per_order")] public decimal? SyncLogisticsPerOrder { get; set; } + /// + /// 店铺续租平台保底金额 默认15 + /// + [Column(Name = "shop_renewal_platform_floor_fee")] + public decimal ShopRenewalPlatformFloorFee { get; set; } = 15; + + /// /// 是否主账户 /// diff --git a/test/WebServiceTest/ShopTest.cs b/test/WebServiceTest/ShopTest.cs index d4de4a8..4876593 100644 --- a/test/WebServiceTest/ShopTest.cs +++ b/test/WebServiceTest/ShopTest.cs @@ -134,7 +134,11 @@ internal class ShopTest [Test] - public void GetShopSalesOrderTest() + [TestCase("2026/10/18")] + [TestCase("2026/10/19")] + [TestCase("2026/10/20")] + [TestCase("2026/10/21")] + public void GetShopSalesOrderTest(string dateString) { var shopService = _container.Resolve(); var shopIds =shopService.GetShopIds("15937791563"); @@ -142,6 +146,10 @@ internal class ShopTest var shopStatsService = _container.Resolve(); DateTime date = DateTime.Parse("2026/10/17"); + if (!string.IsNullOrEmpty(dateString)) + { + date = DateTime.Parse(dateString); + } Console.WriteLine($"开始:{date.ToLongDateString()}"); try {