|
@@ -1,11 +1,13 @@
|
|
|
using AutoMapper;
|
|
|
using OASystem.Domain;
|
|
|
+using OASystem.Domain.Dtos.CRM;
|
|
|
using OASystem.Domain.Dtos.Groups;
|
|
|
using OASystem.Domain.Entities.Customer;
|
|
|
using OASystem.Domain.Entities.Groups;
|
|
|
using OASystem.Domain.ViewModels.Groups;
|
|
|
using OASystem.Infrastructure.Tools;
|
|
|
using Org.BouncyCastle.Utilities.Encoders;
|
|
|
+using StackExchange.Redis;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Globalization;
|
|
@@ -175,7 +177,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return _result;
|
|
|
}
|
|
|
|
|
|
- if (dto.Id < 0)
|
|
|
+ if (dto.Id >= 0)
|
|
|
{
|
|
|
|
|
|
#region 参数处理
|
|
@@ -191,12 +193,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
Crm_CustomerCompany _CustomerCompany = new Crm_CustomerCompany()
|
|
|
{
|
|
|
CompanyFullName = dto.CompanyFullName,
|
|
|
+ LastedOpUserId = dto.UserId,
|
|
|
CreateUserId = dto.UserId
|
|
|
};
|
|
|
|
|
|
Crm_CustomerCert _CustomerCert = new Crm_CustomerCert()
|
|
|
{
|
|
|
- SdId = 733,
|
|
|
+ SdId = 773,
|
|
|
CertNo = dto.IDCardNo,
|
|
|
CreateUserId = dto.UserId
|
|
|
};
|
|
@@ -314,6 +317,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
|
|
|
|
|
|
|
|
|
+ _CustomerCert.DcId = clientId;
|
|
|
if (clientInfo == null)
|
|
|
{
|
|
|
var certInfo = await _sqlSugar.Queryable<Crm_CustomerCert>().Where(it => it.IsDel == 0 &&
|
|
@@ -339,6 +343,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
).FirstAsync();
|
|
|
if (certInfo == null)
|
|
|
{
|
|
|
+
|
|
|
var certAdd = await _sqlSugar.Insertable(_CustomerCert).ExecuteReturnIdentityAsync();
|
|
|
if (certAdd < 0)
|
|
|
{
|
|
@@ -426,6 +431,190 @@ namespace OASystem.Infrastructure.Repositories.Groups
|
|
|
return _result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public async Task<Result> _AddMultiple(TourClientListAddMultipleDto dto)
|
|
|
+ {
|
|
|
+ if (dto.DiId < 0)
|
|
|
+ {
|
|
|
+ _result.Msg = string.Format(@"请传入有效的团组Id参数!");
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+ List<TourClientListInfo> _TourClientListInfos = dto.TourClientListInfos;
|
|
|
+ if (_TourClientListInfos != null || _TourClientListInfos.Count < 0)
|
|
|
+ {
|
|
|
+ _result.Msg = string.Format(@"接团客户名单信息集合为空,不执行批量添加!");
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Crm_DeleClient> _DeleClients = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+ List<Crm_CustomerCompany> _CustomerCompanies = await _sqlSugar.Queryable<Crm_CustomerCompany>().Where(it => it.IsDel == 0).ToListAsync();
|
|
|
+ List<Crm_CustomerCert> _CustomerCerts = await _sqlSugar.Queryable<Crm_CustomerCert>().Where(it => it.IsDel == 0 && it.SdId == 773).ToListAsync();
|
|
|
+
|
|
|
+ string _Msg = "";
|
|
|
+ int _DiId = dto.DiId;
|
|
|
+ int _UserId = dto.UserId;
|
|
|
+
|
|
|
+ foreach (var item in _TourClientListInfos)
|
|
|
+ {
|
|
|
+ _sqlSugar.BeginTran();
|
|
|
+ int companyId = -1;
|
|
|
+ int clientId = -1;
|
|
|
+ string clientName = string.Format(@"{0}{1}", item.LastName, item.FirstName);
|
|
|
+ Crm_DeleClient _DeleClientInfo = _DeleClients.Where(it => it.LastName.Equals(item.LastName) &&
|
|
|
+ it.FirstName.Equals(item.FirstName) &&
|
|
|
+ it.Phone.Equals(item.Phone)).FirstOrDefault();
|
|
|
+ if (_DeleClientInfo == null)
|
|
|
+ {
|
|
|
+ if (!string.IsNullOrEmpty(item.CompanyFullName))
|
|
|
+ {
|
|
|
+ var companyInfo = _CustomerCompanies.Where(it => it.CompanyFullName.Equals(item.CompanyFullName)).FirstOrDefault();
|
|
|
+ if (companyInfo != null) companyId = companyInfo.Id;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Crm_CustomerCompany _CustomerCompany = new Crm_CustomerCompany()
|
|
|
+ {
|
|
|
+ CompanyFullName = item.CompanyFullName,
|
|
|
+ LastedOpUserId = _UserId,
|
|
|
+ CreateUserId = _UserId
|
|
|
+ };
|
|
|
+
|
|
|
+ var companyAdd = await _sqlSugar.Insertable(_CustomerCompany).ExecuteReturnIdentityAsync();
|
|
|
+ if (companyAdd < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 公司信息添加失败!请前往客户信息确认!\r\n", clientName);
|
|
|
+ }
|
|
|
+ companyId = companyAdd;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ _DeleClientInfo = new Crm_DeleClient()
|
|
|
+ {
|
|
|
+ LastName = item.LastName,
|
|
|
+ FirstName = item.FirstName,
|
|
|
+ CrmCompanyId = companyId,
|
|
|
+ Job = item.Job,
|
|
|
+ Sex = item.Sex,
|
|
|
+ Phone = item.Phone,
|
|
|
+ BirthDay = item.BirthDay,
|
|
|
+ };
|
|
|
+ var clientAdd = await _sqlSugar.Insertable(_DeleClientInfo).ExecuteReturnIdentityAsync();
|
|
|
+ if (clientAdd < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 基本信息添加失败,本条客户名单不添加!请重新添加!\r\n", clientName);
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ clientId = clientAdd;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(item.IDCardNo))
|
|
|
+ {
|
|
|
+ Crm_CustomerCert _CustomerCert = _CustomerCerts.Where(it => it.DcId == clientId && it.CertNo.Equals(item.IDCardNo)).FirstOrDefault();
|
|
|
+ if (_CustomerCert == null)
|
|
|
+ {
|
|
|
+ _CustomerCert = new Crm_CustomerCert()
|
|
|
+ {
|
|
|
+ DcId = clientId,
|
|
|
+ SdId = 773,
|
|
|
+ CertNo = item.IDCardNo,
|
|
|
+ CreateUserId = _UserId,
|
|
|
+ };
|
|
|
+ var customerCertAdd = await _sqlSugar.Insertable(_CustomerCert).ExecuteCommandAsync();
|
|
|
+ if (customerCertAdd < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 身份证信息添加失败!请前往客户信息确认!\r\n", clientName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ clientId = _DeleClientInfo.Id;
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(item.CompanyFullName))
|
|
|
+ {
|
|
|
+ var companyInfo = _CustomerCompanies.Where(it => it.CompanyFullName.Equals(item.CompanyFullName)).FirstOrDefault();
|
|
|
+ if (companyInfo != null) companyId = companyInfo.Id;
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Crm_CustomerCompany _CustomerCompany = new Crm_CustomerCompany()
|
|
|
+ {
|
|
|
+ CompanyFullName = item.CompanyFullName,
|
|
|
+ LastedOpUserId = _UserId,
|
|
|
+ CreateUserId = _UserId
|
|
|
+ };
|
|
|
+
|
|
|
+ var companyAdd = await _sqlSugar.Insertable(_CustomerCompany).ExecuteReturnIdentityAsync();
|
|
|
+ if (companyAdd < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 公司信息添加失败!请前往客户信息确认!\r\n", clientName);
|
|
|
+ }
|
|
|
+ companyId = companyAdd;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Crm_DeleClient _DeleClient = new Crm_DeleClient() {
|
|
|
+ LastName = item.LastName,
|
|
|
+ FirstName = item.FirstName,
|
|
|
+ Sex = item.Sex,
|
|
|
+ Phone = item.Phone,
|
|
|
+ BirthDay = item.BirthDay
|
|
|
+ };
|
|
|
+ var clientEdit = await _sqlSugar.Updateable(_DeleClient).UpdateColumns(it =>
|
|
|
+ new
|
|
|
+ {
|
|
|
+ it.LastName,
|
|
|
+ it.FirstName,
|
|
|
+ it.Sex,
|
|
|
+ it.Phone,
|
|
|
+ it.BirthDay
|
|
|
+ }
|
|
|
+ )
|
|
|
+ .Where(it => it.Id == clientId)
|
|
|
+ .ExecuteCommandAsync();
|
|
|
+ if (clientEdit < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 基本信息修改失败,!请前往客户信息修改!\r\n", clientName);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Grp_TourClientList _TourClientList = new Grp_TourClientList()
|
|
|
+ {
|
|
|
+ DiId = _DiId,
|
|
|
+ ClientId = clientId,
|
|
|
+ ShippingSpaceTypeId = item.ShippingSpaceTypeId,
|
|
|
+ CreateUserId = _UserId
|
|
|
+ };
|
|
|
+ var tourClientAdd = await _sqlSugar.Insertable(_TourClientList).ExecuteReturnIdentityAsync();
|
|
|
+ if (tourClientAdd < 0)
|
|
|
+ {
|
|
|
+ _Msg += string.Format("{0} 接团客户名单添加失败!请检查数据完整性后重新添加!\r\n", clientName);
|
|
|
+ _sqlSugar.RollbackTran();
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ _sqlSugar.CommitTran();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(_Msg)) _result.Msg = _Msg;
|
|
|
+ else _result.Msg = string.Format("操作成功!");
|
|
|
+
|
|
|
+ _result.Code = 0;
|
|
|
+
|
|
|
+ return _result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|