收盘改回双倍费用,黑名单客户直接通知客户端不可下单

This commit is contained in:
吴方海
2025-04-21 11:06:59 +08:00
parent f2466bc7b7
commit 94ab27d5e6
2 changed files with 22 additions and 5 deletions
@@ -1,6 +1,10 @@
using BaseOUDAL;
using Microsoft.Extensions.DependencyInjection;
using Org.BouncyCastle.Crypto.Tls;
using Qdp.Foundation.Utilities;
using System.Data;
using YieldChain.Commons;
using YLErp.Abstract;
using YLErp.Commons;
using YLErp.Model;
using YLErp.Models.Tag;
@@ -14,9 +18,10 @@ namespace YLErp.Modules.ClientModule
/// </summary>
public class ClientBlackService : ClientBaseService
{
private IKafkaProduce _kafkaProduce;
public ClientBlackService(OptUserInfo userInfo) : base(userInfo)
{
_kafkaProduce = YLServiceLocator.ServiceProvider.GetService<IKafkaProduce>();
}
/// <summary>
@@ -188,6 +193,8 @@ namespace YLErp.Modules.ClientModule
throw new ServiceException(msg);
}
}
// 在外部定义列表来保存需要通知的客户对
var clientsToNotify = new List<(Client oldClient, Client newClient)>();
foreach (var item in list)
{
if (string.IsNullOrWhiteSpace(item.Name))
@@ -205,6 +212,7 @@ namespace YLErp.Modules.ClientModule
var dt = DateTime.Now;
if (clientexistence.ProcessStatus == "已开户")
{
var oldClient= clientexistence.Clone();
clientexistence.ProcessOrderId = -4;
clientexistence.ProcessStatus = "已休眠";
clientexistence.OptId = UserId;
@@ -221,6 +229,11 @@ namespace YLErp.Modules.ClientModule
OptName = UserName,
OptDate = dt
});
// 如果原有状态是已开户,添加到通知列表
if (oldClient != null)
{
clientsToNotify.Add((oldClient, clientexistence));
}
}
///日志记录
DbContext.ClientAuditLog.Add(new ClientAuditLog
@@ -242,7 +255,11 @@ namespace YLErp.Modules.ClientModule
}
DbContext.client_black.AddRange(list);
DbContext.SaveChanges();
// 发送Kafka消息
foreach (var (oldClient, newClient) in clientsToNotify)
{
new ClientKafkaService(_kafkaProduce).Send(newClient, oldClient);
}
var importHasTagClientNames = list.Where(p => p.Tags != null && p.Tags.Count > 0).Select(p => p.Name).Distinct().ToList();
if (importHasTagClientNames != null && importHasTagClientNames.Count > 0)
{