HomeController.cs 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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("2023122911184819662469868,180.80");
  87. foreach(string sub in nos)
  88. {
  89. string[] data = sub.Split(',');
  90. string no = data[0];
  91. decimal CurDivi = decimal.Parse(data[1]);
  92. ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
  93. if (order != null)
  94. {
  95. JsonData ProfitInfo = JsonMapper.ToObject(order.SeoDescription);
  96. int ProfitDays = int.Parse(function.CheckInt(ProfitInfo["ProfitDays"].ToString())); //活动有效时间
  97. if (order.IsAct == 1)
  98. {
  99. if (order.MaxDivi > order.CurDivi)
  100. {
  101. List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
  102. if (suborders.Count > 0)
  103. {
  104. ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
  105. if (suborder == null)
  106. {
  107. order.CurDivi = CurDivi;
  108. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
  109. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":254,");
  110. RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  111. order.ReturnFlag = 1;
  112. maindb.SaveChanges();
  113. }
  114. }
  115. }
  116. }
  117. }
  118. }
  119. maindb.Dispose();
  120. return result;
  121. }
  122. public string makeCode()
  123. {
  124. string code = "";
  125. List<string> list = new List<string>();
  126. string start = "LKB0123090019999";
  127. for(int i = 0;i<=9999;i++)
  128. {
  129. string num = i.ToString();
  130. for(int j = 0;j< 4 - i.ToString().Length;j++)
  131. {
  132. num = "0" + num;
  133. }
  134. string sn = dbconn.Encrypt3DES(start + num + function.get_Random(8), "l2k0b2#3");
  135. sn = sn.Substring(0, sn.Length - 1);
  136. code += System.Web.HttpUtility.UrlEncode(sn) + "\n";
  137. }
  138. return code;
  139. }
  140. public string test1()
  141. {
  142. DateTime start = DateTime.Parse("2025-01-01 00:00:00");
  143. List<string> list = new List<string>();
  144. list.Add("LKB01231000599995661");
  145. WebCMSEntities db = new WebCMSEntities();
  146. foreach(string sub in list)
  147. {
  148. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == sub && m.BindingState == 1 && m.BindingTime >= start);
  149. if(pos != null)
  150. {
  151. MerchantAddInfo addMer = db.MerchantAddInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new MerchantAddInfo();
  152. PosPushDataNewHelper.Bind(addMer, pos);
  153. }
  154. }
  155. db.Dispose();
  156. return "ok";
  157. }
  158. }
  159. }