H5Controller.cs 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using molilian.core;
  2. using dodohold.core;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Org.BouncyCastle.Ocsp;
  5. using System.Text.Json;
  6. using System.Runtime.InteropServices;
  7. using System.Net;
  8. using System.Security.Cryptography;
  9. using Microsoft.AspNetCore.Authentication;
  10. using TencentCloud.Ecm.V20190719.Models;
  11. using Dataoke;
  12. namespace molilian.api.Controllers
  13. {
  14. [ApiController]
  15. [Route("[controller]/[action]")]
  16. public class H5Controller : ControllerBase
  17. {
  18. protected IHttpContextAccessor _accessor;
  19. public H5Controller(IHttpContextAccessor accessor)
  20. {
  21. _accessor = accessor;
  22. }
  23. [HttpGet]
  24. public ActionResult sign()
  25. {
  26. var api = DataokeCore.GetOne();
  27. if (api == null)
  28. {
  29. return new APIResult(new
  30. {
  31. success = false,
  32. message = "没有可用签名账户"
  33. });
  34. }
  35. int nonce;
  36. string timer;
  37. DtkApp app = new(api.app_key, api.app_secret);
  38. string sign = app.MakeSign(out nonce, out timer);
  39. string sign_url = $"appKey={api.app_key}&nonce={nonce}&signRan={sign}&timer={timer}";
  40. https://openapi.dataoke.com/api/tb-service/get-privilege-link?appKey=663dc44dcb55f&nonce=955350&signRan=9FFB668FD91AD897C238C536899C92EC&timer=1716116967528&version=v1.3.1&pid=236e3aa943d948339732430b74737328&goodsId=jyn335Ds0tJYG9g9g0IN6PCJte-GPgAyeRIqOVrK3W0HnY&coupon_id=
  41. return new APIResult(new
  42. {
  43. success = true,
  44. message = "ok",
  45. sign_url
  46. });
  47. }
  48. /*
  49. var api = DataokeCore.GetOne();
  50. if (api == null)
  51. {
  52. result.success = false;
  53. result.message = "内部错误";
  54. result.reason = "没有匹配账号";
  55. result.rawContent = content;
  56. result.rawContent2 = content2;
  57. TkLogCore.Log(result);
  58. return new APIResult(result);
  59. }
  60. result = DataokeCore.JdParse(result, api, account, content);
  61. }
  62. */
  63. }
  64. }