|
@@ -1,7 +1,10 @@
|
|
-using OASystem.Domain;
|
|
|
|
|
|
+using AutoMapper;
|
|
|
|
+using OASystem.Domain;
|
|
using OASystem.Domain.Dtos;
|
|
using OASystem.Domain.Dtos;
|
|
|
|
+using OASystem.Domain.Dtos.CRM;
|
|
using OASystem.Domain.Dtos.UserDto;
|
|
using OASystem.Domain.Dtos.UserDto;
|
|
using OASystem.Domain.Entities.Customer;
|
|
using OASystem.Domain.Entities.Customer;
|
|
|
|
+using OASystem.Domain.Entities.Resource;
|
|
using OASystem.Domain.ViewModels.CRM;
|
|
using OASystem.Domain.ViewModels.CRM;
|
|
using System;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
@@ -15,10 +18,14 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
/// 签证客户公司
|
|
/// 签证客户公司
|
|
/// 仓库
|
|
/// 仓库
|
|
/// </summary>
|
|
/// </summary>
|
|
- public class VisaDeleClientCompanyRepository : BaseRepository<Crm_VisaCustomerCompany, VisaCustomerCompanyView>
|
|
|
|
|
|
+ public class VisaDeleClientCompanyRepository : BaseRepository<Crm_CustomerCompany, CustomerCompanyView>
|
|
{
|
|
{
|
|
- public VisaDeleClientCompanyRepository(SqlSugarClient sqlSugar) :
|
|
|
|
- base(sqlSugar){ }
|
|
|
|
|
|
+ private readonly IMapper _mapper;
|
|
|
|
+ public VisaDeleClientCompanyRepository(SqlSugarClient sqlSugar, IMapper mapper) :
|
|
|
|
+ base(sqlSugar)
|
|
|
|
+ {
|
|
|
|
+ _mapper= mapper;
|
|
|
|
+ }
|
|
|
|
|
|
/// <summary>
|
|
/// <summary>
|
|
/// 签证客户公司 List
|
|
/// 签证客户公司 List
|
|
@@ -31,10 +38,10 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
|
|
|
|
if (dto.PortType == 1 || dto.PortType == 2)
|
|
if (dto.PortType == 1 || dto.PortType == 2)
|
|
{
|
|
{
|
|
- string sql = string.Format(@"Select ccc.Id,ccc.CompanyName,ccc.Address,ccc.PostCodes,su.CnName UserName,ccc.CreateTime
|
|
|
|
- From Crm_CustomerCompany ccc Inner Join Sys_Users su On ccc.CreateUserId = su.Id");
|
|
|
|
|
|
+ string sql = string.Format(@"Select ccc.Id,ccc.CompanyName,ccc.Address,ccc.PostCodes,su.CnName UserName,ccc.CreateTime,ccc.Remark
|
|
|
|
+ From Crm_CustomerCompany ccc Inner Join Sys_Users su On ccc.CreateUserId = su.Id where ccc.IsDel=0");
|
|
|
|
|
|
- var _clientCompanyList = await _sqlSugar.SqlQueryable<VisaCustomerCompanyListView>(sql).ToListAsync();
|
|
|
|
|
|
+ var _clientCompanyList = await _sqlSugar.SqlQueryable<CustomerCompanyListView>(sql).ToListAsync();
|
|
if (_clientCompanyList.Count > 0)
|
|
if (_clientCompanyList.Count > 0)
|
|
{
|
|
{
|
|
result.Code = 0;
|
|
result.Code = 0;
|
|
@@ -50,5 +57,61 @@ namespace OASystem.Infrastructure.Repositories.CRM
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public async Task<Result> OperationClientCompany(OperationClientCompanyDto dto)
|
|
|
|
+ {
|
|
|
|
+ Result result = new Result() { Code = -2, Msg = "未知错误" };
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ if (dto.Status == 1)//添加
|
|
|
|
+ {
|
|
|
|
+ string selectSql = string.Format(@"select * from Crm_CustomerCompany WHERE CompanyName='{0}' and IsDel='{1}'"
|
|
|
|
+ , dto.CompanyName, 0);
|
|
|
|
+ var CustomerCompany = await _sqlSugar.SqlQueryable<Crm_CustomerCompany>(selectSql).FirstAsync();//查询是否存在
|
|
|
|
+ if (CustomerCompany != null)
|
|
|
|
+ {
|
|
|
|
+ return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else//不存在,可添加
|
|
|
|
+ {
|
|
|
|
+ Crm_CustomerCompany _CustomerCompany = _mapper.Map<Crm_CustomerCompany>(dto);
|
|
|
|
+ int id = await AddAsyncReturnId(_CustomerCompany);
|
|
|
|
+ if (id == 0)
|
|
|
|
+ {
|
|
|
|
+ return result = new Result() { Code = -1, Msg = "添加失败!" };
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else if (dto.Status == 2)//修改
|
|
|
|
+ {
|
|
|
|
+ bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Crm_CustomerCompany
|
|
|
|
+ {
|
|
|
|
+ CompanyName=dto.CompanyName,
|
|
|
|
+ Address = dto.Address,
|
|
|
|
+ PostCodes = dto.PostCodes,
|
|
|
|
+ LastedOpUserId = dto.LastedOpUserId,
|
|
|
|
+ LastedOpDt = dto.LastedOpDt,
|
|
|
|
+ Remark = dto.Remark,
|
|
|
|
+
|
|
|
|
+ });
|
|
|
|
+ if (!res)
|
|
|
|
+ {
|
|
|
|
+ return result = new Result() { Code = -1, Msg = "修改失败!" };
|
|
|
|
+ }
|
|
|
|
+ result = new Result() { Code = 0, Msg = "修改成功!" };
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ return result = new Result() { Code = -2, Msg = "程序错误!" };
|
|
|
|
+ }
|
|
|
|
+ return result;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|