|
@@ -1,6 +1,7 @@
|
|
|
using AutoMapper;
|
|
|
using AutoMapper.Execution;
|
|
|
using MySqlX.XDevAPI.Relational;
|
|
|
+using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos;
|
|
|
using OASystem.Domain.Dtos.CRM;
|
|
@@ -29,6 +30,110 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
_mapper = mapper;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 客户资料
|
|
|
+ /// 基础数据源
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> _Init(int portType)
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
+
|
|
|
+ if (portType == 1 || portType == 2 || portType == 3)
|
|
|
+ {
|
|
|
+ #region 下拉框初始化数据
|
|
|
+ //负责人下拉框
|
|
|
+ List<dynamic> _Users = new List<dynamic>();
|
|
|
+ List<Sys_Users> users = _sqlSugar.Queryable<Sys_Users>()
|
|
|
+ .Where(u => (u.CnName == "张海麟" || u.CnName == "安宁" || u.CnName == "李彩娟" || u.CnName == "舒庆" || u.CnName == "李媛媛") && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_Users user in users)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = user.Id,
|
|
|
+ Name = user.CnName
|
|
|
+ };
|
|
|
+ _Users.Add(data);
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ List<Sys_SetData> initData = _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToList();
|
|
|
+
|
|
|
+ //客户级别数据
|
|
|
+ List<dynamic> _level = new List<dynamic>();
|
|
|
+ List<Sys_SetData> level = initData.Where(u => u.STid == 33 && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_SetData item in level)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ Name = item.Name
|
|
|
+ };
|
|
|
+ _level.Add(data);
|
|
|
+ };
|
|
|
+ //客户类别
|
|
|
+ List<dynamic> _CustomerClass = new List<dynamic>();
|
|
|
+ List<Sys_SetData> CustomerClass = initData.Where(u => u.STid == 37 && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_SetData item in CustomerClass)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ Name = item.Name
|
|
|
+ };
|
|
|
+ _CustomerClass.Add(data);
|
|
|
+ };
|
|
|
+ //业务分类
|
|
|
+ List<dynamic> _ServiceClass = new List<dynamic>();
|
|
|
+ List<Sys_SetData> ServiceClass = initData.Where(u => u.STid == 36 && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_SetData item in ServiceClass)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ Name = item.Name
|
|
|
+ };
|
|
|
+ _ServiceClass.Add(data);
|
|
|
+ };
|
|
|
+
|
|
|
+ //身份分类
|
|
|
+ List<dynamic> _ProvinceClass = new List<dynamic>();
|
|
|
+ List<Sys_SetData> ProvinceClass = initData.Where(u => u.STid == 42 && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_SetData item in ProvinceClass)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ Name = item.Name
|
|
|
+ };
|
|
|
+ _ProvinceClass.Add(data);
|
|
|
+ };
|
|
|
+ #endregion
|
|
|
+ var data1 = new {
|
|
|
+ Users = _Users,
|
|
|
+ Level = _level,
|
|
|
+ CustomerClass = _CustomerClass,
|
|
|
+ ServiceClass= _ServiceClass,
|
|
|
+ ProvinceClass = _ProvinceClass
|
|
|
+ };
|
|
|
+ return result = new Result()
|
|
|
+ {
|
|
|
+ Code = 0,
|
|
|
+ Msg = "查询成功",
|
|
|
+ Data = data1
|
|
|
+ };
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result.Msg = string.Format("请传入有效的PortType参数!");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 客户资料初识初始化
|
|
|
/// </summary>
|
|
@@ -345,68 +450,24 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
};
|
|
|
|
|
|
}
|
|
|
- else if (dto.PortType == 2)
|
|
|
- {
|
|
|
-
|
|
|
- foreach (var item in NewClientDataView)
|
|
|
- {
|
|
|
- List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
|
- ("select u1.UsersId as UserId ,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + item.Id + " AND u1.ISDEL = 0").ToListAsync();
|
|
|
- item.AscribedUser = AscribedUser.Select(x=> x.UserId);
|
|
|
-
|
|
|
- List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
|
|
|
- ("select d2.Id,d2.Name,d1.NewClientDataId from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + item.Id + " AND d1.ISDEL = 0").ToListAsync();
|
|
|
- item.AscribedDepartment = AscribedDepartment.Select(x => x.Id);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- result = new Result()
|
|
|
- {
|
|
|
- Code = 0,
|
|
|
- Msg = "查询成功",
|
|
|
- Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = NewClientDataView },
|
|
|
- };
|
|
|
- }
|
|
|
- else if (dto.PortType == 3)
|
|
|
+ else if (dto.PortType == 2 || dto.PortType == 3)
|
|
|
{
|
|
|
- List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
|
- ("select u1.UsersId as UserId ,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id AND u1.ISDEL = 0").ToListAsync();
|
|
|
-
|
|
|
- List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
|
|
|
- ("select d2.Id,d2.Name,d1.NewClientDataId from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id AND d1.ISDEL = 0").ToListAsync();
|
|
|
- List<NewClientDataIOSView> newClientDataIOSViews = new List<NewClientDataIOSView>();
|
|
|
+ List<NewClientDataAndroidIOSView> newClientDataIOSViews = new List<NewClientDataAndroidIOSView>();
|
|
|
foreach (var item in NewClientDataView)
|
|
|
{
|
|
|
-
|
|
|
- var ascribedUser = AscribedUser.Where(it => it.NewClientDataId == item.Id).Select(x => x.CnName).ToList();
|
|
|
-
|
|
|
-
|
|
|
- var ascribedDepartment = AscribedDepartment.Where(it => it.NewClientDataId == item.Id).Select(x => x.Name).ToList();
|
|
|
|
|
|
-
|
|
|
- newClientDataIOSViews.Add(new NewClientDataIOSView() {
|
|
|
- Id = item.Id,
|
|
|
+ newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
|
+ {
|
|
|
RowNumber = item.RowNumber,
|
|
|
- CategoryStr = item.CategoryStr,
|
|
|
- LvlidStr = item.LvlidStr,
|
|
|
- AscribedUser = ascribedUser,
|
|
|
- AscribedDepartment = ascribedDepartment,
|
|
|
+ Id = item.Id,
|
|
|
Client = item.Client,
|
|
|
Contact = item.Contact,
|
|
|
Job = item.Job,
|
|
|
Telephone = item.Telephone,
|
|
|
- Phone = item.Phone,
|
|
|
Location = item.Location,
|
|
|
- Birthday = item.Birthday,
|
|
|
- Weight = item.Weight,
|
|
|
- PreDele = item.PreDele,
|
|
|
- FinlishedDele = item.FinlishedDele,
|
|
|
- Remark = item.Remark,
|
|
|
});
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-
|
|
|
result = new Result()
|
|
|
{
|
|
|
Code = 0,
|
|
@@ -414,6 +475,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = newClientDataIOSViews },
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -756,5 +818,60 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
return AcrionResult;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 市场客户资料数据
|
|
|
+ /// 批量指派
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<Result> _BatchAssignment(BatchAssignmentDto dto)
|
|
|
+ {
|
|
|
+ Result AcrionResult = new Result() { Code = -1,Msg="操作失败"};
|
|
|
+ if (dto.UserIdItem != null || dto.UserIdItem.Count < 1)
|
|
|
+ {
|
|
|
+ AcrionResult.Msg = "用户ID集合不能为空!";
|
|
|
+ return AcrionResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (dto.ClientDataIdItem != null || dto.ClientDataIdItem.Count < 1)
|
|
|
+ {
|
|
|
+ AcrionResult.Msg = "客户资料ID集合不能为空!";
|
|
|
+ return AcrionResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Crm_ClientDataAndUser> _ClientDataAndUsers = new List<Crm_ClientDataAndUser>();
|
|
|
+
|
|
|
+ List < Crm_ClientDataAndUser > _ClientDataAndUsers1 = await _sqlSugar.Queryable< Crm_ClientDataAndUser >().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+ foreach (var clientDataId in dto.ClientDataIdItem)
|
|
|
+ {
|
|
|
+ Crm_ClientDataAndUser ClientDataAndUser = new Crm_ClientDataAndUser()
|
|
|
+ {
|
|
|
+ CreateUserId = dto.UserId,
|
|
|
+ NewClientDataId = clientDataId
|
|
|
+ };
|
|
|
+
|
|
|
+ foreach (var userId in dto.UserIdItem)
|
|
|
+ {
|
|
|
+ ClientDataAndUser.usersId = userId;
|
|
|
+ Crm_ClientDataAndUser _ClientDataAndUsers2 = _ClientDataAndUsers1.Where(it => it.NewClientDataId == clientDataId && it.usersId == userId).FirstOrDefault();
|
|
|
+ if (_ClientDataAndUsers2 == null)
|
|
|
+ {
|
|
|
+ _ClientDataAndUsers.Add(ClientDataAndUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (_ClientDataAndUsers.Count > 0)
|
|
|
+ {
|
|
|
+ var adds = await _sqlSugar.Insertable(_ClientDataAndUsers).ExecuteCommandAsync();
|
|
|
+ if (adds > 0)
|
|
|
+ {
|
|
|
+ AcrionResult.Code = 0;
|
|
|
+ return AcrionResult;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return AcrionResult;
|
|
|
+ }
|
|
|
}
|
|
|
}
|