From db0147994ef4899702ac864ac0794a79fe980416 Mon Sep 17 00:00:00 2001 From: username@email.com <yzy2002yzy@163.com> Date: 星期四, 02 二月 2023 11:12:03 +0800 Subject: [PATCH] 分配客户聊天的业务经理 --- zhengcaioa/Model/CustomerYwjl.cs | 15 +++ zhengcaioa/Services/CooperatecustomCustomerService.cs | 5 zhengcaioa/zhengcaioa/Controllers/UserController.cs | 146 +++++++++++++++++++++++++++++ zhengcaioa/IServices/IUserService.cs | 7 + zhengcaioa/DTO/PltUserDTO.cs | 1 zhengcaioa/Model/zhengcaioaContext.cs | 23 ++++ zhengcaioa/Model/PltUser.cs | 1 zhengcaioa/zhengcaioa/appsettings.Development.json | 2 zhengcaioa/IServices/IIntentionCustomerService.cs | 2 zhengcaioa/Services/IntentionCustomerService.cs | 20 +++ zhengcaioa/Services/UserService.cs | 61 ++++++++++++ zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs | 10 + zhengcaioa/Crawler/Program.cs | 2 13 files changed, 286 insertions(+), 9 deletions(-) diff --git a/zhengcaioa/Crawler/Program.cs b/zhengcaioa/Crawler/Program.cs index a492aaa..2d4b5d6 100644 --- a/zhengcaioa/Crawler/Program.cs +++ b/zhengcaioa/Crawler/Program.cs @@ -20,7 +20,7 @@ //public static string connection = @"server=.;database=WebCrawler;uid=sa;pwd=123456;"; //public static string connection1 = @"server=.;database=zhengcaioa;uid=sa;pwd=123456;"; - //public static string api_domain = "http://192.168.0.4:9200"; + //public static string api_domain = "http://192.168.0.15:9200"; public static string connection = @"server=172.26.97.184;database=WebCrawler;uid=sa;pwd=Za20222812;"; public static string connection1 = @"server=172.26.97.184;database=zhengcaioa;uid=sa;pwd=Za20222812;"; diff --git a/zhengcaioa/DTO/PltUserDTO.cs b/zhengcaioa/DTO/PltUserDTO.cs index 8d70e03..603eda0 100644 --- a/zhengcaioa/DTO/PltUserDTO.cs +++ b/zhengcaioa/DTO/PltUserDTO.cs @@ -67,6 +67,7 @@ public DateTime? ShiyongDateEnd { get; set; } public DateTime? HetongDateEnd { get; set; } public string HetongDateEndName { get; set; } + public DateTime? FenpeiDate { get; set; } public string ShiyongDateEndName { get; set; } public decimal? ShiyongPrice { get; set; } public string ShiyongPriceName { get; set; } diff --git a/zhengcaioa/IServices/IIntentionCustomerService.cs b/zhengcaioa/IServices/IIntentionCustomerService.cs index ff1959d..d9787b4 100644 --- a/zhengcaioa/IServices/IIntentionCustomerService.cs +++ b/zhengcaioa/IServices/IIntentionCustomerService.cs @@ -19,7 +19,7 @@ ResultEntity ModifyStatus(string id, string userid); - List<IntentionCustomerDTO> GetList(); + List<IntentionCustomerDTO> GetList(string huiyuanId = null); diff --git a/zhengcaioa/IServices/IUserService.cs b/zhengcaioa/IServices/IUserService.cs index 8e7070e..5cd2482 100644 --- a/zhengcaioa/IServices/IUserService.cs +++ b/zhengcaioa/IServices/IUserService.cs @@ -29,5 +29,12 @@ List<PltUserDTO> GetListjisuankaoqin(DateTime dateminkaoqin, DateTime datemaxkaoqin); + ResultEntity savePltUserFenpeiDate(DateTime? FenpeiDate, string userId); + + ResultEntity saveCustomerYwjl(CustomerYwjl DTO); + + + List<CustomerYwjl> GetListCustomerYwjl(string CustomerId); + } } diff --git a/zhengcaioa/Model/CustomerYwjl.cs b/zhengcaioa/Model/CustomerYwjl.cs new file mode 100644 index 0000000..9d55703 --- /dev/null +++ b/zhengcaioa/Model/CustomerYwjl.cs @@ -0,0 +1,15 @@ +锘縰sing System; +using System.Collections.Generic; + +#nullable disable + +namespace zhengcaioa.Models +{ + public partial class CustomerYwjl + { + public string Id { get; set; } + public string UserId { get; set; } + public string YwjlId { get; set; } + public DateTime? Createtime { get; set; } + } +} diff --git a/zhengcaioa/Model/PltUser.cs b/zhengcaioa/Model/PltUser.cs index 106bb33..d0b0ce2 100644 --- a/zhengcaioa/Model/PltUser.cs +++ b/zhengcaioa/Model/PltUser.cs @@ -74,5 +74,6 @@ public decimal? geshuiqizheng { get; set; } public string Yaoqingma { get; set; } public DateTime? HetongDateEnd { get; set; } + public DateTime? FenpeiDate { get; set; } } } diff --git a/zhengcaioa/Model/zhengcaioaContext.cs b/zhengcaioa/Model/zhengcaioaContext.cs index e5eaff8..fdf849e 100644 --- a/zhengcaioa/Model/zhengcaioaContext.cs +++ b/zhengcaioa/Model/zhengcaioaContext.cs @@ -62,6 +62,7 @@ public virtual DbSet<CooperOrder> CooperOrders { get; set; } public virtual DbSet<CooperVisit> CooperVisits { get; set; } public virtual DbSet<CooperatecustomCustomer> CooperatecustomCustomers { get; set; } + public virtual DbSet<CustomerYwjl> CustomerYwjls { get; set; } public virtual DbSet<CustomerGuanlian> CustomerGuanlians { get; set; } public virtual DbSet<CusFangwenjilu> CusFangwenjilus { get; set; } public virtual DbSet<FiAccount> FiAccounts { get; set; } @@ -2761,6 +2762,26 @@ .HasColumnName("taocanjianshu"); }); + + modelBuilder.Entity<CustomerYwjl>(entity => + { + entity.ToTable("Customer_Ywjl"); + + entity.Property(e => e.Id).HasMaxLength(50); + + entity.Property(e => e.Createtime) + .HasColumnType("datetime") + .HasColumnName("createtime"); + + entity.Property(e => e.UserId) + .HasMaxLength(50) + .HasColumnName("userId"); + + entity.Property(e => e.YwjlId) + .HasMaxLength(50) + .HasColumnName("ywjlId"); + }); + modelBuilder.Entity<CustomerGuanlian>(entity => { entity.ToTable("CustomerGuanlian"); @@ -5367,6 +5388,8 @@ entity.Property(e => e.HetongDateEnd).HasColumnType("datetime"); + entity.Property(e => e.FenpeiDate).HasColumnType("datetime"); + entity.Property(e => e.ShiyongPrice).HasColumnType("numeric(18, 2)"); entity.Property(e => e.Tel) diff --git a/zhengcaioa/Services/CooperatecustomCustomerService.cs b/zhengcaioa/Services/CooperatecustomCustomerService.cs index 3e6ca7f..3007480 100644 --- a/zhengcaioa/Services/CooperatecustomCustomerService.cs +++ b/zhengcaioa/Services/CooperatecustomCustomerService.cs @@ -128,7 +128,10 @@ updateproject.Modifier = cooperatecustomCustomer.Modifier; updateproject.Modifytime = cooperatecustomCustomer.Modifytime; updateproject.Weixin = cooperatecustomCustomer.Weixin; - updateproject.HuiyuanId = cooperatecustomCustomer.HuiyuanId; + if (!string.IsNullOrEmpty(cooperatecustomCustomer.HuiyuanId)) + { + updateproject.HuiyuanId = cooperatecustomCustomer.HuiyuanId; + } updateproject.Shifoutianjiaweixin = cooperatecustomCustomer.Shifoutianjiaweixin; updateproject.Weixintime = cooperatecustomCustomer.Weixintime; updateproject.Weixiner = cooperatecustomCustomer.Weixiner; diff --git a/zhengcaioa/Services/IntentionCustomerService.cs b/zhengcaioa/Services/IntentionCustomerService.cs index 410bb6c..404a3f7 100644 --- a/zhengcaioa/Services/IntentionCustomerService.cs +++ b/zhengcaioa/Services/IntentionCustomerService.cs @@ -510,21 +510,35 @@ /// 鑾峰彇鎵�鏈夋湁鏁堟剰鍚戝鎴� /// </summary> /// <returns></returns> - public List<IntentionCustomerDTO> GetList() + public List<IntentionCustomerDTO> GetList(string huiyuanId = null) { List<IntentionCustomerDTO> intentionCustomerDTOs = (List<IntentionCustomerDTO>)CacheHelperNetCore.CacheValue("intentionCustomerDTOs"); + + if (intentionCustomerDTOs != null && intentionCustomerDTOs.Count > 0) { + if (!string.IsNullOrEmpty(huiyuanId)) + { + intentionCustomerDTOs = intentionCustomerDTOs.Where(x => x.HuiyuanId == huiyuanId).ToList(); + } + + return intentionCustomerDTOs; } + var listPosition = _context.IntentionCustomers.Where(r => r.RecStatus == "A").ToList(); intentionCustomerDTOs = _mapper.Map<List<IntentionCustomerDTO>>(listPosition); CacheHelperNetCore.CacheInsert("intentionCustomerDTOs", intentionCustomerDTOs); - var list = _mapper.Map<List<IntentionCustomerDTO>>(listPosition); - return list; + + if (!string.IsNullOrEmpty(huiyuanId)) + { + intentionCustomerDTOs = intentionCustomerDTOs.Where(x => x.HuiyuanId == huiyuanId).ToList(); + } + + return intentionCustomerDTOs; } /// <summary> diff --git a/zhengcaioa/Services/UserService.cs b/zhengcaioa/Services/UserService.cs index 32f4736..4387ca5 100644 --- a/zhengcaioa/Services/UserService.cs +++ b/zhengcaioa/Services/UserService.cs @@ -411,6 +411,67 @@ var list = _mapper.Map<List<PltUserDTO>>(listUser.ToList()); return list; } + + + public ResultEntity savePltUserFenpeiDate(DateTime? FenpeiDate,string userId) + { + ResultEntity resultEntity = new ResultEntity(); + + try { + + var updatepltUser = _context.PltUsers.Find(userId); + + updatepltUser.FenpeiDate = FenpeiDate; + + _context.SaveChanges(); + resultEntity.ReturnID = userId; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + + public ResultEntity saveCustomerYwjl(CustomerYwjl DTO) + { + + ResultEntity resultEntity = new ResultEntity(); + try + { + + + + + + DTO.Id = Guid.NewGuid().ToString(); + + _context.CustomerYwjls.Add(DTO); + + + _context.SaveChanges(); + resultEntity.ReturnID = DTO.Id; + resultEntity.Result = true; + } + catch (Exception ex) + { + resultEntity.Result = false; + resultEntity.Message = "淇濆瓨澶辫触锛岃鑱旂郴绠$悊鍛�"; + + } + return resultEntity; + } + + + public List<CustomerYwjl> GetListCustomerYwjl(string CustomerId) + { + var listUser = _context.CustomerYwjls.Where(u => u.UserId == CustomerId).OrderByDescending(x=>x.Createtime).ToList(); + return listUser; + } } } \ No newline at end of file diff --git a/zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs b/zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs index db6457c..f2f3346 100644 --- a/zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs +++ b/zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs @@ -16,6 +16,7 @@ using zhengcaioa.Models; using zhengcaioa.IService; using System.Transactions; +using System.IdentityModel.Tokens.Jwt; namespace zhengcaioa.Controllers.Customer { @@ -31,11 +32,13 @@ private readonly ISysAttachmentService _sysAttachmentService; private readonly IPltPageService _pltPageService; private readonly ICooperVisitService _cooperVisitService; + private readonly IIntentionCustomerService _intentionCustomerService; public CooperatecustomCustomerController(ILogger<CooperatecustomCustomerController> logger, IProjectService projectService, ILiaotianService liaotianService, ICooperatecustomCustomerService cooperatecustomCustomerService, IUserService userService, IHrDeptService hrDeptService , ISysAttachmentService sysAttachmentService , IPltPageService pltPageService - , ICooperVisitService cooperVisitService) + , ICooperVisitService cooperVisitService + , IIntentionCustomerService intentionCustomerService) { _logger = logger; _projectService = projectService; @@ -46,6 +49,7 @@ _sysAttachmentService = sysAttachmentService; _pltPageService = pltPageService; _cooperVisitService = cooperVisitService; + _intentionCustomerService = intentionCustomerService; } public IActionResult Index() @@ -577,5 +581,9 @@ return new JsonResult(resultEntity); } + + + + } } diff --git a/zhengcaioa/zhengcaioa/Controllers/UserController.cs b/zhengcaioa/zhengcaioa/Controllers/UserController.cs index d6b4099..eb4a16f 100644 --- a/zhengcaioa/zhengcaioa/Controllers/UserController.cs +++ b/zhengcaioa/zhengcaioa/Controllers/UserController.cs @@ -6,6 +6,7 @@ using Newtonsoft.Json; using System; using System.Collections.Generic; +using System.IdentityModel.Tokens.Jwt; using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -26,11 +27,15 @@ private readonly ISysAttachmentService _sysAttachmentService; private readonly IPltRoleService _pltRoleService; private readonly IPltPageService _pltPageService; + private readonly ICooperatecustomCustomerService _cooperatecustomCustomerService; + private readonly IIntentionCustomerService _intentionCustomerService; public UserController(ILogger<UserController> logger, IUserService userService, IHrDeptService hrDeptService, IHrPositionService hrPositionService, ILiaotianService liaotianService, IPltJiatingchengyuanService pltJiatingchengyuanService, ISysAttachmentService sysAttachmentService , IPltRoleService pltRoleService - , IPltPageService pltPageService) + , IPltPageService pltPageService + , ICooperatecustomCustomerService cooperatecustomCustomerService + , IIntentionCustomerService intentionCustomerService) { _logger = logger; _userService = userService; @@ -41,6 +46,8 @@ _sysAttachmentService = sysAttachmentService; _pltRoleService = pltRoleService; _pltPageService = pltPageService; + _cooperatecustomCustomerService = cooperatecustomCustomerService; + _intentionCustomerService = intentionCustomerService; } @@ -585,7 +592,144 @@ return JsonConvert.SerializeObject(resultEntity); } #endregion + //鎻愰棶 + public IActionResult GetHuiYuanYwjl(string change = "D") + { + ReturnMsg<PltUserDTO> returnMsg = new ReturnMsg<PltUserDTO>(); + returnMsg.code = 2; + try + { + string userid = ""; + var headers = Request.Headers; + if (headers != null) + { + //string SecurityKey = _configuration.GetSection("SecurityKey").Value; + var keyId = headers["Authorization"].FirstOrDefault(); + if (string.IsNullOrEmpty("keyId")) + { + returnMsg.code = 2; + returnMsg.error = "娌℃湁鑾峰彇鍒皌oken"; + returnMsg.count = 0; + return new JsonResult(returnMsg); + } + + + JwtSecurityToken jwt = null; + var handler = new JwtSecurityTokenHandler(); + var key1 = keyId.Replace("Bearer", "").Trim(); + jwt = handler.ReadJwtToken(key1); + System.Security.Claims.Claim sss = jwt.Claims.Where(x => x.Type == "id").FirstOrDefault(); + userid = sss.Value; + + } + + + + //鏌ユ壘鐢ㄦ埛瀵瑰簲鐨勪笟鍔$粡鐞嗭紝娌℃湁鐨勮瘽灏卞垎閰嶄竴涓笟鍔$粡鐞� + PltUserDTO dTO = new PltUserDTO(); + + var cooperatecustomCustomerDTOs = _cooperatecustomCustomerService.GetList(userid); + //鍚堜綔瀹㈡埛鏄惁瀛樺湪涓氬姟缁忕悊 + if (cooperatecustomCustomerDTOs.Count > 0) + { + var cooperatecustomCustomerDTO = cooperatecustomCustomerDTOs.Where(x => x.Ywjl != null).FirstOrDefault(); + if (cooperatecustomCustomerDTO != null) + { + dTO = _userService.GetPltUserEntity(cooperatecustomCustomerDTO.Ywjl); + if (!string.IsNullOrEmpty(dTO.Id) && dTO.IsYwjl == "A" && dTO.Zhiwustatus == "A") + { + returnMsg.code = 1; + returnMsg.returnObj = dTO; + return new JsonResult(returnMsg); + } + } + + } + + var intentionCustomerDTOs = _intentionCustomerService.GetList(userid); + //妗f瀹㈡埛鏄惁瀛樺湪涓氬姟缁忕悊 + if (intentionCustomerDTOs.Count > 0) + { + var intentionCustomerDTO = intentionCustomerDTOs.Where(x => x.Ywjl != null).FirstOrDefault(); + if (intentionCustomerDTO != null) + { + dTO = _userService.GetPltUserEntity(intentionCustomerDTO.Ywjl); + if (!string.IsNullOrEmpty(dTO.Id) && dTO.IsYwjl == "A" && dTO.Zhiwustatus == "A") + { + returnMsg.code = 1; + returnMsg.returnObj = dTO; + return new JsonResult(returnMsg); + } + } + } + //鏄惁鏇剧粡鍒嗛厤杩囦笟鍔$粡鐞� + var customerYwjls = _userService.GetListCustomerYwjl(userid); + if (customerYwjls.Count > 0) + { + if (change != "A") + { + + dTO = _userService.GetPltUserEntity(customerYwjls.First().YwjlId); + if (!string.IsNullOrEmpty(dTO.Id) && dTO.IsYwjl == "A" && dTO.Zhiwustatus == "A") + { + returnMsg.code = 1; + returnMsg.returnObj = dTO; + return new JsonResult(returnMsg); + } + } + else + { + var pltUserDTOs = _userService.GetList(null, "A").Where(x => x.Id != customerYwjls.First().YwjlId).OrderBy(x => x.FenpeiDate).ToList(); + if (pltUserDTOs.Count > 0) + { + dTO = pltUserDTOs.First(); + _userService.savePltUserFenpeiDate(DateTime.Now, dTO.Id); + CustomerYwjl customerYwjl = new CustomerYwjl(); + customerYwjl.UserId = userid; + customerYwjl.YwjlId = dTO.Id; + customerYwjl.Createtime = DateTime.Now; + _userService.saveCustomerYwjl(customerYwjl); + returnMsg.code = 1; + returnMsg.returnObj = dTO; + return new JsonResult(returnMsg); + } + + } + + } + + + //鍒嗛厤瀹㈡埛缁忕悊 + var userDTOs = _userService.GetList(null, "A").OrderBy(x => x.FenpeiDate).ToList(); + if (userDTOs.Count > 0) + { + dTO = userDTOs.First(); + _userService.savePltUserFenpeiDate(DateTime.Now, dTO.Id); + CustomerYwjl customerYwjl = new CustomerYwjl(); + customerYwjl.UserId = userid; + customerYwjl.YwjlId = dTO.Id; + customerYwjl.Createtime = DateTime.Now; + _userService.saveCustomerYwjl(customerYwjl); + returnMsg.code = 1; + returnMsg.returnObj = dTO; + return new JsonResult(returnMsg); + } + + + returnMsg.code = 2; + returnMsg.error = "娌℃湁鎵惧埌涓氬姟缁忕悊"; + returnMsg.count = 0; + } + catch (Exception ex) + { + returnMsg.code = 2; + returnMsg.error = "娌℃湁鑾峰彇鍒皌oken"; + returnMsg.count = 0; + + } + return new JsonResult(returnMsg); + } } } \ No newline at end of file diff --git a/zhengcaioa/zhengcaioa/appsettings.Development.json b/zhengcaioa/zhengcaioa/appsettings.Development.json index 8bb28ea..5d8d368 100644 --- a/zhengcaioa/zhengcaioa/appsettings.Development.json +++ b/zhengcaioa/zhengcaioa/appsettings.Development.json @@ -13,7 +13,7 @@ } }, "AllowedHosts": "*", - "Elasticsearchurl": "http://192.168.0.4:9200", + "Elasticsearchurl": "http://192.168.0.15:9200", "SecurityKey": "superSecretKey@345", "Shuchengurl": "http://192.168.0.7:8085", "GetShopUsers": "/actionapi/Shop/GetShopUsers", -- Gitblit v1.9.1