public void SaveCustomerFollowUp(Sender sender, SaveCustomerFollowUpArgs args) { try { using (ObjectProxy op = new ObjectProxy(true)) { CustomerFollowUp obj = new CustomerFollowUp(); obj.FollowID = args.CustomerFollowUp.FollowID; if (op.LoadCustomerFollowUpByFollowID(obj) == 0) { args.CustomerFollowUp.Created = DateTime.Now; args.CustomerFollowUp.CreatedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); args.CustomerFollowUp.Modified = DateTime.Now; args.CustomerFollowUp.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.InsertCustomerFollowUp(args.CustomerFollowUp); } else { args.CustomerFollowUp.Modified = DateTime.Now; args.CustomerFollowUp.ModifiedBy = string.Format("{0}.{1}", sender.UserCode, sender.UserName); op.UpdateCustomerFollowUpByFollowID(args.CustomerFollowUp); } op.CommitTransaction(); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
/// <summary> /// 删除客户跟进 /// </summary> /// <param name="user">登陆用户基本信息</param> /// <param name="customerfollowup">客户跟进实体</param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public async Task DeleteAsync(SimpleUser user, CustomerFollowUp customerfollowup, CancellationToken cancellationToken = default(CancellationToken)) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (customerfollowup == null) { throw new ArgumentNullException(nameof(customerfollowup)); } //删除基本信息 customerfollowup.DeleteTime = DateTime.Now; customerfollowup.DeleteUser = user.Id; customerfollowup.IsDeleted = true; Context.Attach(customerfollowup); var entry = Context.Entry(customerfollowup); entry.Property(x => x.IsDeleted).IsModified = true; entry.Property(x => x.DeleteUser).IsModified = true; entry.Property(x => x.DeleteTime).IsModified = true; try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { throw; } }
public IActionResult Index(UserResultViewModel UserReult) { ViewBag.Name = HttpContext.Session.GetString(SessionName); ViewBag.Title = "User"; UserResultViewModel _userResultViewModels = new UserResultViewModel(); _userResultViewModels.SearchDate = new SearchModel(); //Get Customer Details _userResultViewModels.UserResultviewCustomer = new List <CustomerFollowUp>(); int SalesPersonId = Convert.ToInt32(HttpContext.Session.GetString(SessionId)); //int SalesPersonId = 2; string Curr_date = System.DateTime.Now.ToShortDateString(); DateTime Cur_date = Convert.ToDateTime(Curr_date); if (UserReult.SearchDate != null) { _userResultViewModels.UserResultviewCustomer = _followupsContext.CustomerFollowUp.Where(x => x.DateOfContact >= UserReult.SearchDate.FromDate && x.DateOfContact <= UserReult.SearchDate.ToDate || x.CreateDate >= Cur_date && x.SalesPersonId == SalesPersonId).ToList(); _userResultViewModels.CountryResult = new List <Countries>(); _userResultViewModels.CountryResult = (from d in _followupsContext.Countries select d).ToList(); _userResultViewModels.CountryResult.Insert(0, new Countries { Id = 0, Name = "--Select--" }); ViewBag.Country = _userResultViewModels.CountryResult; //Bind Sales Person _userResultViewModels.ResultSalesPerson = new List <Employee>(); _userResultViewModels.ResultSalesPerson = (from c in _followupsContext.Employee select c).ToList(); _userResultViewModels.ResultSalesPerson.Insert(0, new Employee { Id = 0, Name = "--Select--" }); ViewBag.SalesPerson = _userResultViewModels.ResultSalesPerson; } else { if (UserReult.UserResultviewCustomer != null) { foreach (var item in UserReult.UserResultviewCustomer) { CustomerFollowUp objCust = new CustomerFollowUp(); objCust = _followupsContext.CustomerFollowUp.Find(item.FollowId); objCust.CountryId = item.CountryId; objCust.CustomerInterest = item.CustomerInterest; objCust.DateOfContact = item.DateOfContact; objCust.Idstatus = item.Idstatus; objCust.Phone = objCust.Phone; objCust.SalesPersonId = objCust.SalesPersonId; string d = DateTime.Now.ToShortDateString(); DateTime cur_date = Convert.ToDateTime(d); objCust.ModifiedDate = cur_date; _followupsContext.Entry(objCust).State = EntityState.Modified; _followupsContext.SaveChanges(); } } } //Bind Country return(View(_userResultViewModels)); }
/// <summary> /// 修改客户跟进信息 /// </summary> /// <param name="customerfollowup"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task UpdateAsync(CustomerFollowUp customerfollowup, CancellationToken cancellationToken = default(CancellationToken)) { if (customerfollowup == null) { throw new ArgumentNullException(nameof(customerfollowup)); } Context.Attach(customerfollowup); Context.Update(customerfollowup); try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { } }
public void SaveFollowUp() { using (ProxyBE p = new ProxyBE()) { try { if (parm.CustomerID == Guid.Empty) { throw new Exception("请选择客户。"); } if (parm.FollowType == "") { throw new Exception("请选择跟进方式"); } CustomerFollowUp followup = p.Client.GetCustomerFollowUp(null, parm.FollowID); if (followup == null) { followup = new CustomerFollowUp(); followup.FollowID = parm.FollowID; } followup.CustomerID = parm.CustomerID; followup.FollowType = parm.FollowType; followup.Title = parm.Title; followup.Remark = parm.Remark; //followup.CreatedBy = parm.CreatedBy; followup.ImportantResult = parm.ImportantResult; followup.Suggest = parm.Suggest; SaveCustomerFollowUpArgs args = new SaveCustomerFollowUpArgs(); args.CustomerFollowUp = followup; p.Client.SaveCustomerFollowUp(SenderUser, args); WriteSuccess(); } catch (Exception ex) { WriteError(ex.Message, ex); } } }
public CustomerFollowUp GetCustomerFollowUp(Sender sender, Guid FollowID) { try { using (ObjectProxy op = new ObjectProxy()) { CustomerFollowUp obj = new CustomerFollowUp(); obj.FollowID = FollowID; if (op.LoadCustomerFollowUpByFollowID(obj) == 0) { return(null); } return(obj); } } catch (Exception ex) { PLogger.LogError(ex); throw ex; } }
/// <summary> /// 新增客户跟进信息 /// </summary> /// <param name="customerfollowup">实体</param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public async Task <CustomerFollowUp> CreateAsync(CustomerFollowUp customerfollowup, CancellationToken cancellationToken = default(CancellationToken)) { if (customerfollowup == null) { throw new ArgumentNullException(nameof(customerfollowup)); } var costomerinfo = await Context.CustomerInfos.FindAsync(customerfollowup.CustomerId); costomerinfo.FollowUpNum++; costomerinfo.FollowupTime = customerfollowup.FollowUpTime; var customerdemand = Context.CustomerDemands.Where(x => x.CustomerId == costomerinfo.Id).FirstOrDefault(); if (customerfollowup.Importance != null) { customerdemand.Importance = customerfollowup.Importance; customerdemand.DemandLevel = customerfollowup.DemandLevel; Context.Attach(customerdemand); Context.Update(customerdemand); } else { customerfollowup.Importance = customerdemand.Importance; customerfollowup.DemandLevel = customerfollowup.DemandLevel; } Context.Attach(costomerinfo); Context.Update(costomerinfo); Context.Add(customerfollowup); await Context.SaveChangesAsync(cancellationToken); return(customerfollowup); }
public void UpdateFollowUp() { try { Guid FollowID = new Guid(Request["FollowID"]); using (ProxyBE p = new ProxyBE()) { CustomerFollowUp rd = p.Client.GetCustomerFollowUp(SenderUser, FollowID); if (rd != null) { Response.Write(JSONHelper.Object2Json(rd)); } else { Response.Write(JSONHelper.Object2Json(null)); } } } catch (Exception ex) { WriteError(ex.Message, ex); } }
public async Task <CustomerLoss> CreateAsync(CustomerLoss customerLoss, CancellationToken cancellationToken = default(CancellationToken)) { if (customerLoss == null) { throw new ArgumentNullException(nameof(customerLoss)); } Context.Add(customerLoss); if (customerLoss.CustomerInfo != null) { Context.Attach(customerLoss.CustomerInfo); Context.Update(customerLoss.CustomerInfo); //插入跟进信息 var followup = new CustomerFollowUp { Id = Guid.NewGuid().ToString(), CustomerId = customerLoss.CustomerInfo.Id, TypeId = CustomerFollowUpType.Loss, UserId = customerLoss.LossUserId, DepartmentId = customerLoss.LossDepartmentId, FollowUpTime = DateTime.Now, TrueName = customerLoss.CustomerInfo.CustomerName, FollowUpContents = "拉无效", CustomerNo = customerLoss.CustomerInfo.CustomerNo, IsRealFollow = false, CreateTime = DateTime.Now, CreateUser = customerLoss.LossUserId }; Context.Add(followup); } await Context.SaveChangesAsync(cancellationToken); return(customerLoss); }
/// <summary> /// 再次带看 /// </summary> /// <param name="customertransactions"></param> /// <param name="customertransactionstollowup"></param> /// <param name="customerFollowUp"></param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public async Task CreateAgainBeltLookAsync(CustomerTransactions customertransactions, CustomerTransactionsFollowUp customertransactionstollowup, CustomerFollowUp customerFollowUp, CancellationToken cancellationToken = default(CancellationToken)) { if (customertransactions == null) { throw new ArgumentNullException(nameof(customertransactions)); } if (customertransactions != null) { Context.Add(customertransactions); } if (customertransactionstollowup != null) { Context.Add(customertransactionstollowup); } if (customerFollowUp != null) { Context.Add(customerFollowUp); } await Context.SaveChangesAsync(cancellationToken); }
/// <summary> /// 新增客户成交信息 /// </summary> /// <param name="customerdeal">实体</param> /// <param name="customerInfo"></param> /// <param name="customerTransactionsFollowUp"></param> /// <param name="customerTransactions"></param> /// <param name="customerFollowUp"></param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public async Task <CustomerDeal> CreateAsync(CustomerDeal customerdeal, CustomerInfo customerInfo, CustomerTransactionsFollowUp customerTransactionsFollowUp, CustomerTransactions customerTransactions, CustomerFollowUp customerFollowUp, CancellationToken cancellationToken = default(CancellationToken)) { if (customerdeal == null) { throw new ArgumentNullException(nameof(customerdeal)); } Context.Attach(customerdeal); Context.Update(customerdeal); if (customerInfo != null) { Context.Attach(customerInfo); Context.Update(customerInfo); } if (customerTransactions != null) { Context.Attach(customerTransactions); Context.Update(customerTransactions); Context.Add(customerTransactionsFollowUp); } if (customerFollowUp != null) { Context.Add(customerFollowUp); } await Context.SaveChangesAsync(cancellationToken); return(customerdeal); }
public async Task <bool> ActivateLossUser(UserInfo user, string Id, bool isDeleteOldData, CancellationToken cancellationToken = default(CancellationToken)) { var customerLoss = await Context.CustomerLosss.AsNoTracking().Where(a => a.CustomerId == Id && !a.IsDeleted).FirstOrDefaultAsync(cancellationToken); if (isDeleteOldData) { if (customerLoss == null) { return(false); } var customer = await Context.CustomerInfos.AsNoTracking().Where(a => a.Id == customerLoss.CustomerId).FirstOrDefaultAsync(cancellationToken); if (customer == null) { return(false); } var customerdemand = await Context.CustomerDemands.AsNoTracking().Where(a => a.CustomerId == customerLoss.CustomerId).FirstOrDefaultAsync(cancellationToken); if (customerdemand == null) { return(false); } var oldcustomer = customer; oldcustomer.IsDeleted = true; oldcustomer.DeleteTime = DateTime.Now; oldcustomer.DeleteUser = user.Id; var newcustomerinfo = await Context.CustomerInfos.AsNoTracking().Where(a => a.Id == customerLoss.CustomerId).FirstOrDefaultAsync(cancellationToken);; newcustomerinfo.Id = Guid.NewGuid().ToString(); newcustomerinfo.IsDeleted = false; newcustomerinfo.CustomerStatus = CustomerStatus.ExistingCustomers; newcustomerinfo.FollowupTime = DateTime.Now; newcustomerinfo.SourceId = customer.Id; customerdemand.CustomerId = newcustomerinfo.Id; customerdemand.IsDeleted = false; customerLoss.IsDeleted = true; customerLoss.DeleteTime = DateTime.Now; customerLoss.DeleteUserId = user.Id; Context.Add(newcustomerinfo); Context.Attach(oldcustomer); Context.Update(oldcustomer); Context.Attach(customerdemand); Context.Update(customerdemand); Context.Attach(customerLoss); Context.Update(customerLoss); await Context.SaveChangesAsync(cancellationToken); } else { if (customerLoss == null) { return(false); } var customer = await Context.CustomerInfos.AsNoTracking().Where(a => a.Id == customerLoss.CustomerId).FirstOrDefaultAsync(cancellationToken); if (customer == null) { return(false); } var customerdemand = await Context.CustomerDemands.AsNoTracking().Where(a => a.CustomerId == customerLoss.CustomerId).FirstOrDefaultAsync(cancellationToken); if (customerdemand == null) { return(false); } customer.IsDeleted = false; customer.CustomerStatus = CustomerStatus.ExistingCustomers; customer.FollowUpNum = customer.FollowUpNum + 1; customer.FollowupTime = DateTime.Now; customerdemand.IsDeleted = false; customerLoss.IsDeleted = true; customerLoss.DeleteTime = DateTime.Now; customerLoss.DeleteUserId = user.Id; Context.Attach(customer); Context.Attach(customerdemand); Context.Attach(customerLoss); Context.Update(customer); Context.Update(customerdemand); Context.Update(customerLoss); //插入跟进信息 var followup = new CustomerFollowUp { Id = Guid.NewGuid().ToString(), CustomerId = customer.Id, TypeId = CustomerFollowUpType.Activation, UserId = user.Id, DepartmentId = user.OrganizationId, FollowUpTime = DateTime.Now, TrueName = customer.CustomerName, FollowUpContents = "激活用户", CustomerNo = customer.CustomerNo, IsRealFollow = false, CreateTime = DateTime.Now, CreateUser = user.Id }; Context.Add(followup); await Context.SaveChangesAsync(cancellationToken); } return(true); }
public IActionResult Index(CustomerResultViewModel customers, IFormFile file, [FromServices] IHostingEnvironment hostingEnvironment) { CustomerResultViewModel _custResult = new CustomerResultViewModel(); _custResult.ResultCustomer = new List <Customer>(); _custResult.ResultSalesPerson = new List <Employee>(); _custResult.Customer = new Customer(); //Sales Persons Details _custResult.ResultSalesPerson = (from c in _followupsContext.Employee select c).ToList(); _custResult.ResultSalesPerson.Insert(0, new Employee { Id = 0, Name = "--Select--" }); ViewBag.SalesPerson = _custResult.ResultSalesPerson; //Coutry Details _custResult.ResultCountry = new List <Countries>(); _custResult.ResultCountry = (from d in _followupsContext.Countries select d).ToList(); _custResult.ResultCountry.Insert(0, new Countries { PhoneCode = 0, Name = "--Select--" }); ViewBag.Country = _custResult.ResultCountry; //Upload Files if (file != null) { int Countrycode = (int)customers.Customer.CountryId; string filename = $"{hostingEnvironment.WebRootPath}\\files\\{ file.FileName}"; using (FileStream fileStream = System.IO.File.Create(filename)) { file.CopyTo(fileStream); fileStream.Flush(); } _custResult.ResultCustomer = this.GetCustDetails(file.FileName, Countrycode); return(View(_custResult)); } //Save Details else { DataTable dtUnassigned = new DataTable(); dtUnassigned.Columns.Add("Phone", typeof(string)); if (customers.ResultCustomer != null) { using (var context = new FollowUpDbContext()) { foreach (var item in customers.ResultCustomer) { if (item.SalesPersonId != 0) { CustomerFollowUp CustResult = _mapper.Map <CustomerFollowUp>(item); context.CustomerFollowUp.Add(CustResult); context.SaveChanges(); } else { dtUnassigned.Rows.Add(item.Phone); } } } if (dtUnassigned.Rows.Count > 0) { string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; string fileName = "UnAssignedPhone.xlsx"; using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.Worksheets.Add("Sheet1"); worksheet.Cell(1, 1).Value = "Phone"; for (int i = 0; i <= dtUnassigned.Rows.Count - 1; i++) { worksheet.Cell(i + 1, 1).Value = dtUnassigned.Rows[i]["Phone"].ToString(); } using (var stream = new MemoryStream()) { workbook.SaveAs(stream); var content = stream.ToArray(); return(File(content, contentType, fileName)); } } } } //Save Details Mannually if (customers.Customer != null) { string d1 = DateTime.Now.ToShortDateString(); DateTime Cur_date = Convert.ToDateTime(d1); _custResult.Customer.CreateDate = Cur_date; customers.Customer.CreateDate = Cur_date; var details = customers.Customer; CustomerFollowUp CustResult = _mapper.Map <CustomerFollowUp>(customers.Customer); _followupsContext.CustomerFollowUp.Add(CustResult); _followupsContext.SaveChanges(); } return(RedirectToAction("Index")); } }
/// <summary> /// 新增报备信息 /// </summary> /// <param name="user">新增人基本信息</param> /// <param name="customerReportRequest">请求实体</param> /// <param name="cancellationToken">验证</param> /// <returns></returns> public virtual async Task <CustomerReportResponse> CreateAsync(UserInfo user, CustomerReportRequest customerReportRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (customerReportRequest == null) { throw new ArgumentNullException(nameof(customerReportRequest)); } customerReportRequest.CustomerInfoCreateRequest.MainPhone = new Help.EncDncHelper().Encrypt(customerReportRequest.CustomerInfoCreateRequest.MainPhone); if (string.IsNullOrEmpty(customerReportRequest.CustomerId)) { //信息是否完善 if (string.IsNullOrEmpty(customerReportRequest.CustomerInfoCreateRequest.MainPhone) && string.IsNullOrEmpty(customerReportRequest.CustomerInfoCreateRequest.CustomerName)) { throw new ArgumentNullException(nameof(customerReportRequest)); } else { var customerInfo = await _customerinfoStore.CustomerInfoAll().Where(b => b.UserId == user.Id && b.MainPhone == customerReportRequest.CustomerInfoCreateRequest.MainPhone && b.CustomerName == customerReportRequest.CustomerInfoCreateRequest.CustomerName && !b.IsDeleted).FirstOrDefaultAsync(cancellationToken); if (customerInfo != null) { //修改核心意向 var demand = await _icustomerDemandStore.GetAsync(a => a.Where(b => b.Id == customerInfo.CustomerDemand.Id), cancellationToken); if (customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.PriceEnd == null) { demand.PriceEnd = customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.PriceEnd; } if (customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.PriceStart == null) { demand.PriceStart = customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.PriceStart; } if (customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.AcreageEnd == null) { demand.AcreageEnd = customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.AcreageEnd; } if (customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.AcreageStart == null) { demand.AcreageStart = customerReportRequest.CustomerInfoCreateRequest.CustomerDemandRequest.AcreageStart; } await _icustomerDemandStore.UpdateAsync(demand, cancellationToken); } else { var customerinfo = _mapper.Map <CustomerInfo>(customerReportRequest.CustomerInfoCreateRequest); //客户基本信息 customerinfo.Id = Guid.NewGuid().ToString(); customerinfo.CreateUser = user.Id; customerinfo.CreateTime = DateTime.Now; customerinfo.UserId = user.Id; customerinfo.DepartmentId = user.OrganizationId; //最后跟进时间为创建时间 customerinfo.FollowupTime = customerinfo.CreateTime; if (customerinfo.Birthday != null) { customerinfo.Age = DateTime.Now.Year - customerinfo.Birthday.Value.Year; } customerinfo.CustomerStatus = CustomerStatus.ExistingCustomers; //客户需求信息 customerinfo.CustomerDemand.Id = Guid.NewGuid().ToString(); customerinfo.CustomerDemand.UserId = user.Id; customerinfo.CustomerDemand.DepartmentId = user.OrganizationId; customerinfo.CustomerDemand.CustomerId = customerinfo.Id; customerinfo.CustomerDemand.CreateUser = user.Id; customerinfo.CustomerDemand.CreateTime = DateTime.Now; //客户电话信息 customerinfo.CustomerPhones = customerinfo.CustomerPhones.Select(q => { q.Id = Guid.NewGuid().ToString(); q.CustomerId = customerinfo.Id; q.CreateUser = user.Id; q.CreateTime = DateTime.Now; return(q); }); await _customerinfoStore.CreateAsync(customerinfo, cancellationToken); customerReportRequest.CustomerId = customerinfo.Id; } } } else { //更新原来的用户数据跟进时间 var customerinfo = await _customerinfoStore.GetAsync(a => a.Where(b => b.Id == customerReportRequest.CustomerId && !b.IsDeleted)); //插入跟进信息 var followup = new CustomerFollowUp { Id = Guid.NewGuid().ToString(), CustomerId = customerReportRequest.CustomerId, TypeId = CustomerFollowUpType.CustomerReported, UserId = user.Id, DepartmentId = user.OrganizationId, FollowUpTime = DateTime.Now, TrueName = customerinfo.CustomerName, FollowUpContents = "客户报备", CustomerNo = customerinfo.CustomerNo, IsRealFollow = false, CreateTime = DateTime.Now, CreateUser = user.Id }; await _icustomerFollowUpStore.CreateAsync(followup, cancellationToken); } var customerreport = _mapper.Map <CustomerReport>(customerReportRequest); //报备基本信息 customerreport.Id = Guid.NewGuid().ToString(); customerreport.CreateUser = user.Id; customerreport.CreateTime = DateTime.Now; customerreport.UserId = user.Id; customerreport.DepartmentId = user.OrganizationId; customerreport.ReportTime = customerreport.CreateTime; await _customerReportStore.CreateAsync(customerreport, cancellationToken); return(_mapper.Map <CustomerReportResponse>(customerreport)); }
public async Task <bool> ClaimCustomerAsync(UserInfo user, CustomerPoolClaimRequest customerPoolClaimRequest, CancellationToken cancellationToken = default(CancellationToken)) { var customerpools = Context.CustomerPools.Where(a => customerPoolClaimRequest.CustomerIds.Contains(a.CustomerId) && !a.IsDeleted).ToList(); customerpools = customerpools.Select(x => { x.IsDeleted = true; x.DeleteUser = user.Id; x.DeleteTime = DateTime.Now; return(x); }).ToList(); if (customerpools != null) { Context.UpdateRange(customerpools); } var customerInfos = Context.CustomerInfos.Where(a => customerPoolClaimRequest.CustomerIds.Contains(a.Id)).ToList(); foreach (var item in customerInfos) { var customerdemand = await Context.CustomerDemands.AsNoTracking().Where(a => a.CustomerId == item.Id).FirstOrDefaultAsync(cancellationToken); if (customerdemand == null) { return(false); } item.UserId = user.Id; item.DepartmentId = user.OrganizationId; item.CustomerStatus = CustomerStatus.ExistingCustomers; customerdemand.UserId = user.Id; customerdemand.DepartmentId = user.OrganizationId; //var newcustomerinfo = JsonConvert.DeserializeObject<CustomerInfo>(JsonConvert.SerializeObject(item)); //newcustomerinfo.Id = Guid.NewGuid().ToString(); //newcustomerinfo.IsDeleted = false; //newcustomerinfo.UserId = user.Id; //newcustomerinfo.DepartmentId = user.OrganizationId; //newcustomerinfo.UniqueId = item.UniqueId; //newcustomerinfo.CustomerStatus = CustomerStatus.ExistingCustomers; //newcustomerinfo.SourceId = item.Id; //var newcustomerdemand = JsonConvert.DeserializeObject<CustomerDemand>(JsonConvert.SerializeObject(customerdemand)); //customerdemand.Id = Guid.NewGuid().ToString(); //customerdemand.CustomerId = newcustomerinfo.Id; //customerdemand.IsDeleted = false; //customerdemand.UserId = user.Id; //customerdemand.DepartmentId = user.OrganizationId; var customerfu = new CustomerFollowUp { Id = Guid.NewGuid().ToString(), CustomerId = item.Id, TypeId = CustomerFollowUpType.ClaimCustomer, UserId = item.UserId, DepartmentId = item.DepartmentId, FollowUpTime = DateTime.Now, TrueName = item.CustomerName, FollowUpContents = "认领客户", CustomerNo = item.CustomerNo, IsRealFollow = false, CreateTime = DateTime.Now, CreateUser = user.Id }; if (item != null) { Context.Update(item); } //Context.Add(newcustomerinfo); if (customerfu != null) { Context.Add(customerfu); } if (customerdemand != null) { Context.Update(customerdemand); } } try { await Context.SaveChangesAsync(cancellationToken); } catch (DbUpdateConcurrencyException) { throw; } return(true); }