HomeController.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. using System.Linq;
  2. using Library;
  3. using LitJson;
  4. using System;
  5. using System.IO;
  6. using System.Text.RegularExpressions;
  7. using Microsoft.AspNetCore.Mvc;
  8. namespace MySystem.Controllers
  9. {
  10. public class HomeController : Controller
  11. {
  12. public HomeController()
  13. {
  14. }
  15. public IActionResult Index()
  16. {
  17. return View();
  18. }
  19. public IActionResult Error()
  20. {
  21. string isapi = Request.Headers["Api"].ToString();
  22. if (isapi != "1")
  23. {
  24. if (Response.StatusCode == 500)
  25. {
  26. return Redirect("/public/errpage/pc/500.html");
  27. }
  28. else if (Response.StatusCode == 502)
  29. {
  30. return Redirect("/public/errpage/pc/502.html");
  31. }
  32. else if (Response.StatusCode == 404)
  33. {
  34. return Redirect("/public/errpage/pc/404.html");
  35. }
  36. else if (Response.StatusCode == 401)
  37. {
  38. return Content("401");
  39. }
  40. }
  41. return View();
  42. }
  43. public string auth(string app_id, string source, string application_type, string app_auth_code, string state)
  44. {
  45. return app_id + "\n" + source + "\n" + application_type + "\n" + app_auth_code + "\n" + state + "\n" + Request.QueryString.ToString();
  46. }
  47. public string test()
  48. {
  49. string result = "ok";
  50. // List<ReceiverList> Receivers = new List<ReceiverList>();
  51. // Receivers.Add(new ReceiverList()
  52. // {
  53. // type = "MERCHANT_ID", //分账接收方类型
  54. // account = "1611167423", //分账接收方账号
  55. // amount = 1, //分账金额
  56. // description = "服务费", //分账描述
  57. // });
  58. // Receivers.Add(new ReceiverList()
  59. // {
  60. // type = "PERSONAL_OPENID", //分账接收方类型
  61. // account = "ooDpv5LkCKEguE-LMZO-rSV4TDpk", //分账接收方账号
  62. // amount = 1, //分账金额
  63. // description = "优惠", //分账描述
  64. // });
  65. // result = new WeChatFunction().ProfitShare("1645266943", "4200001846202306021274142861", "2023060214014405449699901", Receivers);
  66. // result = new WeChatFunction().AddReceive("1645266943", "PERSONAL_OPENID", "ooDpv5LkCKEguE-LMZO-rSV4TDpk", "", "USER");
  67. // result = new WeChatFunction().QueryProfitShare("1645266943", "4200001815202306025662773463", "2023060213335030713572885");
  68. // result += new WeChatFunction().Unfreeze("1647917209","4200001851202306296256433756","2023062914544345583469577", "结算");
  69. // result += new WeChatFunction().Unfreeze("1647917209","4200001871202306297971809063","2023062914503970424085049", "结算");
  70. // result += new WeChatFunction().Unfreeze("1647917209","4200001861202306299303626271","2023062914274571909443048", "结算");
  71. // result = new WeChatFunction().ProfitShareReturn("1646405429", "1611167423", "2023060810550382756164803", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), 0.02M);
  72. // result = new WeChatFunction().GetPublicKey();
  73. // string content = function.ReadInstance("1.txt");
  74. // string[] list = content.Split('\n');
  75. // foreach(string sub in list)
  76. // {
  77. // RedisDbconn.Instance.AddList("WeChatPayBackHd", sub);
  78. // }
  79. string logcontent = function.ReadInstance("直联微信.log");
  80. string[] contents = logcontent.Split('\n');
  81. foreach(string content in contents)
  82. {
  83. RedisDbconn.Instance.AddList("WeChatPayBack", content);
  84. }
  85. logcontent = function.ReadInstance("银联微信.log");
  86. contents = logcontent.Split('\n');
  87. foreach(string content in contents)
  88. {
  89. RedisDbconn.Instance.AddList("WeChatPayBackHd", content);
  90. }
  91. logcontent = function.ReadInstance("银联支付宝.log");
  92. contents = logcontent.Split('\n');
  93. foreach(string content in contents)
  94. {
  95. RedisDbconn.Instance.AddList("WeChatPayBackHd", content);
  96. }
  97. return result;
  98. }
  99. public string OrderCheck(string d, int m)
  100. {
  101. string[] datelist = d.Split('-');
  102. string path = "";
  103. if(m == 1) path = "支付宝服务平台支付回调(好哒)";
  104. if(m == 2) path = "微信服务平台支付回调(好哒)";
  105. string logcontent = function.ReadInstance("/log/" + path + "/" + datelist[0] + "/" + datelist[1] + "/" + datelist[2] + "/content.log");
  106. MatchCollection mc = Regex.Matches(logcontent, "{.*?}");
  107. foreach(Match match in mc)
  108. {
  109. string content = match.Value;
  110. RedisDbconn.Instance.AddList("WeChatPayBackHd", content);
  111. }
  112. return "ok";
  113. }
  114. }
  115. }