HomeController.cs 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.Models;
  10. using Library;
  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. }
  42. return View();
  43. }
  44. public string makerSn()
  45. {
  46. WebCMSEntities db = new WebCMSEntities();
  47. for (int i = 1; i <= 200; i++)
  48. {
  49. string EndNo = i.ToString();
  50. for (int j = 0; j < 6 - i.ToString().Length; j++)
  51. {
  52. EndNo = "0" + EndNo;
  53. }
  54. string PosSn = "KXS01220300102" + EndNo;
  55. db.PosMachinesTwo.Add(new PosMachinesTwo()
  56. {
  57. CreateDate = DateTime.Now,
  58. StoreId = 1,
  59. SourceStoreId = 1,
  60. SourcePosSn = PosSn,
  61. PosSn = PosSn,
  62. });
  63. db.SaveChanges();
  64. }
  65. db.Dispose();
  66. return "ok";
  67. }
  68. public string test()
  69. {
  70. // DataTable dt = CustomerSqlConn.dtable("select UserId,sum(ProfitAmount) from ProfitRecord where UserId>0 group by UserId", MysqlConn.connstr);
  71. // int index = 0;
  72. // WebCMSEntities db = new WebCMSEntities();
  73. // foreach (DataRow dr in dt.Rows)
  74. // {
  75. // index += 1;
  76. // int UserId = int.Parse(dr["UserId"].ToString());
  77. // decimal ProfitMoney = decimal.Parse(dr[1].ToString());
  78. // try
  79. // {
  80. // string IdBrand = UserId + "_0";
  81. // UserMachineData MachineData = db.UserMachineData.FirstOrDefault(m => m.IdBrand == IdBrand);
  82. // if (MachineData == null)
  83. // {
  84. // MachineData = db.UserMachineData.Add(new UserMachineData()
  85. // {
  86. // IdBrand = IdBrand,
  87. // }).Entity;
  88. // db.SaveChanges();
  89. // }
  90. // MachineData.TradeProfit = ProfitMoney;
  91. // db.SaveChanges();
  92. // }
  93. // catch (Exception ex)
  94. // {
  95. // function.WriteLog(DateTime.Now.ToString() + "\n" + UserId + "," + ProfitMoney + "\n" + ex.ToString(), "同步到余额异常");
  96. // }
  97. // function.WriteLog(index.ToString(), "同步分润数据");
  98. // }
  99. // db.Dispose();
  100. return "ok";
  101. }
  102. public string profit(int t = 0)
  103. {
  104. string date = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
  105. string OpTypeString = "";
  106. if (t > 0)
  107. {
  108. OpTypeString += "-" + t;
  109. }
  110. string check = function.ReadInstance("/Balance/1/" + date + OpTypeString + ".txt");
  111. if (string.IsNullOrEmpty(check))
  112. {
  113. function.WritePage("/Balance/1/", date + OpTypeString + ".txt", DateTime.Now.ToString());
  114. RedisDbconn.Instance.AddList("SycnProfitQueue2", "1#cut#" + date + "#cut#" + t + "#cut#系统");
  115. return "success";
  116. }
  117. return date + "分润已同步,请勿重复操作";
  118. }
  119. }
  120. }