数据库 User表增加 商铺续费最低抽佣
OEM结算 店铺续费根据最低抽佣计算默认15
This commit is contained in:
1 parent
28a90b135c
commit
6e4f44bbe6
6 files changed
+59
-22
No files matched your search
@@ -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)
|
||||
{
|
||||
|
||||
@@ -108,6 +108,10 @@ namespace KJD_Web.Model
|
||||
/// </summary>
|
||||
public decimal? gift_oem_amount_per_order { get; set; }
|
||||
public decimal? sync_logistics_per_order { get; set; }
|
||||
/// <summary>
|
||||
/// 店铺续租平台保底金额 有OEM 平台默认抽成15
|
||||
/// </summary>
|
||||
public decimal? shop_renewal_platform_floor_fee { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
/// <param name="userName"></param>
|
||||
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
|
||||
/// <param name="orm">当前事务ORM</param>
|
||||
/// <param name="userNames">需要结算的用户</param>
|
||||
/// <param name="oemAddTime">
|
||||
private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection<string> userNames, DateTime? oemAddTime)
|
||||
private long SettleFlowsInternal(IFreeSql tr_freeSql, ICollection<UserEntity> users, DateTime? oemAddTime)
|
||||
{
|
||||
if (userNames == null || userNames.Count == 0) { throw new Exception("没有用户"); }
|
||||
if (users == null || users.Count == 0) { throw new Exception("没有用户"); }
|
||||
|
||||
IEnumerable<string> 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<long> ids = userPoints.Select(a => a.Id).ToList();
|
||||
var feeMap = users
|
||||
.GroupBy(a => a.UserName)
|
||||
.ToDictionary(g => g.Key, g => g.First().ShopRenewalPlatformFloorFee);
|
||||
|
||||
List<long> 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; // 允许出现负数
|
||||
});//累计返利
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace KJD_Web.Services.Users
|
||||
/// <summary>
|
||||
/// 商铺续费每月30
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +160,13 @@ namespace Store.Contracts.User.Entitys
|
||||
[Column(Name = "sync_logistics_per_order")]
|
||||
public decimal? SyncLogisticsPerOrder { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 店铺续租平台保底金额 默认15
|
||||
/// </summary>
|
||||
[Column(Name = "shop_renewal_platform_floor_fee")]
|
||||
public decimal ShopRenewalPlatformFloorFee { get; set; } = 15;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 是否主账户
|
||||
/// </summary>
|
||||
|
||||
@@ -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<ShopService>();
|
||||
var shopIds =shopService.GetShopIds("15937791563");
|
||||
@@ -142,6 +146,10 @@ internal class ShopTest
|
||||
var shopStatsService = _container.Resolve<ShopRevenueStatisticsService>();
|
||||
DateTime date = DateTime.Parse("2026/10/17");
|
||||
|
||||
if (!string.IsNullOrEmpty(dateString))
|
||||
{
|
||||
date = DateTime.Parse(dateString);
|
||||
}
|
||||
Console.WriteLine($"开始:{date.ToLongDateString()}");
|
||||
try
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user