XYYTestController.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using Microsoft.AspNetCore.Authorization;
  2. using Microsoft.AspNetCore.Mvc;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.IO;
  6. using System.Linq;
  7. using System.Security.Cryptography;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using XYY.Core.Standard.Mvc;
  11. using XYY.Model.Standard.Order;
  12. using XYY.Service.Standard.ChannelApi;
  13. using static XYY.Api.Order.Controllers.CustomerMaintenanceController;
  14. using static XYY.Service.Standard.ChannelApi.HangLe.Api;
  15. namespace XYY.Api.Order.Controllers
  16. {
  17. [AllowAnonymous]
  18. [Route("api/[controller]/[action]")]
  19. [ApiController]
  20. public class XYYTestController : ApiControllerBase
  21. {
  22. private IEnumerable<IUItidelApi> _packLabelApis;
  23. public XYYTestController(IEnumerable<IUItidelApi> packLabelApis)
  24. {
  25. _packLabelApis = packLabelApis;
  26. }
  27. /// <summary>
  28. /// 测试 获取打包标签接口
  29. /// 查看标签下载标签pdf查看
  30. /// </summary>
  31. /// <returns></returns>
  32. [AllowAnonymous]
  33. [HttpPost]
  34. public async Task<IActionResult> GetIBBagLabels_Test()
  35. {
  36. ChannelBagLabelParam param = new ChannelBagLabelParam()
  37. {
  38. Box = new XYY.Model.Standard.Channel.Logistics_Box() { BoxNumber = "B230306006402" },
  39. Channel = new XYY.Model.Standard.Channel.Logistics_Channel() { ServiceTrackingUrl = "https://clients.postnl.a02.cldsvc.net", ApiKey = "WSNTMxGyMMrklKbFChO82K0rNsXGhi2f6EVCTOj2d6PpQCqwLLhmyIevKgFCIqA0HdqndszcJ5EtjhTPP6RSeFPAer2Sj4JC9zi8MAAqVfm7uQjn0FTHUtMSqQTykA9NfDhYeTfHSIu64scmmYrvN2uL0dubQn7szo4pUV6s9PvXRAB4qw1ohzKKfsTUkrKwgiCkNPlVqHodmPAU3HVKQpDaCMepLJAhQiuBSGXPVudyvRoRyLa9A2heTaHybX6NPwMvgOKPcXdneeS669LuUt5gKkGxJk8Ksi519AAKcm8A", },
  40. };
  41. var baseApi = _packLabelApis.Where(x => x.ServiceName == "NLPost").FirstOrDefault();
  42. var resultData = await baseApi.GetChannelBagLabel(param);
  43. MemoryStream ms = new MemoryStream(Convert.FromBase64String(resultData.Label));
  44. return new FileStreamResult(ms, "application/pdf");
  45. }
  46. [HttpGet]
  47. [AllowAnonymous]
  48. public async Task<IActionResult> TestIOSSM()
  49. {
  50. string code = "IM2760000999";
  51. string publicKeyBase64 = @"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDc0KbDAE/y4EtmCZCpqqzWreAX0b+1BWP+cFN7XbD55cv0xPF0zIlJ4qTVfdurYEHARTOfVNZOrg2jl2W0ViJ6n7F4";
  52. string privateKeyBase64 = @"MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANzQpsMAT/LgS2YJkKmqrNat4BfRv7UFY/5wU3tdsPnly/TE8XTMiUnipNV926tgQcBFM59U1k6uDaOXZbRWInqfsXgz9E1XcIHED15IWuXfePewA7By7HnFr9BkjW+WXpmijuDq3Nm7vqDcV6zmzYvmzTQmsGB62a1NaL1FQeilAg";
  53. string value = @"IR4E//Nym9n8heEN0A43pijxKBu1BUHKrCMWTAVp6vLFSSfyrQVhtvKq6os4E1kxtvbNUNQoQnHOX7QewGIFUPIqS2eGXilQdTs3Tf0UIysmGpft9P/rkpkiffZ1eK6o/f8EClGAIy4KVDevaNvRSZ5uOOvQm5oBctjQodercts=";
  54. XYY.Common.Standard.RSA rsa = new Common.Standard.RSA();
  55. string v = rsa.DecryptByPrivateKey(value, privateKeyBase64);
  56. return Ok((v));
  57. }
  58. }
  59. }