|
@@ -13,6 +13,7 @@ using OASystem.Domain.ViewModels.Groups;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
+using System.Runtime.Intrinsics.X86;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
@@ -46,7 +47,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
From Crm_DeleClient cdc
|
|
|
Left Join Crm_CustomerCompany ccc On cdc.crmCompanyId = ccc.Id
|
|
|
Left Join Crm_CustomerCert crmCard1 On crmCard1.SdId = 773 And cdc.Id = crmCard1.DcId
|
|
|
- Left Join Crm_CustomerCert crmCard2 On crmCard2.SdId = 774 And cdc.Id = crmCard2.DcId ");
|
|
|
+ Left Join Crm_CustomerCert crmCard2 On crmCard2.SdId = 774 And cdc.Id = crmCard2.DcId where cdc.IsDel='0' order By cdc.CreateTime desc");
|
|
|
|
|
|
var clientList = await _sqlSugar.SqlQueryable<VisaDeleClientListView>(sql).ToListAsync();
|
|
|
|
|
@@ -281,7 +282,7 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
|
|
|
}
|
|
|
- //进行其他表炒作
|
|
|
+ //进行其他表
|
|
|
if (result.Code == 0)
|
|
|
{//家庭成员信息
|
|
|
foreach (CustomerFamily item in dto.CustomerFamily)
|
|
@@ -308,10 +309,18 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
IsUSA = Crm_VisaCustomerFamily.IsUSA,
|
|
|
Remark = Crm_VisaCustomerFamily.Remark,
|
|
|
}).ExecuteCommandAsync();
|
|
|
+ if (res==0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "家庭成员信息保存失败!" };
|
|
|
+ }
|
|
|
}
|
|
|
else if (item.Id == 0)//添加
|
|
|
{
|
|
|
int sss= await _sqlSugar.Insertable(Crm_VisaCustomerFamily).ExecuteReturnIdentityAsync();
|
|
|
+ if (sss == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "家庭成员信息保存失败!" };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -336,17 +345,139 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
CreateUserId = CustomerCert.CreateUserId,
|
|
|
Remark = CustomerCert.Remark,
|
|
|
}).ExecuteCommandAsync();
|
|
|
+ if (res == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "证件信息保存失败!" };
|
|
|
+ }
|
|
|
}
|
|
|
else if (item.Id == 0)//添加
|
|
|
{
|
|
|
int sss = await _sqlSugar.Insertable(CustomerCert).ExecuteReturnIdentityAsync();
|
|
|
+ if (sss == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "证件信息保存失败!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //客户工作经历表
|
|
|
+ foreach (VisaCustomerCompany item in dto.WorkExperience)
|
|
|
+ {
|
|
|
+ Crm_VisaCustomerCompany VisaCustomerCompany = _mapper.Map<Crm_VisaCustomerCompany>(item);
|
|
|
+ VisaCustomerCompany.DcId = deleId;
|
|
|
+ if (item.Id != 0)//修改
|
|
|
+ {
|
|
|
+ int res = await _sqlSugar.Updateable<Crm_VisaCustomerCompany>().Where(a => a.Id == VisaCustomerCompany.Id).SetColumns(a => new Crm_VisaCustomerCompany
|
|
|
+ {
|
|
|
+ DcId=VisaCustomerCompany.DcId,
|
|
|
+ Company = VisaCustomerCompany.Company,
|
|
|
+ CompanyAddress = VisaCustomerCompany.CompanyAddress,
|
|
|
+ Phone = VisaCustomerCompany.Phone,
|
|
|
+ Job = VisaCustomerCompany.Job,
|
|
|
+ LeaderName = VisaCustomerCompany.LeaderName,
|
|
|
+ WorkStart = VisaCustomerCompany.WorkStart,
|
|
|
+ WorkEnd = VisaCustomerCompany.WorkEnd,
|
|
|
+ WorkState = VisaCustomerCompany.WorkState,
|
|
|
+ CreateUserId = VisaCustomerCompany.CreateUserId,
|
|
|
+ Remark = VisaCustomerCompany.Remark,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ if (res == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "客户工作经历保存失败!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (item.Id == 0)//添加
|
|
|
+ {
|
|
|
+ int sss = await _sqlSugar.Insertable(VisaCustomerCompany).ExecuteReturnIdentityAsync();
|
|
|
+ if (sss == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "客户工作经历保存失败!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //客户学历表
|
|
|
+ foreach (VisaCustomerSchool item in dto.CustomerSchool)
|
|
|
+ {
|
|
|
+ Crm_VisaCustomerSchool VisaCustomerSchool = _mapper.Map<Crm_VisaCustomerSchool>(item);
|
|
|
+ VisaCustomerSchool.DcId = deleId;
|
|
|
+ if (item.Id != 0)//修改
|
|
|
+ {
|
|
|
+ int res = await _sqlSugar.Updateable<Crm_VisaCustomerSchool>().Where(a => a.Id == VisaCustomerSchool.Id).SetColumns(a => new Crm_VisaCustomerSchool
|
|
|
+ {
|
|
|
+ DcId = VisaCustomerSchool.DcId,
|
|
|
+ School = VisaCustomerSchool.School,
|
|
|
+ Address = VisaCustomerSchool.Address,
|
|
|
+ Teacher = VisaCustomerSchool.Teacher,
|
|
|
+ Education = VisaCustomerSchool.Education,
|
|
|
+ Subject = VisaCustomerSchool.Subject,
|
|
|
+ StudyStart = VisaCustomerSchool.StudyStart,
|
|
|
+ StudyEnd = VisaCustomerSchool.StudyEnd,
|
|
|
+ CreateUserId = VisaCustomerSchool.CreateUserId,
|
|
|
+ Remark = VisaCustomerSchool.Remark,
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ if (res == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "客户学历信息保存失败!" };
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (item.Id == 0)//添加
|
|
|
+ {
|
|
|
+ int sss = await _sqlSugar.Insertable(VisaCustomerSchool).ExecuteReturnIdentityAsync();
|
|
|
+ if (sss == 0)
|
|
|
+ {
|
|
|
+ result = new Result() { Code = -1, Msg = "客户学历信息保存失败!" };
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ return result = new Result() { Code = -2, Msg = "程序错误!" };
|
|
|
+ throw;
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
-
|
|
|
+ public async Task<Result> DelCustomer(DeleClientDelDto dto)
|
|
|
+ {
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bool isOk=await SoftDeleteByIdAsync<Crm_DeleClient>(dto.Id.ToString(),dto.DeleteUserId);
|
|
|
+ if (isOk)//删除其他表数据
|
|
|
+ {
|
|
|
+ //客户工作经历
|
|
|
+ await _sqlSugar.Updateable<Crm_VisaCustomerCompany>().Where(a => a.DcId==dto.Id).SetColumns(a => new Crm_VisaCustomerCompany()
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = dto.DeleteUserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ //客户学历
|
|
|
+ await _sqlSugar.Updateable<Crm_VisaCustomerSchool>().Where(a => a.DcId == dto.Id).SetColumns(a => new Crm_VisaCustomerSchool()
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = dto.DeleteUserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ //客户家庭成员信息
|
|
|
+ await _sqlSugar.Updateable<Crm_VisaCustomerFamily>().Where(a => a.DcId == dto.Id).SetColumns(a => new Crm_VisaCustomerFamily()
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = dto.DeleteUserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ //客户证件表
|
|
|
+ await _sqlSugar.Updateable<Crm_CustomerCert>().Where(a => a.DcId == dto.Id).SetColumns(a => new Crm_CustomerCert()
|
|
|
+ {
|
|
|
+ IsDel = 1,
|
|
|
+ DeleteUserId = dto.DeleteUserId,
|
|
|
+ DeleteTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
|
+ }).ExecuteCommandAsync();
|
|
|
+ return result = new Result() { Code = 0, Msg = "删除成功!" };
|
|
|
+ }
|
|
|
}
|
|
|
- catch (Exception)
|
|
|
+ catch (Exception ex)
|
|
|
{
|
|
|
return result = new Result() { Code = -2, Msg = "程序错误!" };
|
|
|
throw;
|