|
@@ -1,4 +1,5 @@
|
|
|
|
|
|
+using AutoMapper;
|
|
|
using OASystem.Domain;
|
|
|
using OASystem.Domain.Dtos;
|
|
|
using OASystem.Domain.Dtos.CRM;
|
|
@@ -21,9 +22,12 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
/// </summary>
|
|
|
public class VisaDeleClientRepository : BaseRepository<Crm_DeleClient, VisaDeleClientView>
|
|
|
{
|
|
|
- public VisaDeleClientRepository(SqlSugarClient sqlSugar) :
|
|
|
+ private readonly IMapper _mapper;
|
|
|
+ public VisaDeleClientRepository(SqlSugarClient sqlSugar,IMapper mapper) :
|
|
|
base(sqlSugar)
|
|
|
- { }
|
|
|
+ {
|
|
|
+ _mapper = mapper;
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
|
/// 签证客户list
|
|
@@ -142,14 +146,34 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- public async Task<Domain.Result> EditCustomer(DeleClientOpDto dto)
|
|
|
+ public async Task<Result> OpCustomer(DeleClientOpDto dto)
|
|
|
{
|
|
|
- Domain.Result result = new Domain.Result() { Code = -2, Msg = "未知错误" };
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
try
|
|
|
{
|
|
|
if (dto.Status==1)//添加
|
|
|
{
|
|
|
- return result = new Domain.Result() { Code = -2, Msg = "未知错误" };
|
|
|
+ string selectSql = string.Format(@"select * from Crm_DeleClient where LastName+FirstName='{0}' and Phone='{1}' and IsDel='{2}'"
|
|
|
+ , dto.DeleClient.LastName+dto.DeleClient.FirstName, dto.DeleClient.Phone, 0);
|
|
|
+ var DeleClient = await _sqlSugar.SqlQueryable<Crm_DeleClient>(selectSql).FirstAsync();//查询是否存在
|
|
|
+ if (DeleClient != null)
|
|
|
+ {
|
|
|
+ return result = new Result() { Code = -1, Msg = "该客户已存在,请勿重复添加!" };
|
|
|
+
|
|
|
+ }
|
|
|
+ else//不存在,可添加
|
|
|
+ {
|
|
|
+ Crm_DeleClient _CountryFeeCost = _mapper.Map<Crm_DeleClient>(dto.DeleClient);
|
|
|
+ int id = await AddAsyncReturnId(_CountryFeeCost);
|
|
|
+ if (id == 0)
|
|
|
+ {
|
|
|
+ return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ return result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
+ //进行其他表炒作
|
|
|
+ }
|
|
|
}
|
|
|
else if (dto.Status == 2)//修改
|
|
|
{
|
|
@@ -248,15 +272,27 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
});
|
|
|
if (!res)
|
|
|
{
|
|
|
- return result = new Domain.Result() { Code = -1, Msg = "修改失败!" };
|
|
|
+ return result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
+ }
|
|
|
+ foreach (var item in dto.CustomerFamily)
|
|
|
+ {
|
|
|
+ if (item.Id!=0)//修改
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+ else//添加
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
- result = new Domain.Result() { Code = 0, Msg = "修改成功!" };
|
|
|
+ return result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
+ //进行其他表操作
|
|
|
}
|
|
|
|
|
|
}
|
|
|
catch (Exception)
|
|
|
{
|
|
|
- return result = new Domain.Result() { Code = -2, Msg = "程序错误!" };
|
|
|
+ return result = new Result() { Code = -2, Msg = "程序错误!" };
|
|
|
throw;
|
|
|
}
|
|
|
return result;
|