|
@@ -18,7 +18,7 @@ using static OASystem.Domain.Dtos.CRM.NewClientDataQueryDto;
|
|
|
|
|
|
namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
{
|
|
|
- public class NewClientDataRepository : BaseRepository<Crm_NewClientData, Crm_NewClientData>
|
|
|
+ public class NewClientDataRepository : BaseRepository<Crm_NewClientData, NewClientDataView>
|
|
|
{
|
|
|
private readonly IMapper _mapper;
|
|
|
public NewClientDataRepository(SqlSugarClient sqlSugar, IMapper mapper) :
|
|
@@ -192,7 +192,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- var RangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x=>x.Id).ToList();
|
|
|
+ var RangeSetDataList = _sqlSugar.SqlQueryable<Sys_SetData>(setDataSql).Select(x => x.Id).ToList();
|
|
|
string lvlds = string.Join(',', RangeSetDataList).TrimEnd(',');
|
|
|
if (!string.IsNullOrEmpty(lvlds))
|
|
|
{
|
|
@@ -308,11 +308,11 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
foreach (var item in NewClientDataView)
|
|
|
{
|
|
|
List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
|
- ("select u1.UsersId,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + item.Id + "").ToListAsync();
|
|
|
+ ("select u1.UsersId,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;
|
|
|
|
|
|
List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
|
|
|
- ("select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + item.Id + "").ToListAsync();
|
|
|
+ ("select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + item.Id + " AND d1.ISDEL = 0").ToListAsync();
|
|
|
item.AscribedDepartment = AscribedDepartment;
|
|
|
}
|
|
|
|
|
@@ -481,5 +481,107 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取下拉列表数据和单条数据信息
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dto"></param>
|
|
|
+ public async Task<Result> QuerySelectAndSingleData(QuerySingleDto dto)
|
|
|
+ {
|
|
|
+ Result rest = new Result();
|
|
|
+ var QueryData = await GetAsync<Crm_NewClientData>(x => x.Id == dto.Id);
|
|
|
+ NewClientDataView MapQueryData = null;
|
|
|
+ if (QueryData != null)
|
|
|
+ {
|
|
|
+ MapQueryData = _mapper.Map<NewClientDataView>(QueryData);
|
|
|
+ MapQueryData.AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
|
+ ("select u1.UsersId,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + dto.Id + " and u1.isdel = 0").ToListAsync();
|
|
|
+
|
|
|
+ MapQueryData.AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
|
|
|
+ ("select d1.*,d2.Name from Crm_ClientDataAndBusiness d1,Sys_SetData d2 where d1.SetDataId=d2.Id and NewClientDataId=" + dto.Id + " and d1.isdel = 0").ToListAsync();
|
|
|
+ }
|
|
|
+
|
|
|
+ #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<dynamic> _Province = new List<dynamic>();
|
|
|
+ List<Sys_SetData> province = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .Where(u => u.STid == 42 && u.IsDel == 0).ToList();
|
|
|
+ foreach (Sys_SetData item in province)
|
|
|
+ {
|
|
|
+ var data = new
|
|
|
+ {
|
|
|
+ Id = item.Id,
|
|
|
+ Name = item.Name
|
|
|
+ };
|
|
|
+ _Province.Add(data);
|
|
|
+ };
|
|
|
+ //客户级别数据
|
|
|
+ List<dynamic> _level = new List<dynamic>();
|
|
|
+ List<Sys_SetData> level = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .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 = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .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 = _sqlSugar.Queryable<Sys_SetData>()
|
|
|
+ .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);
|
|
|
+ };
|
|
|
+ #endregion
|
|
|
+
|
|
|
+ rest.Code = 0;
|
|
|
+ rest.Data = new
|
|
|
+ {
|
|
|
+ data = MapQueryData,
|
|
|
+ Users = _Users,
|
|
|
+ Province = _Province,
|
|
|
+ level = _level,
|
|
|
+ CustomerClass = _CustomerClass,
|
|
|
+ ServiceClass = _ServiceClass,
|
|
|
+ };
|
|
|
+ rest.Msg = "获取成功!";
|
|
|
+ return rest;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|