AssistantAddressService.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. using Microsoft.AspNetCore.Http;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using XYY.Core.Standard.Data.Infrastructure;
  7. using XYY.Model.Standard.OrderAddressCheck;
  8. using System.Linq;
  9. using XYY.PerformanceCount.Standard;
  10. namespace XYY.Service.Standard.AddressCheck
  11. {
  12. public class AssistantAddressService : IAssistantAddressService
  13. {
  14. private readonly IEnumerable<IAdderssService> _adderssServicesList;
  15. public AssistantAddressService(IEnumerable<IAdderssService> adderssServicesList)
  16. {
  17. _adderssServicesList = adderssServicesList;
  18. }
  19. private IAdderssService GetAdderssService(string receiverCountryCode)
  20. {
  21. var service = _adderssServicesList.Where(x => x.CountryCode == receiverCountryCode).FirstOrDefault();
  22. if (service == null)
  23. throw new Exception("未注册【" + receiverCountryCode + "】相关检索服务");
  24. else
  25. return service;
  26. }
  27. [MethodPerformanceAttrice("GetRecommendedAddresses")]
  28. public Task<RecommendedAddress> GetRecommendedAddresses(AssistantOrderAddress address)
  29. {
  30. var _adderssService = GetAdderssService(address.CountryCode);
  31. return _adderssService.GetRecommendedAddresses(address.OrderAddress);
  32. }
  33. }
  34. }