amount.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using dodohold.core;
  2. using Sayaka.Common;
  3. namespace molilian.core
  4. {
  5. public partial class JdUnionPlus
  6. {
  7. public class SpreadReportInfoDTO
  8. {
  9. public int id { get; set; } = 0;
  10. public int accountId { get; set; } = 0;
  11. public string accountName { get; set; } = string.Empty;
  12. public DateTime report_date { get; set; } = DateTime.MinValue;
  13. public DateTime create_time { get; set; } = DateTime.Now;
  14. public DateTime last_time { get; set; } = DateTime.MinValue;
  15. public string accountDate { get; set; } = string.Empty;
  16. public int clickNum { get; set; } = 0;
  17. public decimal cosFee { get; set; } = 0;
  18. public decimal cosPrice { get; set; } = 0;
  19. public decimal finishCosFee { get; set; } = 0;
  20. public decimal finishCosPrice { get; set; } = 0;
  21. public int finishOrderNum { get; set; } = 0;
  22. public int orderNum { get; set; } = 0;
  23. }
  24. public async Task<SpreadReportInfoDTO> queryTodaySpreadEffectData(CancellationToken cancellationToken = default)
  25. {
  26. SpreadReportInfoDTO result = null;
  27. var ts = DateTime.Now.Convert2UnixTimestamp(true);
  28. string cookies = _account.cookies;
  29. string useragent = _account.user_agent;
  30. if (string.IsNullOrEmpty(useragent)) useragent = ProviderFakeUserAgent.RandomComputer;
  31. var args = new
  32. {
  33. funName = "querySpreadEffectData",
  34. param = new
  35. {
  36. startDate = DateTime.Now.ToString("yyyy-MM-dd"),
  37. endDate = DateTime.Now.ToString("yyyy-MM-dd"),
  38. mediaId = "",
  39. proCont = "",
  40. promotionId = "",
  41. sourceEmt = "",
  42. pageNo = 0,
  43. pageSize = 20
  44. },
  45. };
  46. string data = args.Convert2Json().UrlEncode();
  47. string url = $"https://api.m.jd.com/api?functionId=union_report&appid=unionpc&loginType=3&body={data}";
  48. WebClientUtility client = new WebClientUtility();
  49. client.Proxy = _proxy;
  50. #if DEBUG
  51. client.Proxy = null;
  52. #endif
  53. client.SetContentType("application/x-www-form-urlencoded");
  54. client.AddHeaders("X-Referer-Page", "https://union.jd.com/proManager/index");
  55. client.AddHeaders("X-Rp-Client", "h5_1.0.0");
  56. client.AddHeaders("Referer", "https://union.jd.com/");
  57. client.AddHeaders("Origin", "https://union.jd.com");
  58. client.UserAgent = useragent;
  59. client.AddHeaders("Cookie", cookies);
  60. client.Post($"body={data}");
  61. var response = await client.RequestAsync(url, "POST", cancellationToken);
  62. if (!client.Successed) throw client.ResponseException;
  63. string body = response.Body();
  64. var root = body.Convert2JsonElement();
  65. int code = root.Read<int>("code");
  66. string message = root.Read<string>("message");
  67. if (code == 200 && "success".Equals(message))
  68. {
  69. var list = root.ElementRead("result").ElementRead("spreadReportInfoChatList");
  70. if (list.EnumerateArray().Any())
  71. {
  72. result = list[0].GetRawText().Convert2Object<SpreadReportInfoDTO>();
  73. }
  74. return result;
  75. }
  76. throw new APIException(body);
  77. }
  78. }
  79. }