BillDownloadResponse.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using System.Threading.Tasks;
  2. using PaySharp.Core.Request;
  3. using PaySharp.Core.Utils;
  4. namespace PaySharp.Alipay.Response
  5. {
  6. public class BillDownloadResponse : BaseResponse
  7. {
  8. /// <summary>
  9. /// 账单下载地址链接,获取连接后30秒后未下载,链接地址失效。
  10. /// </summary>
  11. public string BillDownloadUrl { get; set; }
  12. private byte[] _billFile;
  13. /// <summary>
  14. /// 获取账单文件
  15. /// </summary>
  16. public byte[] GetBillFile()
  17. {
  18. if (_billFile == null && !string.IsNullOrEmpty(BillDownloadUrl))
  19. {
  20. _billFile = HttpUtil.Download(BillDownloadUrl);
  21. }
  22. return _billFile;
  23. }
  24. /// <summary>
  25. /// 获取账单文件
  26. /// </summary>
  27. public async Task<byte[]> GetBillFileAsync()
  28. {
  29. if (_billFile == null && !string.IsNullOrEmpty(BillDownloadUrl))
  30. {
  31. _billFile = await HttpUtil.DownloadAsync(BillDownloadUrl);
  32. }
  33. return _billFile;
  34. }
  35. internal override void Execute<TModel, TResponse>(Merchant merchant, Request<TModel, TResponse> request)
  36. {
  37. }
  38. }
  39. }