goods.cs 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. using Microsoft.AspNetCore.Http;
  2. using Microsoft.AspNetCore.Mvc.Controllers;
  3. using Microsoft.AspNetCore.Mvc.Filters;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using dodohold.core;
  9. using Dataoke;
  10. using System.Text.RegularExpressions;
  11. using Org.BouncyCastle.Ocsp;
  12. using System.Diagnostics;
  13. using TencentCloud.Fmu.V20191213.Models;
  14. using Microsoft.VisualBasic;
  15. using System.Text.Json;
  16. using static System.Runtime.InteropServices.JavaScript.JSType;
  17. using System.Security.Cryptography;
  18. using System.Security.Policy;
  19. using Google.Protobuf.WellKnownTypes;
  20. using Microsoft.AspNetCore.Components;
  21. using Org.BouncyCastle.Pqc.Crypto.Ntru;
  22. using Newtonsoft.Json;
  23. namespace molilian.core
  24. {
  25. public partial class JdUnionPlus
  26. {
  27. /// <summary>
  28. /// 网站/APP获取推广链接接口
  29. /// </summary>
  30. /// <param name="unionId"></param>
  31. /// <param name="materialId"></param>
  32. /// <returns></returns>
  33. public string promotion_get(string siteId, string materialId)
  34. {
  35. string method = "jd.union.open.promotion.common.get";
  36. string version = "1.0";
  37. var data = new
  38. {
  39. promotionCodeReq = new
  40. {
  41. siteId,
  42. materialId,
  43. command = 1,
  44. chainType = 2,
  45. }
  46. };
  47. var body = Request(method, version, data.Convert2Json());
  48. var root = body.Convert2Object<JdUnionResponse>();
  49. string code = root.jd_union_open_promotion_common_get_responce.code;
  50. if ("0".Equals(code))
  51. {
  52. var _promotion_data = root.jd_union_open_promotion_common_get_responce.getResult;
  53. var promotion_data = _promotion_data.Convert2Object<JdData>();
  54. if (promotion_data.code == 200)
  55. {
  56. var url = promotion_data.data.clickURL;
  57. return url;
  58. }
  59. }
  60. _ = new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).SaveAsync();
  61. return null;
  62. }
  63. public async Task<string> GetPromotionAsync(string siteId, string materialId)
  64. {
  65. string method = "jd.union.open.promotion.common.get";
  66. string version = "1.0";
  67. var data = new
  68. {
  69. promotionCodeReq = new
  70. {
  71. siteId,
  72. materialId,
  73. command = 1,
  74. chainType = 2,
  75. }
  76. };
  77. var body = await RequestAsync(method, version, data.Convert2Json());
  78. var root = body.Convert2Object<JdUnionResponse>();
  79. string code = root.jd_union_open_promotion_common_get_responce.code;
  80. if ("0".Equals(code))
  81. {
  82. var _promotion_data = root.jd_union_open_promotion_common_get_responce.getResult;
  83. var promotion_data = _promotion_data.Convert2Object<JdData>();
  84. if (promotion_data.code == 200)
  85. {
  86. var url = promotion_data.data.clickURL;
  87. return url;
  88. }
  89. }
  90. _ = new LoggerLibrary("JdUnion", "promotion_get_error").Info(body).SaveAsync();
  91. return null;
  92. }
  93. }
  94. public class JdData
  95. {
  96. public int code { get; set; }
  97. public JdClickData data { get; set; }
  98. }
  99. public class JdClickData
  100. {
  101. public string clickURL { get; set; }
  102. }
  103. public class JdUnionResponse
  104. {
  105. public JdUnionOpenPromotionCommonGetResponce jd_union_open_promotion_common_get_responce { get; set; }
  106. }
  107. public class JdUnionOpenPromotionCommonGetResponce
  108. {
  109. public string code { get; set; }
  110. public string getResult { get; set; }
  111. public string message { get; set; }
  112. public string requestId { get; set; }
  113. }
  114. }