HomeController.cs 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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;
  9. using System.IO;
  10. using System.Text.RegularExpressions;
  11. namespace MySystem.Controllers
  12. {
  13. public class HomeController : Controller
  14. {
  15. private readonly ILogger<HomeController> _logger;
  16. public HomeController(ILogger<HomeController> logger)
  17. {
  18. _logger = logger;
  19. }
  20. public IActionResult Index()
  21. {
  22. return View();
  23. }
  24. public IActionResult Error()
  25. {
  26. string isapi = Request.Headers["Api"].ToString();
  27. if (isapi != "1")
  28. {
  29. if (Response.StatusCode == 500)
  30. {
  31. return Redirect("/public/errpage/pc/500.html");
  32. }
  33. else if (Response.StatusCode == 502)
  34. {
  35. return Redirect("/public/errpage/pc/502.html");
  36. }
  37. else if (Response.StatusCode == 404)
  38. {
  39. return Redirect("/public/errpage/pc/404.html");
  40. }
  41. else if (Response.StatusCode == 401)
  42. {
  43. return Content("401");
  44. }
  45. }
  46. return View();
  47. }
  48. public string auth(string app_id, string source, string application_type, string app_auth_code, string state)
  49. {
  50. return app_id + "\n" + source + "\n" + application_type + "\n" + app_auth_code + "\n" + state + "\n" + Request.QueryString.ToString();
  51. }
  52. public string test()
  53. {
  54. string result = "";
  55. WebCMSEntities maindb = new WebCMSEntities();
  56. List<string> nos = new List<string>();
  57. foreach(string no in nos)
  58. {
  59. ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
  60. if (order != null)
  61. {
  62. List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 999999);
  63. if (suborders.Count > 0)
  64. {
  65. ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
  66. if (suborder != null)
  67. {
  68. order.CurDivi = suborder.CurDivi;
  69. maindb.SaveChanges();
  70. RedisDbconn.Instance.RemoveFromList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, suborder);
  71. order.ReturnFlag = 0;
  72. maindb.SaveChanges();
  73. }
  74. }
  75. }
  76. }
  77. maindb.Dispose();
  78. return result;
  79. }
  80. public string test2()
  81. {
  82. string result = "ok";
  83. WebCMSEntities maindb = new WebCMSEntities();
  84. List<string> nos = new List<string>();
  85. nos.Add("2023122118000851456243816,288.4");
  86. nos.Add("2023122117593143700062399,341.04");
  87. nos.Add("2023122117325908930632327,254.15");
  88. nos.Add("2023122116415701143090181,312.26");
  89. nos.Add("2023122116413711877723909,276.83");
  90. nos.Add("2023122114085649698036050,342.45");
  91. nos.Add("2023122313533734425618726,299.78");
  92. nos.Add("2023122313282248497454670,246.97");
  93. nos.Add("2023122311000256069736155,261.82");
  94. nos.Add("2023122310594073141191302,304.84");
  95. nos.Add("2023122520210853072569713,191.59");
  96. nos.Add("2023122518244789260165229,186.53");
  97. nos.Add("2023122515274323574090329,275.95");
  98. nos.Add("2023122515252336206794004,261.82");
  99. nos.Add("2023122619342154468765968,178.31");
  100. nos.Add("2023122618011435195726036,258.07");
  101. nos.Add("2023122618001597671800401,248.51");
  102. nos.Add("2023122615422945713502403,191.84");
  103. nos.Add("2023122613362000858247931,227.61");
  104. nos.Add("2023122820200788070426381,198.57");
  105. nos.Add("2023122820125421416300639,237.29");
  106. nos.Add("2023122820123371996899445,182.56");
  107. nos.Add("2023122814020384897788563,167.38");
  108. nos.Add("2023122811030268206294741,228.91");
  109. nos.Add("2023122810460690412361230,210.46");
  110. nos.Add("2023122810364031620851479,202.11");
  111. nos.Add("2023122811124893906532985,224.09");
  112. nos.Add("2023122917185120082183642,152.23");
  113. nos.Add("2023122911233689014204746,163.27");
  114. nos.Add("2023122911214057116568112,122.39");
  115. nos.Add("2023122911184819662469868,180.80");
  116. foreach(string sub in nos)
  117. {
  118. string[] data = sub.Split(',');
  119. string no = data[0];
  120. decimal CurDivi = decimal.Parse(data[1]);
  121. ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
  122. if (order != null)
  123. {
  124. JsonData ProfitInfo = JsonMapper.ToObject(order.SeoDescription);
  125. int ProfitDays = int.Parse(function.CheckInt(ProfitInfo["ProfitDays"].ToString())); //活动有效时间
  126. if (order.IsAct == 1)
  127. {
  128. if (order.MaxDivi > order.CurDivi)
  129. {
  130. List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
  131. if (suborders.Count > 0)
  132. {
  133. ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
  134. if (suborder == null)
  135. {
  136. order.CurDivi = CurDivi;
  137. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
  138. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":254,");
  139. RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  140. order.ReturnFlag = 1;
  141. maindb.SaveChanges();
  142. }
  143. }
  144. }
  145. }
  146. }
  147. }
  148. maindb.Dispose();
  149. return result;
  150. }
  151. public string makeCode()
  152. {
  153. string code = "";
  154. List<string> list = new List<string>();
  155. string start = "LKB0123090019999";
  156. for(int i = 0;i<=9999;i++)
  157. {
  158. string num = i.ToString();
  159. for(int j = 0;j< 4 - i.ToString().Length;j++)
  160. {
  161. num = "0" + num;
  162. }
  163. string sn = dbconn.Encrypt3DES(start + num + function.get_Random(8), "l2k0b2#3");
  164. sn = sn.Substring(0, sn.Length - 1);
  165. code += System.Web.HttpUtility.UrlEncode(sn) + "\n";
  166. }
  167. return code;
  168. }
  169. }
  170. }