53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using YLErp.Abstract;
|
|
using YLErp.Helpers;
|
|
using YLErp.Model;
|
|
|
|
namespace YLErp.Modules.ClientModule
|
|
{
|
|
/// <summary>
|
|
/// 客户信息kafka服务
|
|
/// </summary>
|
|
public class ClientKafkaService
|
|
{
|
|
private IKafkaProduce kafkaProduceHelper;
|
|
private string topic = string.Empty;
|
|
public ClientKafkaService(IKafkaProduce kafkaProduce)
|
|
{
|
|
kafkaProduceHelper = kafkaProduce;
|
|
topic= Environment.GetEnvironmentVariable("KafkaConfig_YiLian_ClientInfoChangeTopic");
|
|
}
|
|
public ClientKafkaService() {
|
|
kafkaProduceHelper= new KafkaProduceHelper();
|
|
topic = Environment.GetEnvironmentVariable("KafkaConfig_YiLian_ClientInfoChangeTopic");
|
|
}
|
|
public void Send(Client client,Client oldClient)
|
|
{
|
|
ClientChangeKafkaRequest clientChangeKafkaRequest = new ClientChangeKafkaRequest();
|
|
clientChangeKafkaRequest.ClientId = client.id;
|
|
clientChangeKafkaRequest.ClientName = client.Name;
|
|
clientChangeKafkaRequest.Status = client.ProcessStatus;
|
|
clientChangeKafkaRequest.ClientRight = client.ClientRight;
|
|
clientChangeKafkaRequest.BusinessUseType = client.BusinessUseType;
|
|
clientChangeKafkaRequest.CustomerManagerId = client.CustomerManagerId;
|
|
if (client.ProcessStatus == "已销户"
|
|
|| client.ProcessStatus == "已休眠"
|
|
|| client.ClientRight!= oldClient?.ClientRight
|
|
|| client.BusinessUseType!= oldClient?.BusinessUseType
|
|
)
|
|
{
|
|
clientChangeKafkaRequest.ForceLoginOut = true;
|
|
}
|
|
if (!string.IsNullOrEmpty(topic))
|
|
{
|
|
kafkaProduceHelper.Produce(topic, JsonHelper.Serialize(clientChangeKafkaRequest));
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|