CustomerSendsApplicationService.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Abp.Authorization;
  2. using Abp.Domain.Repositories;
  3. using IwbZero.AppServiceBase;
  4. using ShwasherSys.Authorization.Permissions;
  5. using ShwasherSys.CustomerInfo.Dto;
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Threading.Tasks;
  10. using Abp.Application.Services.Dto;
  11. using Abp.Auditing;
  12. using IwbZero.IdentityFramework;
  13. using ShwasherSys.Dto;
  14. using ShwasherSys.OrderSendInfo;
  15. namespace ShwasherSys.CustomerInfo
  16. {
  17. [AbpAuthorize]
  18. public class CustomerSendsAppService : ShwasherAsyncCrudAppService<CustomerSend, CustomerSendDto, int, PagedRequestDto, CustomerSendCreateDto, CustomerSendUpdateDto>, ICustomerSendsAppService
  19. {
  20. protected IRepository<ViewOrderSend> ViewOrderSendRepository;
  21. public CustomerSendsAppService(IRepository<CustomerSend, int> repository, IRepository<ViewOrderSend> viewOrderSendRepository) : base(repository)
  22. {
  23. ViewOrderSendRepository = viewOrderSendRepository;
  24. }
  25. protected override string GetPermissionName { get; set; } = PermissionNames.PagesCustomerInfoCustomers;
  26. protected override string GetAllPermissionName { get; set; } = PermissionNames.PagesCustomerInfoCustomers;
  27. protected override string CreatePermissionName { get; set; } = PermissionNames.PagesCustomerInfoCustomersCreateSend;
  28. protected override string UpdatePermissionName { get; set; } = PermissionNames.PagesCustomerInfoCustomersUpdateSend;
  29. protected override string DeletePermissionName { get; set; } = PermissionNames.PagesCustomerInfoCustomersDeleteSend;
  30. public override async Task Delete(EntityDto<int> input)
  31. {
  32. CheckDeletePermission();
  33. var entity = await GetEntityByIdAsync(input.Id);
  34. var queryAllList = ViewOrderSendRepository.GetAll().Where(i =>
  35. i.CustomerId == entity.CustomerId && (i.OrderSendBillNo == null || i.OrderSendBillNo == "") &&
  36. i.CustomerSendId == input.Id);
  37. if (queryAllList.Any())
  38. {
  39. CheckErrors(new IwbIdentityResult("该客户发货地址存在未生成发货单的发货记录,不可删除!"));
  40. }
  41. #region shwasher temp
  42. AddCommonPropertyValue("TimeLastMod", DateTime.Now, ref entity);
  43. AddCommonPropertyValue("UserIDLastMod", AbpSession.UserName, ref entity);
  44. AddCommonPropertyValue("IsLock", "Y", ref entity);
  45. #endregion
  46. await CurrentUnitOfWork.SaveChangesAsync();
  47. //return MapToEntityDto(entity);
  48. }
  49. [DisableAuditing]
  50. public List<CustomerSendDto> GetCustomerSendDtoByCustomerId(CustomerSendDto customerId)
  51. {
  52. var entities = Repository.GetAll().Where(i => i.CustomerId == customerId.CustomerId && i.IsLock == "N");
  53. return ObjectMapper.Map<List<CustomerSendDto>>(entities.ToList());
  54. }
  55. [DisableAuditing]
  56. public async Task<CustomerSendDto> GetEntityById(CommonDto<int> input)
  57. {
  58. CheckGetPermission();
  59. if (input == null || input.Key == 0)
  60. {
  61. return null;
  62. }
  63. var entity = await GetEntityByIdAsync(input.Key);
  64. return MapToEntityDto(entity);
  65. }
  66. }
  67. }