HomeController.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. using System.Collections.Generic;
  2. using Microsoft.AspNetCore.Mvc;
  3. using Microsoft.Extensions.Logging;
  4. using MySystem.MainModels;
  5. using System.Linq;
  6. using Library;
  7. using LitJson;
  8. using System.Threading.Tasks;
  9. using System;
  10. namespace MySystem.Controllers
  11. {
  12. public class HomeController : Controller
  13. {
  14. private readonly ILogger<HomeController> _logger;
  15. public HomeController(ILogger<HomeController> logger)
  16. {
  17. _logger = logger;
  18. }
  19. public IActionResult Index()
  20. {
  21. return View();
  22. }
  23. public IActionResult Error()
  24. {
  25. string isapi = Request.Headers["Api"].ToString();
  26. if (isapi != "1")
  27. {
  28. if (Response.StatusCode == 500)
  29. {
  30. return Redirect("/public/errpage/pc/500.html");
  31. }
  32. else if (Response.StatusCode == 502)
  33. {
  34. return Redirect("/public/errpage/pc/502.html");
  35. }
  36. else if (Response.StatusCode == 404)
  37. {
  38. return Redirect("/public/errpage/pc/404.html");
  39. }
  40. }
  41. return View();
  42. }
  43. public string setFee(string merNo, string sn, decimal fee, int addRate = 0)
  44. {
  45. string content = PublicImportDataService.Instance.SetFee(merNo, sn, fee, addRate);
  46. JsonData obj = JsonMapper.ToObject(content);
  47. if (obj["code"].ToString() == "000000")
  48. {
  49. content += "|" + PublicImportDataService.Instance.Decrypt(obj["data"].ToString());
  50. }
  51. return content;
  52. }
  53. public string test()
  54. {
  55. // List<string> list = new List<string>();
  56. // foreach(string sub in list)
  57. // {
  58. // string url = "https://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_MACHINE_PRIZE_CONFIG_DIVISION&m=" + sub + "&ids=3";
  59. // string content = function.GetWebRequest(url);
  60. // }
  61. // return "ok";
  62. return PublicImportDataService.Instance.LePassGetExpiredIdCardUrl("5546616071");
  63. // string content = "MzdEcXp6ZkcvODlXL1NNWDhrRVAzemRTZC9zTityQlpXRHVxcGdLQlpRZz0=";
  64. // return PublicImportDataService.Instance.AesDecryptForIv(content);
  65. }
  66. public ActionResult LogSelect()
  67. {
  68. return View();
  69. }
  70. public async Task<string> LogSelectResult(string condi)
  71. {
  72. string result = "";
  73. string[] condiList = condi.Split('|');
  74. string logstore = "connect-log";
  75. string topic = condiList[0];
  76. string keyword = condiList[1];
  77. string month = condiList[2];
  78. if(topic.EndsWith("推送消息"))
  79. {
  80. logstore = "spserver";
  81. }
  82. IList<IDictionary<string, string>> logs = await SLS.GetLogs(logstore, topic, "* and content: " + keyword, DateTimeOffset.Now.AddMonths(-int.Parse(month)));
  83. foreach(IDictionary<string, string> log in logs)
  84. {
  85. result += log["__tag__:datetime"] + "\n";
  86. result += log["content"] + "\n";
  87. result += "\n--------------------------------------------------------------------------------------------------\n\n";
  88. }
  89. return result;
  90. }
  91. public async Task<string> SLSLog()
  92. {
  93. string logstore = "spserver";
  94. Dictionary<string, string> brands = new Dictionary<string, string>();
  95. // brands.Add("开店宝", "2");
  96. // brands.Add("乐刷", "4");
  97. // brands.Add("立刷", "6");
  98. // brands.Add("立刷微电签", "22");
  99. // brands.Add("盛付通", "7");
  100. // brands.Add("海科电签", "8");
  101. // brands.Add("海科大POS", "9");
  102. // brands.Add("联动", "10");
  103. brands.Add("盒易付电签", "12");
  104. // brands.Add("联客宝", "15");
  105. brands.Add("拉卡拉", "30");
  106. // brands.Add("联动掌中宝", "34");
  107. // brands.Add("国通星驿付", "38");
  108. // brands.Add("金控", "27");
  109. foreach(var topic in brands.Keys)
  110. {
  111. int page = 0;
  112. bool op = true;
  113. while(op)
  114. {
  115. int skip = page * 50;
  116. IList<IDictionary<string, string>> logs = await SLS.GetLogs(logstore, topic + "商户信息通知推送消息", "", DateTimeOffset.Parse("2026-01-23 00:00:00"), skip, 50);
  117. if(logs.Count > 0)
  118. {
  119. foreach(IDictionary<string, string> log in logs)
  120. {
  121. DateTime time = DateTime.Parse(log["__tag__:datetime"]);
  122. if(time < DateTime.Parse("2026-01-23 11:30:00"))
  123. {
  124. string content = log["content"];
  125. if(content.IndexOf("{") > 0)
  126. {
  127. content = content.Substring(content.IndexOf("{"));
  128. }
  129. RedisDbconn.Instance.AddList("kxs_merchantinfo_list_" + brands[topic], content);
  130. }
  131. }
  132. page += 1;
  133. }
  134. else
  135. {
  136. op = false;
  137. }
  138. }
  139. }
  140. return "ok";
  141. }
  142. public ActionResult SourceDataToDb()
  143. {
  144. WebCMSEntities db = new WebCMSEntities();
  145. var list = db.KqProducts.Select(m => new { m.SpProductType, m.Name }).ToList();
  146. List<string> strlist = new List<string>();
  147. foreach(var sub in list)
  148. {
  149. strlist.Add(sub.SpProductType + "|" + sub.Name);
  150. }
  151. db.Dispose();
  152. ViewBag.dic = strlist;
  153. return View();
  154. }
  155. public string SourceDataToDbResult(string content)
  156. {
  157. RedisDbconn.Instance.AddList("DataToDbQueue", content);
  158. return "ok";
  159. }
  160. public string prize()
  161. {
  162. // List<string> list = new List<string>();
  163. // list.Add("LDN7HDQM024100912776|252167");
  164. // foreach(string sub in list)
  165. // {
  166. // string[] data = sub.Split('|');
  167. // function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m={\"brand_id\":29,\"ext_field\":\"830_01\",\"pos_sn\":\"" + data[0] + "\",\"user_id\":" + data[1] + "}&ids=67");
  168. // }
  169. // list = new List<string>();
  170. // list.Add("LDN7HDQM024100912625|297660");
  171. // foreach(string sub in list)
  172. // {
  173. // string[] data = sub.Split('|');
  174. // function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m={\"brand_id\":29,\"ext_field\":\"830_01\",\"pos_sn\":\"" + data[0] + "\",\"user_id\":" + data[1] + "}&ids=67");
  175. // }
  176. // string[] data = function.ReadInstance("1.txt").Split('\n');
  177. // foreach(string sub in data)
  178. // {
  179. // function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_LKB_PRO_PRIZE_CONFIG_DIVISION&m=" + sub + "&ids=69");
  180. // }
  181. // string[] data = function.ReadInstance("tmp/1.txt").Split('\n');
  182. // Dictionary<string, string> sn = new Dictionary<string, string>();
  183. // foreach(string sub in data)
  184. // {
  185. // string[] subdata = sub.Split(',');
  186. // sn.Add(subdata[0], subdata[1]);
  187. // }
  188. string[] data = function.ReadInstance("tmp/1.txt").Split('\n');
  189. foreach(string sub in data)
  190. {
  191. // string[] subdata = sub.Split(',');
  192. // if(sn.ContainsKey(subdata[0]))
  193. // {
  194. // string pos = subdata[0];
  195. // string userId = sn[subdata[0]];
  196. // string kind = subdata[2];
  197. // string amount = subdata[1];
  198. // string listId = "";
  199. // if(kind == "833_01") listId = "81";
  200. // if(kind == "833_02") listId = "82";
  201. // listId += ",83";
  202. // string m = "{\"brand_id\":36,\"ext_field\":\"" + kind + "\",\"pos_sn\":\"" + pos + "\",\"user_id\":" + userId + ",\"prize\":\"" + amount + "\"}";
  203. // function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_HAODA_PRIZE_CONFIG_DIVISION&m=" + m + "&ids=" + listId);
  204. // }
  205. string s = function.GetWebRequest("http://logic-executor-api.kexiaoshuang.com/noauth/prize/pushbyone?n=QUEUE_KXS_LKB_PRO_PRIZE_CONFIG_DIVISION&m=" + sub + "&ids=72,73,75");
  206. }
  207. return "ok";
  208. }
  209. }
  210. }