123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- using OASystem.Domain.Dtos.CRM;
- using OASystem.Domain.Entities.Customer;
- using OASystem.Infrastructure.Repositories.CRM;
- namespace OASystem.API.Controllers
- {
- /// <summary>
- /// 签证客户资料相关
- /// </summary>
- [Route("api/[controller]/[action]")]
- //[ApiController]
- public class CRMController : ControllerBase
- {
- private readonly VisaDeleClientCompanyRepository _clientCompanyRepository;
- private readonly VisaDeleClientRepository _clientRepository;
- private readonly CustomerCertRepository _customerCertRep;
- private readonly CustomerFamilyRepository _customerFamilyRep;
- private readonly CustomerSchoolRepository _customerSchoolRep;
- private readonly CustomerCompanyRepository _customerCompanyRep;
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="clientCompanyRepository"></param>
- /// <param name="clientRepository"></param>
- public CRMController(VisaDeleClientCompanyRepository clientCompanyRepository, VisaDeleClientRepository clientRepository,
- CustomerCertRepository customerCertRep, CustomerFamilyRepository customerFamilyRep, CustomerSchoolRepository customerSchoolRep, CustomerCompanyRepository customerCompanyRep)
- {
- this._clientCompanyRepository = clientCompanyRepository;
- this._clientRepository = clientRepository;
- this._customerCertRep = customerCertRep;
- this._customerFamilyRep = customerFamilyRep;
- this._customerSchoolRep = customerSchoolRep;
- _customerCompanyRep = customerCompanyRep;
- }
- /// <summary>
- /// 获取签证客户公司列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetClientCompanyList(DtoBase dto)
- {
- var clientCompanyData = await _clientCompanyRepository.GetCrm_ClientCompanyList(dto);
- if (clientCompanyData.Code != 0)
- {
- return Ok(JsonView(false, clientCompanyData.Msg == null ? "操作失败" : clientCompanyData.Msg));
- }
- return Ok(JsonView(clientCompanyData.Data, clientCompanyData.Data.Count));
- }
- /// <summary>
- /// 签证客户公司列表操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> OperationClientCompany(OperationClientCompanyDto dto)
- {
- try
- {
- if (dto.CompanyName == "")
- {
- return Ok(JsonView(false, "请检查客户单位名称是否填写!"));
- }
- if (dto.Address == "")
- {
- return Ok(JsonView(false, "请检查客户单位地址是否填写!"));
- }
- if (dto.PostCodes == "")
- {
- return Ok(JsonView(false, "请检查客户单位邮编是否填写!"));
- }
- Result clientCompanyData = await _clientCompanyRepository.OperationClientCompany(dto);
- if (clientCompanyData.Code != 0)
- {
- return Ok(JsonView(false, clientCompanyData.Msg));
- }
- return Ok(JsonView(true, clientCompanyData.Msg));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 签证客户公司列表操作(删除)
- /// </summary>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelClientCompany(DelBaseDto dto)
- {
- try
- {
- var res = await _clientCompanyRepository.SoftDeleteByIdAsync<Crm_CustomerCompany>(dto.Id.ToString(), dto.DeleteUserId);
- if (!res)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- catch (Exception ex)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 获取签证客户列表
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> GetClientList(DtoBase dto)
- {
- var clientData = await _clientRepository.GetCrmList(dto);
- if (clientData.Code != 0)
- {
- return Ok(JsonView(false, clientData.Msg == null ? "操作失败" : clientData.Msg));
- }
- return Ok(JsonView(clientData.Data, clientData.Data.Count));
- }
- /// <summary>
- /// 根据Id获取签证客户信息
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> CustomerInfo(CustomerDto dto)
- {
- try
- {
- Crm_DeleClient crm_Dele = await _clientRepository.GetAsync<Crm_DeleClient>(x => x.Id == dto.Id);
- if (crm_Dele == null)
- {
- return Ok(JsonView(false, "查询失败!"));
- }
- List<Crm_VisaCustomerCompany> _VisaCustomerCompany = _clientRepository.Query<Crm_VisaCustomerCompany>(x => x.DcId == crm_Dele.Id && x.IsDel == 0).ToList();//客户工作经历表
- List<Crm_VisaCustomerSchool> _VisaCustomerSchool = _clientRepository.Query<Crm_VisaCustomerSchool>(x => x.DcId == crm_Dele.Id && x.IsDel == 0).ToList();//客户学历表
- List<Crm_VisaCustomerFamily> _VisaCustomerFamily = _clientRepository.Query<Crm_VisaCustomerFamily>(x => x.DcId == crm_Dele.Id && x.IsDel == 0).ToList();//客户学历表
- List<Crm_CustomerCert> _CustomerCerts = _clientRepository.Query<Crm_CustomerCert>(x => x.DcId == crm_Dele.Id && x.IsDel == 0).ToList();//客户证件表
- Crm_CustomerCompany _CustomerCompany = await _clientCompanyRepository.GetAsync<Crm_CustomerCompany>(x => x.Id == crm_Dele.CrmCompanyId);//客户公司信息
- var data = new
- {
- DeleClient = crm_Dele,
- WorkExperience = _VisaCustomerCompany,
- CustomerSchool = _VisaCustomerSchool,
- CustomerFamily = _VisaCustomerFamily,
- CustomerCompany = _CustomerCompany,
- CustomerCerts = _CustomerCerts
- };
- return Ok(JsonView(true, "查询成功!", data));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 客户资料操作(Status:1.新增,2.修改)
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> EditCustomer(DeleClientOpDto dto)
- {
- try
- {
- Domain.Result result = await _clientRepository.OpCustomer(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- catch (Exception)
- {
- return Ok(JsonView(false, "程序错误!"));
- throw;
- }
- }
- /// <summary>
- /// 客户资料操作删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomer(DeleClientDelDto dto)
- {
- Result result = await _clientRepository.DelCustomer(dto);
- if (result.Code != 0)
- {
- return Ok(JsonView(false, result.Msg));
- }
- return Ok(JsonView(true, result.Msg));
- }
- /// <summary>
- /// 证件表数据删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomerCerts(DelBaseDto dto)
- {
- var result = await _customerCertRep.SoftDeleteByIdAsync<Crm_CustomerCert>(dto.Id.ToString(), dto.DeleteUserId);
- if (!result)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 家庭成员表数据删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomerFamily(DelBaseDto dto)
- {
- var result = await _customerFamilyRep.SoftDeleteByIdAsync<Crm_VisaCustomerFamily>(dto.Id.ToString(), dto.DeleteUserId);
- if (!result)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 客户学历表数据删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelCustomerSchool(DelBaseDto dto)
- {
- var result = await _customerSchoolRep.SoftDeleteByIdAsync<Crm_VisaCustomerSchool>(dto.Id.ToString(), dto.DeleteUserId);
- if (!result)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 客户工作经历表数据删除
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> DelVisaCustomerCompany(DelBaseDto dto)
- {
- var result = await _customerCompanyRep.SoftDeleteByIdAsync<Crm_VisaCustomerCompany>(dto.Id.ToString(), dto.DeleteUserId);
- if (!result)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- /// <summary>
- /// 客户资料导入
- /// </summary>
- /// <param name="dto"></param>
- /// <returns></returns>
- [HttpPost]
- [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
- public async Task<IActionResult> PostClient(DelBaseDto dto)
- {
- var result = await _customerCompanyRep.SoftDeleteByIdAsync<Crm_VisaCustomerCompany>(dto.Id.ToString(), dto.DeleteUserId);
- if (!result)
- {
- return Ok(JsonView(false, "删除失败"));
- }
- return Ok(JsonView(true, "删除成功!"));
- }
- }
- }
|