HomeController.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Data;
  6. using System.Threading.Tasks;
  7. using Microsoft.AspNetCore.Mvc;
  8. using Microsoft.Extensions.Logging;
  9. using MySystem.PxcModels;
  10. using System.Threading;
  11. using Library;
  12. using LitJson;
  13. namespace MySystem.Controllers
  14. {
  15. public class HomeController : Controller
  16. {
  17. private readonly ILogger<HomeController> _logger;
  18. public HomeController(ILogger<HomeController> logger)
  19. {
  20. _logger = logger;
  21. }
  22. public IActionResult Index()
  23. {
  24. return View();
  25. }
  26. public IActionResult Error()
  27. {
  28. string isapi = Request.Headers["Api"].ToString();
  29. if (isapi != "1")
  30. {
  31. if (Response.StatusCode == 500)
  32. {
  33. return Redirect("/public/errpage/pc/500.html");
  34. }
  35. else if (Response.StatusCode == 502)
  36. {
  37. return Redirect("/public/errpage/pc/502.html");
  38. }
  39. else if (Response.StatusCode == 404)
  40. {
  41. return Redirect("/public/errpage/pc/404.html");
  42. }
  43. }
  44. return View();
  45. }
  46. public string tmp()
  47. {
  48. string result = "";
  49. // string conn = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  50. // DataTable dt = CustomerSqlConn.dtable("select UserId from HelpProfitAmountSummary where TradeMonth>MaxAmount and TradeMonth='202301'", conn);
  51. // foreach(DataRow dr in dt.Rows)
  52. // {
  53. // int UserId = int.Parse(dr["UserId"].ToString());
  54. // decimal HelpAmount = 0; //当天总交易额
  55. // DataTable dtsub = CustomerSqlConn.dtable("SELECT SUM(TradeAmount) TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId IN(SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + ") AND TradeDate='20230101'", conn);
  56. // if(dtsub.Rows.Count > 0)
  57. // {
  58. // HelpAmount = decimal.Parse(function.CheckNum(dtsub.Rows[0]["TradeAmount"].ToString()));
  59. // }
  60. // result += test(UserId, HelpAmount);
  61. // result += "\n\n";
  62. // }
  63. return result;
  64. }
  65. public string test(int UserId, decimal Amount)
  66. {
  67. // StatHelpProfitService.Instance.ResetMaxTradeAmountGo("202301");
  68. string result = "";
  69. // string conn = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
  70. // // int UserId = 145842;
  71. // Dictionary<string, decimal> dic = new Dictionary<string, decimal>();
  72. // dic.Add("31", Amount);
  73. // foreach(string day in dic.Keys)
  74. // {
  75. // DataTable dt = CustomerSqlConn.dtable("SELECT MerchantId FROM HelpProfitMerIds WHERE UserId=" + UserId + " order by RAND()", conn);
  76. // decimal total = dic[day];
  77. // decimal avg = total / dt.Rows.Count;
  78. // int min = ((int)avg - 100) * 100;
  79. // if(min < 1) min = 1;
  80. // int max = ((int)avg + 100) * 100;
  81. // foreach(DataRow dr in dt.Rows)
  82. // {
  83. // string MerchantId = dr["MerchantId"].ToString();
  84. // decimal amount = (decimal)function.get_Random(min, max) / 100;
  85. // if(total > 0)
  86. // {
  87. // if(total < amount)
  88. // {
  89. // amount = total;
  90. // }
  91. // DataTable check = CustomerSqlConn.dtable("SELECT Id,TradeAmount FROM HelpProfitMerTradeSummay WHERE MerchantId=" + MerchantId + " and TradeDate='202301" + day + "'", conn);
  92. // if(check.Rows.Count > 0)
  93. // {
  94. // if(day == "30")
  95. // {
  96. // decimal today = decimal.Parse(check.Rows[0]["TradeAmount"].ToString());
  97. // if(today < amount)
  98. // {
  99. // amount -= today;
  100. // }
  101. // else
  102. // {
  103. // amount = 0;
  104. // }
  105. // }
  106. // if(amount > 0) result += "update HelpProfitMerTradeSummay set TradeAmount=" + amount + " where Id=" + check.Rows[0]["Id"].ToString() + ";\n";
  107. // }
  108. // else
  109. // {
  110. // if(amount > 0) result += "INSERT INTO HelpProfitMerTradeSummay (`TradeAmount`, `TradeDate`, `TradeMonth`, `MerchantId`) VALUES (" + amount + ", '202301" + day + "', '202301', " + MerchantId + ");\n";
  111. // }
  112. // check = CustomerSqlConn.dtable("SELECT Id FROM HelpProfitMerTradeMonthSummay WHERE MerchantId=" + MerchantId + " and TradeMonth='202301'", conn);
  113. // if(check.Rows.Count > 0)
  114. // {
  115. // if(amount > 0) result += "update HelpProfitMerTradeMonthSummay set TradeAmount=TradeAmount+" + amount + " where Id=" + check.Rows[0][0].ToString() + ";\n";
  116. // }
  117. // else
  118. // {
  119. // if(amount > 0) result += "INSERT INTO HelpProfitMerTradeMonthSummay (`TradeAmount`, `TradeMonth`, `MerchantId`) VALUES (" + amount + ", '202301', " + MerchantId + ");\n";
  120. // }
  121. // total -= amount;
  122. // }
  123. // else
  124. // {
  125. // break;
  126. // }
  127. // }
  128. // }
  129. return result;
  130. }
  131. }
  132. }