/// <summary> /// 公客池移动 /// </summary> /// <param name="customerChangePoolRequest"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task ChangePool(UserInfo user, CustomerChangePoolRequest customerChangePoolRequest, CancellationToken cancellationToken = default(CancellationToken)) { if (customerChangePoolRequest == null) { throw new ArgumentNullException(nameof(CustomerChangePoolRequest)); } var list = await Store.ListAsync(a => a.Where(b => customerChangePoolRequest.CustomerIds.Contains(b.CustomerId))); var mig = new List <MigrationPoolHistory>(); for (int i = 0; i < list.Count; i++) { list[i].DepartmentId = customerChangePoolRequest.NewDepartmentId; list[i].UpdateUser = user.Id; list[i].UpdateTime = DateTime.Now; mig.Add(new MigrationPoolHistory { CustomerId = list[i].CustomerId, MigrationTime = DateTime.Now, OriginalDepartment = list[i].DepartmentId, TargetDepartment = customerChangePoolRequest.NewDepartmentId }); } await Store.UpdateListAsync(list, mig, cancellationToken); }
public async Task <ResponseMessage> CustomerChangePool(UserInfo user, [FromBody] CustomerChangePoolRequest customerChangePoolRequest) { Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})将客户从一个公客池移动到另一个公客池(CustomerChangePool):\r\n请求参数为:\r\n" + (customerChangePoolRequest != null ? JsonHelper.ToJson(customerChangePoolRequest) : "")); ResponseMessage <CustomerPoolDefineResponse> response = new ResponseMessage <CustomerPoolDefineResponse>(); if (!ModelState.IsValid) { response.Code = ResponseCodeDefines.ModelStateInvalid; response.Message = ModelState.GetAllErrors(); Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})将客户从一个公客池移动到另一个公客池(CustomerChangePool)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (customerChangePoolRequest != null ? JsonHelper.ToJson(customerChangePoolRequest) : "")); return(response); } try { await _customerPoolManager.ChangePool(user, customerChangePoolRequest, HttpContext.RequestAborted); } catch (Exception e) { response.Code = ResponseCodeDefines.ServiceError; response.Message = e.ToString(); Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})将客户从一个公客池移动到另一个公客池(CustomerChangePool)请求失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (customerChangePoolRequest != null ? JsonHelper.ToJson(customerChangePoolRequest) : "")); } return(response); }