| ¶Ô±ÈÐÂÎļþ |
| | |
| | | using AutoMapper; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WIDESEA_BasicRepository; |
| | | using WIDESEA_Common.MaterielEnum; |
| | | using WIDESEA_Core; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.BaseServices; |
| | | using WIDESEA_Core.Helper; |
| | | using WIDESEA_DTO.Basic; |
| | | using WIDESEA_DTO.ERP; |
| | | using WIDESEA_IBasicRepository; |
| | | using WIDESEA_IBasicService; |
| | | using WIDESEA_Model.Models; |
| | | |
| | | namespace WIDESEA_BasicService |
| | | { |
| | | public class CustomerInfoService : ServiceBase<Dt_CustomerInfo, ICustomerInfoRepository>, ICustomerInfoService |
| | | { |
| | | public ICustomerInfoRepository Repository => BaseDal; |
| | | private readonly IMapper _mapper; |
| | | private readonly IUnitOfWorkManage _unitOfWorkManage; |
| | | public CustomerInfoService(ICustomerInfoRepository BaseDal,IMapper mapper,IUnitOfWorkManage unitOfWorkManage) : base(BaseDal) |
| | | { |
| | | _mapper = mapper; |
| | | _unitOfWorkManage = unitOfWorkManage; |
| | | } |
| | | /// <summary> |
| | | /// æ¥æ¶äºæå®¢æ·ä¿¡æ¯ |
| | | /// </summary> |
| | | /// <param name="eRPCustomerDTO"></param> |
| | | /// <returns></returns> |
| | | public WebResponseContent ReceiveCustomer(ERPCustomerDTO eRPCustomerDTO) |
| | | { |
| | | WebResponseContent content = new WebResponseContent(); |
| | | try |
| | | { |
| | | if (eRPCustomerDTO == null) |
| | | { |
| | | return content.Error("客æ·ä¿¡æ¯ä¸è½ä¼ å
¥ä¸ºç©º"); |
| | | } |
| | | List<Dt_CustomerInfo> OldcustomerInfos = BaseDal.QueryData(); |
| | | |
| | | if (eRPCustomerDTO.OperateType == 1) |
| | | { |
| | | //夿é夿å
¥ |
| | | Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode); |
| | | if (customerInfoOld != null) |
| | | { |
| | | return content.Error($"客æ·{customerInfoOld.CustomerCode}å·²åå¨"); |
| | | } |
| | | Dt_CustomerInfo customerInfo = _mapper.Map<Dt_CustomerInfo>(eRPCustomerDTO); |
| | | //æ°å¢ |
| | | BaseDal.AddData(customerInfo); |
| | | } |
| | | else if (eRPCustomerDTO.OperateType == 2) |
| | | { |
| | | //夿æ¯å¦åå¨ |
| | | Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode); |
| | | if (customerInfoOld == null) |
| | | { |
| | | return content.Error($"æ´æ°å®¢æ·{eRPCustomerDTO.CustomerCode}ä¸åå¨"); |
| | | } |
| | | Dt_CustomerInfo customerInfo = _mapper.Map<Dt_CustomerInfo>(eRPCustomerDTO); |
| | | customerInfo.Id = customerInfoOld.Id; |
| | | //æ´æ° |
| | | BaseDal.UpdateData(customerInfoOld); |
| | | } |
| | | else if (eRPCustomerDTO.OperateType == 3) |
| | | { |
| | | // 夿æ¯å¦åå¨ |
| | | Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode); |
| | | if (customerInfoOld == null) |
| | | { |
| | | return content.Error($"æ´æ°å®¢æ·{eRPCustomerDTO.CustomerCode}ä¸åå¨"); |
| | | } |
| | | BaseDal.DeleteData(customerInfoOld); |
| | | } |
| | | else |
| | | { |
| | | return content.Error("æªæ¾å°æä½ç±»å"); |
| | | } |
| | | //æ´æ°æ°æ® |
| | | return content.OK("æ¥æ¶æå"); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | content.Error(ex.Message); |
| | | } |
| | | return content; |
| | | } |
| | | } |
| | | } |