|
@@ -1,5 +1,6 @@
|
|
|
|
|
|
using AutoMapper;
|
|
|
+using Newtonsoft.Json;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos;
|
|
|
using OASystem.Domain.Dtos.CRM;
|
|
@@ -26,7 +27,8 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
public VisaDeleClientRepository(SqlSugarClient sqlSugar,IMapper mapper) :
|
|
|
base(sqlSugar)
|
|
|
{
|
|
|
- _mapper = mapper;
|
|
|
+ this._mapper = mapper;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -151,6 +153,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
try
|
|
|
{
|
|
|
+ int deleId = 0;
|
|
|
if (dto.Status==1)//添加
|
|
|
{
|
|
|
string selectSql = string.Format(@"select * from Crm_DeleClient where LastName+FirstName='{0}' and Phone='{1}' and IsDel='{2}'"
|
|
@@ -158,7 +161,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
var DeleClient = await _sqlSugar.SqlQueryable<Crm_DeleClient>(selectSql).FirstAsync();//查询是否存在
|
|
|
if (DeleClient != null)
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "该客户已存在,请勿重复添加!" };
|
|
|
+ result = new Result() { Code = -1, Msg = "该客户已存在,请勿重复添加!" };
|
|
|
|
|
|
}
|
|
|
else//不存在,可添加
|
|
@@ -167,16 +170,17 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
int id = await AddAsyncReturnId(_CountryFeeCost);
|
|
|
if (id == 0)
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+ result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
- //进行其他表炒作
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!" };
|
|
|
+ deleId = id;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
else if (dto.Status == 2)//修改
|
|
|
{
|
|
|
+ deleId=dto.DeleClient.Id;
|
|
|
bool res = await UpdateAsync(a => a.Id == dto.DeleClient.Id, a => new Crm_DeleClient
|
|
|
{
|
|
|
LastName = dto.DeleClient.LastName,
|
|
@@ -272,23 +276,75 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
});
|
|
|
if (!res)
|
|
|
{
|
|
|
- return result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
+ result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
}
|
|
|
- foreach (var item in dto.CustomerFamily)
|
|
|
+ result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
+
|
|
|
+ }
|
|
|
+ //进行其他表炒作
|
|
|
+ if (result.Code == 0)
|
|
|
+ {//家庭成员信息
|
|
|
+ foreach (CustomerFamily item in dto.CustomerFamily)
|
|
|
{
|
|
|
- if (item.Id!=0)//修改
|
|
|
+ Crm_VisaCustomerFamily Crm_VisaCustomerFamily = _mapper.Map<Crm_VisaCustomerFamily>(item);
|
|
|
+ Crm_VisaCustomerFamily.DcId = deleId;
|
|
|
+ if (item.Id != 0)//修改
|
|
|
{
|
|
|
+ int res = await _sqlSugar.Updateable<Crm_VisaCustomerFamily>().Where(a => a.Id == Crm_VisaCustomerFamily.Id).SetColumns(a => new Crm_VisaCustomerFamily
|
|
|
+ {
|
|
|
+ Appellation = Crm_VisaCustomerFamily.Appellation,
|
|
|
+ Name = Crm_VisaCustomerFamily.Name,
|
|
|
+ BirthDay = Crm_VisaCustomerFamily.BirthDay,
|
|
|
+ BirthPlace = Crm_VisaCustomerFamily.BirthPlace,
|
|
|
+ Politics = Crm_VisaCustomerFamily.Politics,
|
|
|
+ Client = Crm_VisaCustomerFamily.Client,
|
|
|
+ Address = Crm_VisaCustomerFamily.Address,
|
|
|
+ IsEu = Crm_VisaCustomerFamily.IsEu,
|
|
|
+ NameSnd = Crm_VisaCustomerFamily.NameSnd,
|
|
|
+ BirthDaySnd = Crm_VisaCustomerFamily.BirthDaySnd,
|
|
|
+ Nationality = Crm_VisaCustomerFamily.Nationality,
|
|
|
+ IDCard = Crm_VisaCustomerFamily.IDCard,
|
|
|
+ Reletionship = Crm_VisaCustomerFamily.Reletionship,
|
|
|
+ IsUSA = Crm_VisaCustomerFamily.IsUSA,
|
|
|
+ Remark = Crm_VisaCustomerFamily.Remark,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ }
|
|
|
+ else if (item.Id == 0)//添加
|
|
|
+ {
|
|
|
+ int sss= await _sqlSugar.Insertable(Crm_VisaCustomerFamily).ExecuteReturnIdentityAsync();
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //证件表信息
|
|
|
+ foreach (CustomerCerts item in dto.CustomerCert)
|
|
|
+ {
|
|
|
+ Crm_CustomerCert CustomerCert = _mapper.Map<Crm_CustomerCert>(item);
|
|
|
+ CustomerCert.DcId = deleId;
|
|
|
+ if (item.Id != 0)//修改
|
|
|
+ {
|
|
|
+ int res = await _sqlSugar.Updateable<Crm_CustomerCert>().Where(a => a.Id == CustomerCert.Id).SetColumns(a => new Crm_CustomerCert
|
|
|
+ {
|
|
|
+ DcId=CustomerCert.DcId,
|
|
|
+ SdId = CustomerCert.DcId,
|
|
|
+ CertNo = CustomerCert.CertNo,
|
|
|
+ Country = CustomerCert.Country,
|
|
|
+ Area = CustomerCert.Area,
|
|
|
+ TargetCountry = CustomerCert.TargetCountry,
|
|
|
+ IssueDt = CustomerCert.IssueDt,
|
|
|
+ ExpiryDt = CustomerCert.ExpiryDt,
|
|
|
+ IDCardAddress = CustomerCert.IDCardAddress,
|
|
|
+ CreateUserId = CustomerCert.CreateUserId,
|
|
|
+ Remark = CustomerCert.Remark,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
}
|
|
|
- else//添加
|
|
|
+ else if (item.Id == 0)//添加
|
|
|
{
|
|
|
-
|
|
|
+ int sss = await _sqlSugar.Insertable(CustomerCert).ExecuteReturnIdentityAsync();
|
|
|
}
|
|
|
}
|
|
|
- return result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
- //进行其他表操作
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|