username@email.com
2023-02-02 db0147994ef4899702ac864ac0794a79fe980416
分配客户聊天的业务经理
12个文件已修改
1个文件已添加
295 ■■■■■ 已修改文件
zhengcaioa/Crawler/Program.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/DTO/PltUserDTO.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/IServices/IIntentionCustomerService.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/IServices/IUserService.cs 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Model/CustomerYwjl.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Model/PltUser.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Model/zhengcaioaContext.cs 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Services/CooperatecustomCustomerService.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Services/IntentionCustomerService.cs 20 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/Services/UserService.cs 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/zhengcaioa/Controllers/Customer/CooperatecustomCustomerController.cs 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/zhengcaioa/Controllers/UserController.cs 146 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zhengcaioa/zhengcaioa/appsettings.Development.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
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;";
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; }
zhengcaioa/IServices/IIntentionCustomerService.cs
@@ -19,7 +19,7 @@
        ResultEntity ModifyStatus(string id, string userid);
        List<IntentionCustomerDTO> GetList();
        List<IntentionCustomerDTO> GetList(string huiyuanId = null);
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);
    }
}
zhengcaioa/Model/CustomerYwjl.cs
New file
@@ -0,0 +1,15 @@
using 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; }
    }
}
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; }
    }
}
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)
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;
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>
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;
        }
    }
}
                                                         
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);
        }
    }
}
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 = "没有获取到token";
                        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);
                //档案客户是否存在业务经理
                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 = "没有获取到token";
                returnMsg.count = 0;
            }
            return new JsonResult(returnMsg);
        }
    }
}
 
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",