|
@@ -2,6 +2,7 @@
|
|
using AutoMapper.Execution;
|
|
using AutoMapper.Execution;
|
|
using EyeSoft.Extensions;
|
|
using EyeSoft.Extensions;
|
|
using MySqlX.XDevAPI.Relational;
|
|
using MySqlX.XDevAPI.Relational;
|
|
|
|
+using Newtonsoft.Json;
|
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
using NPOI.OpenXmlFormats.Dml.Diagram;
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.SS.Formula.Functions;
|
|
using NPOI.SS.UserModel;
|
|
using NPOI.SS.UserModel;
|
|
@@ -13,6 +14,7 @@ using OASystem.Domain.Entities.Customer;
|
|
using OASystem.Domain.Entities.Resource;
|
|
using OASystem.Domain.Entities.Resource;
|
|
using OASystem.Domain.Enums;
|
|
using OASystem.Domain.Enums;
|
|
using OASystem.Domain.ViewModels.CRM;
|
|
using OASystem.Domain.ViewModels.CRM;
|
|
|
|
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
|
|
using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
using OASystem.Domain.ViewModels.QiYeWeChat;
|
|
using SqlSugar;
|
|
using SqlSugar;
|
|
using System;
|
|
using System;
|
|
@@ -178,8 +180,10 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
string infoSql = string.Format(@" Select * From Crm_NewClientData Where Isdel = 0 And Id = {0}", id);
|
|
string infoSql = string.Format(@" Select * From Crm_NewClientData Where Isdel = 0 And Id = {0}", id);
|
|
var info = await _sqlSugar.SqlQueryable<DetailsView>(infoSql).FirstAsync();
|
|
var info = await _sqlSugar.SqlQueryable<DetailsView>(infoSql).FirstAsync();
|
|
- if (info != null )
|
|
|
|
|
|
+ if (info != null)
|
|
{
|
|
{
|
|
|
|
+ EncryptionProcessor.DecryptProperties(info);
|
|
|
|
+
|
|
List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
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=" + info.Id + " AND u1.ISDEL = 0").ToListAsync();
|
|
("select u1.UsersId as UserId ,u2.CnName,u1.NewClientDataId from Crm_ClientDataAndUser u1,Sys_Users u2 where u1.UsersId=u2.Id and NewClientDataId=" + info.Id + " AND u1.ISDEL = 0").ToListAsync();
|
|
info.AscribedUser = AscribedUser.Select(it => it.UserId).ToList();
|
|
info.AscribedUser = AscribedUser.Select(it => it.UserId).ToList();
|
|
@@ -192,10 +196,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
result.Data = info;
|
|
result.Data = info;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else
|
|
|
|
- {
|
|
|
|
- result.Msg = string.Format("请传入有效的PortType参数!");
|
|
|
|
- }
|
|
|
|
|
|
+ else result.Msg = MsgTips.Port;
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -289,53 +290,25 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
}
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
- foreach (var item in intList)
|
|
|
|
- {
|
|
|
|
- NewClientDataId += item + ",";
|
|
|
|
- }
|
|
|
|
- if (!string.IsNullOrWhiteSpace(NewClientDataId))
|
|
|
|
- {
|
|
|
|
- NewClientDataId = NewClientDataId.Substring(0, NewClientDataId.Length - 1);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- var clientDatas = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
|
-
|
|
|
|
- string contact = dto.Contact,location = dto.Location,clientDto = dto.Client;
|
|
|
|
-
|
|
|
|
- //aes 解密
|
|
|
|
-
|
|
|
|
|
|
+ //foreach (var item in intList)
|
|
|
|
+ //{
|
|
|
|
+ // NewClientDataId += item + ",";
|
|
|
|
+ //}
|
|
|
|
+ //if (!string.IsNullOrWhiteSpace(NewClientDataId))
|
|
|
|
+ //{
|
|
|
|
+ // NewClientDataId = NewClientDataId.Substring(0, NewClientDataId.Length - 1);
|
|
|
|
+ //}
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
Stopwatch stopwatch = Stopwatch.StartNew();
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(contact) || !string.IsNullOrEmpty(location) || !string.IsNullOrEmpty(clientDto))
|
|
|
|
- {
|
|
|
|
- foreach (var client in clientDatas)
|
|
|
|
- {
|
|
|
|
- if (!string.IsNullOrEmpty(contact)) client.Contact = AesEncryptionHelper.Decrypt(client.Contact);
|
|
|
|
- if (!string.IsNullOrEmpty(location)) client.Location = AesEncryptionHelper.Decrypt(client.Location);
|
|
|
|
- if (!string.IsNullOrEmpty(clientDto)) client.Client = AesEncryptionHelper.Decrypt(client.Client);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- stopwatch.Stop();
|
|
|
|
- string sqlWhere = string.Empty;
|
|
|
|
|
|
+ //var clientDatas = await NewClientDataRedis(1);
|
|
|
|
|
|
- if (dto.PortType == 1)
|
|
|
|
- {
|
|
|
|
- clientDatas = clientDatas
|
|
|
|
- .WhereIF(!string.IsNullOrEmpty(contact), x => !string.IsNullOrEmpty(x.Contact) && x.Contact.Contains(contact)) //联系人条件
|
|
|
|
- .WhereIF(!string.IsNullOrEmpty(location), x => !string.IsNullOrEmpty(x.Location) && x.Location.Contains(location)) //地区条件
|
|
|
|
- .WhereIF(!string.IsNullOrEmpty(clientDto), x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains(clientDto)) //单位条件
|
|
|
|
- .ToList();
|
|
|
|
|
|
|
|
- }
|
|
|
|
- else if (dto.PortType == 2 || dto.PortType == 3)
|
|
|
|
- {
|
|
|
|
- clientDatas = clientDatas.Where(x => x.Contact.Contains(clientDto) || x.Location.Contains(clientDto) || x.Client.Contains(clientDto)).ToList();
|
|
|
|
- }
|
|
|
|
|
|
+ var clientDatas = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
if (state == -1)
|
|
if (state == -1)
|
|
{
|
|
{
|
|
- //intList
|
|
|
|
-
|
|
|
|
clientDatas = clientDatas.WhereIF(intList.Count > 0, x => intList.Contains(x.Id)).ToList();
|
|
clientDatas = clientDatas.WhereIF(intList.Count > 0, x => intList.Contains(x.Id)).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -395,6 +368,34 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
clientDatas = clientDatas.WhereIF(dto.Category > 0, x => x.Category == dto.Category).ToList();
|
|
clientDatas = clientDatas.WhereIF(dto.Category > 0, x => x.Category == dto.Category).ToList();
|
|
#endregion
|
|
#endregion
|
|
|
|
|
|
|
|
+ string contact = dto.Contact,location = dto.Location,clientDto = dto.Client;
|
|
|
|
+
|
|
|
|
+ if (!string.IsNullOrEmpty(contact) || !string.IsNullOrEmpty(location) || !string.IsNullOrEmpty(clientDto))
|
|
|
|
+ {
|
|
|
|
+ foreach (var data in clientDatas)
|
|
|
|
+ {
|
|
|
|
+ //EncryptionProcessor.DecryptProperties(data);
|
|
|
|
+ if (!string.IsNullOrEmpty(contact)) data.Contact = AesEncryptionHelper.Decrypt(data.Contact);
|
|
|
|
+ if (!string.IsNullOrEmpty(location)) data.Location = AesEncryptionHelper.Decrypt(data.Location);
|
|
|
|
+ if (!string.IsNullOrEmpty(clientDto)) data.Client = AesEncryptionHelper.Decrypt(data.Client);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (dto.PortType == 1)
|
|
|
|
+ {
|
|
|
|
+ clientDatas = clientDatas
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(contact), x => !string.IsNullOrEmpty(x.Contact) && x.Contact.Contains(contact)) //联系人条件
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(location), x => !string.IsNullOrEmpty(x.Location) && x.Location.Contains(location)) //地区条件
|
|
|
|
+ .WhereIF(!string.IsNullOrEmpty(clientDto), x => !string.IsNullOrEmpty(x.Client) && x.Client.Contains(clientDto)) //单位条件
|
|
|
|
+ .ToList();
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (dto.PortType == 2 || dto.PortType == 3)
|
|
|
|
+ {
|
|
|
|
+ clientDatas = clientDatas.Where(x => x.Contact.Contains(clientDto) || x.Location.Contains(clientDto) || x.Client.Contains(clientDto)).ToList();
|
|
|
|
+ }
|
|
|
|
+
|
|
int pIndex = dto.PageIndex * dto.PageSize - dto.PageSize + 1;
|
|
int pIndex = dto.PageIndex * dto.PageSize - dto.PageSize + 1;
|
|
int pSize = dto.PageIndex * dto.PageSize;
|
|
int pSize = dto.PageIndex * dto.PageSize;
|
|
int skip = (dto.PageIndex - 1) * dto.PageSize;
|
|
int skip = (dto.PageIndex - 1) * dto.PageSize;
|
|
@@ -403,23 +404,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
var NewClientDataView = _mapper.Map<List<NewClientDataView>>(pageData);
|
|
var NewClientDataView = _mapper.Map<List<NewClientDataView>>(pageData);
|
|
var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
|
|
var setDatas = _sqlSugar.Queryable<Sys_SetData>().Where(x => x.IsDel == 0).ToList();
|
|
- int index = 1;
|
|
|
|
- foreach (var item in NewClientDataView)
|
|
|
|
- {
|
|
|
|
- item.RowNumber = index;
|
|
|
|
- item.CategoryStr = setDatas.Find(x => x.Id == item.Category)?.Name ?? "-";
|
|
|
|
- item.LvlidStr = setDatas.Find(x => x.Id == item.Lvlid)?.Name ?? "-";
|
|
|
|
- item.Weight = AesEncryptionHelper.Decrypt(item.Weight);
|
|
|
|
- item.Job = AesEncryptionHelper.Decrypt(item.Job);
|
|
|
|
- item.Telephone = AesEncryptionHelper.Decrypt(item.Telephone);
|
|
|
|
- item.Phone = AesEncryptionHelper.Decrypt(item.Phone);
|
|
|
|
- item.Remark = AesEncryptionHelper.Decrypt(item.Remark);
|
|
|
|
- if (string.IsNullOrEmpty(contact)) item.Contact = AesEncryptionHelper.Decrypt(item.Contact);
|
|
|
|
- if (string.IsNullOrEmpty(location)) item.Location = AesEncryptionHelper.Decrypt(item.Location);
|
|
|
|
- if (string.IsNullOrEmpty(clientDto)) item.Client = AesEncryptionHelper.Decrypt(item.Client);
|
|
|
|
-
|
|
|
|
- index++;
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
#region 下拉框初始化数据
|
|
#region 下拉框初始化数据
|
|
//负责人下拉框
|
|
//负责人下拉框
|
|
@@ -439,7 +424,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
var groupNumber = await QueryNumberGroups();
|
|
var groupNumber = await QueryNumberGroups();
|
|
-
|
|
|
|
|
|
+ stopwatch.Stop();
|
|
if (NewClientDataView.Count > 0)
|
|
if (NewClientDataView.Count > 0)
|
|
{
|
|
{
|
|
int count = clientDatas.Count;
|
|
int count = clientDatas.Count;
|
|
@@ -449,8 +434,27 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
if (dto.PortType == 1)
|
|
if (dto.PortType == 1)
|
|
{
|
|
{
|
|
|
|
+ int index = 1;
|
|
foreach (var item in NewClientDataView)
|
|
foreach (var item in NewClientDataView)
|
|
{
|
|
{
|
|
|
|
+ //EncryptionProcessor.DecryptProperties(item);
|
|
|
|
+
|
|
|
|
+ if (string.IsNullOrEmpty(contact)) item.Contact = AesEncryptionHelper.Decrypt(item.Contact);
|
|
|
|
+ if (string.IsNullOrEmpty(location)) item.Location = AesEncryptionHelper.Decrypt(item.Location);
|
|
|
|
+ if (string.IsNullOrEmpty(clientDto)) item.Client = AesEncryptionHelper.Decrypt(item.Client);
|
|
|
|
+
|
|
|
|
+ item.Wechat = AesEncryptionHelper.Decrypt(item.Wechat);
|
|
|
|
+ item.Job = AesEncryptionHelper.Decrypt(item.Job);
|
|
|
|
+ item.Telephone = AesEncryptionHelper.Decrypt(item.Telephone);
|
|
|
|
+ item.Phone = AesEncryptionHelper.Decrypt(item.Phone);
|
|
|
|
+ item.Remark = AesEncryptionHelper.Decrypt(item.Remark);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ item.RowNumber = index;
|
|
|
|
+ item.CategoryStr = setDatas.Find(x => x.Id == item.Category)?.Name ?? "-";
|
|
|
|
+ item.LvlidStr = setDatas.Find(x => x.Id == item.Lvlid)?.Name ?? "-";
|
|
|
|
+
|
|
List<AscribedUser> AscribedUser = await _sqlSugar.SqlQueryable<AscribedUser>
|
|
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();
|
|
("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;
|
|
item.AscribedUser = AscribedUser;
|
|
@@ -458,6 +462,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
List<AscribedDepartment> AscribedDepartment = await _sqlSugar.SqlQueryable<AscribedDepartment>
|
|
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();
|
|
("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;
|
|
item.AscribedDepartment = AscribedDepartment;
|
|
|
|
+ index++;
|
|
}
|
|
}
|
|
|
|
|
|
var Data = new
|
|
var Data = new
|
|
@@ -482,12 +487,24 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
{
|
|
{
|
|
|
|
|
|
List<NewClientDataAndroidIOSView> newClientDataIOSViews = new List<NewClientDataAndroidIOSView>();
|
|
List<NewClientDataAndroidIOSView> newClientDataIOSViews = new List<NewClientDataAndroidIOSView>();
|
|
|
|
+
|
|
|
|
+ int index = 1;
|
|
foreach (var item in NewClientDataView)
|
|
foreach (var item in NewClientDataView)
|
|
{
|
|
{
|
|
|
|
+ //newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
|
|
+ //{
|
|
|
|
+ // RowNumber = index,
|
|
|
|
+ // Id = item.Id,
|
|
|
|
+ // Client = AesEncryptionHelper.Decrypt( item.Client),
|
|
|
|
+ // Contact = AesEncryptionHelper.Decrypt(item.Contact),
|
|
|
|
+ // Job = AesEncryptionHelper.Decrypt(item.Job),
|
|
|
|
+ // Telephone = AesEncryptionHelper.Decrypt(item.Telephone),
|
|
|
|
+ // Location = AesEncryptionHelper.Decrypt(item.Location),
|
|
|
|
+ //});
|
|
|
|
|
|
newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
newClientDataIOSViews.Add(new NewClientDataAndroidIOSView()
|
|
{
|
|
{
|
|
- RowNumber = item.RowNumber,
|
|
|
|
|
|
+ RowNumber = index,
|
|
Id = item.Id,
|
|
Id = item.Id,
|
|
Client = item.Client,
|
|
Client = item.Client,
|
|
Contact = item.Contact,
|
|
Contact = item.Contact,
|
|
@@ -495,6 +512,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
Telephone = item.Telephone,
|
|
Telephone = item.Telephone,
|
|
Location = item.Location,
|
|
Location = item.Location,
|
|
});
|
|
});
|
|
|
|
+ index++;
|
|
}
|
|
}
|
|
|
|
|
|
result = new Result()
|
|
result = new Result()
|
|
@@ -517,7 +535,6 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
{
|
|
{
|
|
var Data = new
|
|
var Data = new
|
|
{
|
|
{
|
|
-
|
|
|
|
ClientTableData = new { pageCount = 0, totalPage = 0, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = NewClientDataView },
|
|
ClientTableData = new { pageCount = 0, totalPage = 0, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = NewClientDataView },
|
|
Users = _Users,
|
|
Users = _Users,
|
|
Province = _Province,
|
|
Province = _Province,
|
|
@@ -528,7 +545,6 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
};
|
|
};
|
|
result = new Result() { Code = 0, Msg = "获取成功!", Data = Data };
|
|
result = new Result() { Code = 0, Msg = "获取成功!", Data = Data };
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -539,7 +555,6 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 客户资料初识初始化
|
|
/// 客户资料初识初始化
|
|
/// </summary>
|
|
/// </summary>
|
|
@@ -976,41 +991,42 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
BirthdayStr = isParse ? Birthday.ToString("yyyy-MM-dd") : "";
|
|
BirthdayStr = isParse ? Birthday.ToString("yyyy-MM-dd") : "";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (string.IsNullOrWhiteSpace(dto.PassportDate))
|
|
|
|
+ {
|
|
|
|
+ dto.PassportDate = null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ var newClientDataUnEncrypted = _mapper.Map<Crm_NewClientData>(dto);
|
|
|
|
+ newClientDataUnEncrypted.Birthday = BirthdayStr;
|
|
|
|
+
|
|
|
|
+ var newClientDataEncrypted = newClientDataUnEncrypted;
|
|
|
|
+ EncryptionProcessor.EncryptProperties(newClientDataEncrypted); //加密
|
|
|
|
+
|
|
try
|
|
try
|
|
{
|
|
{
|
|
BeginTran();
|
|
BeginTran();
|
|
if (dto.Status == 1)//添加
|
|
if (dto.Status == 1)//添加
|
|
{
|
|
{
|
|
string selectSql = string.Format(@"select * from Crm_NewClientData where Client='{0}' And Contact='{1}' And IsDel={2}"
|
|
string selectSql = string.Format(@"select * from Crm_NewClientData where Client='{0}' And Contact='{1}' And IsDel={2}"
|
|
- , dto.Client, dto.Contact, 0);
|
|
|
|
|
|
+ , newClientDataEncrypted.Client, newClientDataEncrypted.Contact, 0);
|
|
var NewClientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(selectSql).FirstAsync();//查询是否存在
|
|
var NewClientData = await _sqlSugar.SqlQueryable<Crm_NewClientData>(selectSql).FirstAsync();//查询是否存在
|
|
- if (NewClientData == null)
|
|
|
|
|
|
+ if (NewClientData != null)
|
|
{
|
|
{
|
|
- if (string.IsNullOrWhiteSpace(dto.PassportDate))
|
|
|
|
- {
|
|
|
|
- dto.PassportDate = null;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Crm_NewClientData _NewClientData = _mapper.Map<Crm_NewClientData>(dto);
|
|
|
|
- _NewClientData.Birthday = BirthdayStr;
|
|
|
|
|
|
+ result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
|
+ }
|
|
|
|
|
|
- int id = await AddAsyncReturnId(_NewClientData); //添加市场客户资料表数据
|
|
|
|
|
|
+ int id = await AddAsyncReturnId(newClientDataEncrypted); //添加市场客户资料表数据
|
|
|
|
|
|
- if (id == 0)
|
|
|
|
- {
|
|
|
|
- result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- result = new Result() { Code = 0, Msg = "添加成功!",Data = id };
|
|
|
|
- istrue = true;
|
|
|
|
- AddReturnId = id;
|
|
|
|
- CommitTran();
|
|
|
|
- }
|
|
|
|
|
|
+ if (id == 0)
|
|
|
|
+ {
|
|
|
|
+ result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!", Data = id };
|
|
|
|
+ istrue = true;
|
|
|
|
+ AddReturnId = id;
|
|
|
|
+ newClientDataUnEncrypted.Id = id;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
@@ -1026,32 +1042,9 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
PassportDate = null;
|
|
PassportDate = null;
|
|
}
|
|
}
|
|
|
|
|
|
- bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Crm_NewClientData
|
|
|
|
- {
|
|
|
|
- Number = dto.Number,
|
|
|
|
- Lvlid = dto.Lvlid,
|
|
|
|
- Client = dto.Client,
|
|
|
|
- Weight = dto.Weight,
|
|
|
|
- ClientShort = dto.Clientshort,
|
|
|
|
- Contact = dto.Contact,
|
|
|
|
- Gender = dto.Gender,
|
|
|
|
- Passport = dto.Passport,
|
|
|
|
- PassportDate = PassportDate,
|
|
|
|
- Job = dto.Job,
|
|
|
|
- Telephone = dto.Telephone,
|
|
|
|
- Phone = dto.Phone,
|
|
|
|
- Email = dto.Email,
|
|
|
|
- Location = dto.Location,
|
|
|
|
- Address = dto.Address,
|
|
|
|
- Birthday = BirthdayStr,
|
|
|
|
- OtherInfo = dto.Otherinfo,
|
|
|
|
- Wechat = dto.Wechat,
|
|
|
|
- Category = dto.Category,
|
|
|
|
- PreDele = dto.Predele,
|
|
|
|
- FinlishedDele = dto.FinlishedDele,
|
|
|
|
- Remark = dto.Remark,
|
|
|
|
- });
|
|
|
|
- if (res)
|
|
|
|
|
|
+ var res = await _sqlSugar.Updateable(newClientDataEncrypted).IgnoreColumns(x => new { x.DeleteTime, x.DeleteUserId, x.CreateTime, x.CreateUserId }).ExecuteCommandAsync();
|
|
|
|
+
|
|
|
|
+ if (res > 0)
|
|
{
|
|
{
|
|
istrue = true;
|
|
istrue = true;
|
|
AddReturnId = dto.Id == 0 ? -1 : dto.Id;
|
|
AddReturnId = dto.Id == 0 ? -1 : dto.Id;
|
|
@@ -1069,7 +1062,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
}).ExecuteCommandAsync();
|
|
}).ExecuteCommandAsync();
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ newClientDataUnEncrypted.Id = AddReturnId;
|
|
result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -1103,6 +1096,15 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
}).ToList());
|
|
}).ToList());
|
|
|
|
|
|
CommitTran();
|
|
CommitTran();
|
|
|
|
+
|
|
|
|
+ ////缓存添加信息
|
|
|
|
+ //var optype = 0;
|
|
|
|
+ //if (dto.Status == 1) optype = 3;
|
|
|
|
+ //else if (dto.Status == 2) optype = 4;
|
|
|
|
+
|
|
|
|
+ ////操作缓存(未加密数据)
|
|
|
|
+ //await NewClientDataRedis(optype, newClientDataUnEncrypted);
|
|
|
|
+
|
|
result.Data = AddReturnId;
|
|
result.Data = AddReturnId;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -1145,7 +1147,9 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
public async Task<Result> QuerySelectAndSingleData(QuerySingleDto dto)
|
|
public async Task<Result> QuerySelectAndSingleData(QuerySingleDto dto)
|
|
{
|
|
{
|
|
Result rest = new Result();
|
|
Result rest = new Result();
|
|
- var QueryData = await GetAsync<Crm_NewClientData>(x => x.Id == dto.Id);
|
|
|
|
|
|
+ //var QueryData1 = await NewClientDataRedis(2, new Crm_NewClientData() { Id = dto.Id });
|
|
|
|
+ //var QueryData = QueryData1.FirstOrDefault();
|
|
|
|
+ var QueryData = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0 && x.Id == dto.Id).FirstAsync();
|
|
NewClientDataView MapQueryData = null;
|
|
NewClientDataView MapQueryData = null;
|
|
if (QueryData != null)
|
|
if (QueryData != null)
|
|
{
|
|
{
|
|
@@ -1248,6 +1252,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
sql = $" update Crm_ClientDataAndBusiness set {sqlSet} where NewClientDataId = {dto.Id} ";
|
|
sql = $" update Crm_ClientDataAndBusiness set {sqlSet} where NewClientDataId = {dto.Id} ";
|
|
await ExecuteCommandAsync(sql);
|
|
await ExecuteCommandAsync(sql);
|
|
CommitTran();
|
|
CommitTran();
|
|
|
|
+ //await NewClientDataRedis(5, new Crm_NewClientData() { Id = dto.Id });
|
|
AcrionResult.Code = 0;
|
|
AcrionResult.Code = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1376,5 +1381,58 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
return userArr;
|
|
return userArr;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /// <summary>
|
|
|
|
+ /// 公司客户名单 缓存
|
|
|
|
+ /// </summary>
|
|
|
|
+ /// <param name="opType">操作类型 1 获取全部 2 单条详情 3 添加 4 修改 5 删除</param>
|
|
|
|
+ /// <param name="data"></param>
|
|
|
|
+ /// <returns></returns>
|
|
|
|
+ public async Task<List<Crm_NewClientData>> NewClientDataRedis(int opType, Crm_NewClientData data = null)
|
|
|
|
+ {
|
|
|
|
+ var datas = new List<Crm_NewClientData>();
|
|
|
|
+ var opTypes = new List<int>() { 1, 2, 3, 4 };
|
|
|
|
+ if (!opTypes.Any(x => x == opType)) return datas;
|
|
|
|
+
|
|
|
|
+ var keyName = $"newClientDataStr";
|
|
|
|
+ var newClientJson = await RedisRepository.RedisFactory.CreateRedisRepository().StringGetAsync<string>(keyName);//string 取
|
|
|
|
+ if (!string.IsNullOrEmpty(newClientJson)) datas = JsonConvert.DeserializeObject<List<Crm_NewClientData>>(newClientJson);
|
|
|
|
+ if (opType == 1) //查询全部
|
|
|
|
+ {
|
|
|
|
+ if (datas != null && datas.Count > 0) return datas;
|
|
|
|
+
|
|
|
|
+ datas = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
|
+ foreach (var item in datas) EncryptionProcessor.DecryptProperties(item);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else if (opType == 2) //单条数据
|
|
|
|
+ {
|
|
|
|
+ if (datas != null && datas.Count > 0) return datas.Where(x => x.Id == data.Id).ToList();
|
|
|
|
+
|
|
|
|
+ datas = await _sqlSugar.Queryable<Crm_NewClientData>().Where(x => x.IsDel == 0).ToListAsync();
|
|
|
|
+ foreach (var item in datas) EncryptionProcessor.DecryptProperties(item);
|
|
|
|
+ await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync(keyName, JsonConvert.SerializeObject(datas));//string 存
|
|
|
|
+ return datas.Where(x => x.Id == data.Id).ToList();
|
|
|
|
+ }
|
|
|
|
+ else if (opType == 3) //添加
|
|
|
|
+ {
|
|
|
|
+ datas.Add(data);
|
|
|
|
+ }
|
|
|
|
+ else if (opType == 4) //修改
|
|
|
|
+ {
|
|
|
|
+ var updData = datas.Where(x => x.Id != data.Id).FirstOrDefault();
|
|
|
|
+ if (updData != null) datas.Remove(updData);
|
|
|
|
+ datas.Add(data);
|
|
|
|
+ }
|
|
|
|
+ else if (opType == 5) //删除
|
|
|
|
+ {
|
|
|
|
+ var delData = datas.Where(x => x.Id == data.Id).FirstOrDefault();
|
|
|
|
+ if (delData != null) datas.Remove(delData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ await RedisRepository.RedisFactory.CreateRedisRepository().StringSetAsync(keyName, JsonConvert.SerializeObject(datas));//string 存
|
|
|
|
+
|
|
|
|
+ return datas;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|