HomeController.cs 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using Microsoft.AspNetCore.Mvc;
  7. using Microsoft.Extensions.Logging;
  8. using Library;
  9. using LitJson;
  10. using System.Data;
  11. using MySystem.Models.Main;
  12. namespace MySystem.Controllers
  13. {
  14. public class HomeController : Controller
  15. {
  16. private readonly ILogger<HomeController> _logger;
  17. public HomeController(ILogger<HomeController> logger)
  18. {
  19. _logger = logger;
  20. }
  21. public IActionResult Index()
  22. {
  23. return View();
  24. }
  25. public string test(decimal a, decimal b, decimal g)
  26. {
  27. // List<int> MerchantIds = new List<int>();
  28. // MerchantIds.Add(5);
  29. // foreach(int MerchantId in MerchantIds)
  30. // {
  31. // RedisDbconn.Instance.AddList("MerchantConfirmHdQueue", "{\"MerchantId\":\"" + MerchantId + "\"}");
  32. // }
  33. // TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"),"2023100701","100");
  34. // MqLinksHelper.Instance.doSomething("LKB01230600250000585","100");
  35. WebCMSEntities db = new WebCMSEntities();
  36. Dictionary<string, decimal> ids = new Dictionary<string, decimal>();
  37. ids.Add("2023110100101889870873103", 165.01M);
  38. ids.Add("2023110823050361106411696", 162.39M);
  39. ids.Add("2023103111150680882895028", 129.97M);
  40. ids.Add("2023110115111893112798296", 186.66M);
  41. ids.Add("2023110119350047351848839", 219.15M);
  42. ids.Add("2023103121092345128864326", 132.51M);
  43. ids.Add("2023110119465569176817757", 219.16M);
  44. ids.Add("2023110119570851706448968", 219.16M);
  45. ids.Add("2023110119282078572281345", 208.32M);
  46. ids.Add("2023103111025117492478602", 151.62M);
  47. ids.Add("2023103111023104266492281", 129.96M);
  48. ids.Add("2023103111020866149098706", 140.79M);
  49. ids.Add("2023103111014803279616494", 162.45M);
  50. ids.Add("2023103111011872712858973", 173.28M);
  51. foreach(string orderno in ids.Keys)
  52. {
  53. decimal cur = ids[orderno];
  54. ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
  55. order.CurDivi = cur;
  56. RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  57. }
  58. // List<int> ids = new List<int>();
  59. // ids.Add(4058);
  60. // List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1271");
  61. // foreach(int oid in ids)
  62. // {
  63. // function.WriteLog("oid:" + oid, "返现id");
  64. // decimal curDivi = 0;
  65. // ConsumerOrders order = orders.FirstOrDefault(m => m.Id == oid);
  66. // if(order == null)
  67. // {
  68. // order = db.ConsumerOrders.FirstOrDefault(m => m.Id == oid);
  69. // curDivi = order.MaxDivi;
  70. // function.WriteLog("出局", "返现id");
  71. // }
  72. // else
  73. // {
  74. // function.WriteLog("未出局", "返现id");
  75. // curDivi = order.CurDivi;
  76. // }
  77. // if(order != null)
  78. // {
  79. // List<ConsumerProfit> profits = db.ConsumerProfit.Where(m => m.OrderId == oid).ToList();
  80. // foreach(ConsumerProfit profit in profits)
  81. // {
  82. // if(curDivi >= profit.GetMoney)
  83. // {
  84. // curDivi -= profit.GetMoney;
  85. // }
  86. // else
  87. // {
  88. // function.WriteLog(profit.Id.ToString(), "返现id");
  89. // }
  90. // }
  91. // }
  92. // function.WriteLog("\n\n", "返现id");
  93. // }
  94. // db.Dispose();
  95. // decimal settleAmount = b / 100M;
  96. // decimal divideAmt = (1 - 0.0038M) * a;
  97. // divideAmt = decimal.Parse(divideAmt.ToString("f2"));
  98. // decimal hdfee = 0.0038M * a * (1 - g / 100 - 0.01M);
  99. // hdfee = decimal.Parse(hdfee.ToString("f2"));
  100. // decimal servicefee = 0.01M * a - hdfee;
  101. // servicefee = decimal.Parse(servicefee.ToString("f2"));
  102. // decimal amount = a*(1-0.0038M) - servicefee;
  103. // amount = decimal.Parse(amount.ToString("f2"));
  104. // decimal otherAmt = settleAmount - servicefee - amount;
  105. // if(otherAmt != 0)
  106. // {
  107. // amount += otherAmt;
  108. // }
  109. // amount = amount * 100; //金额(分)
  110. // servicefee = servicefee * 100;
  111. // string seviceAmount = servicefee.ToString("f0"); //服务费
  112. // string amountAmount = amount.ToString("f0");
  113. // return amountAmount + ":" + seviceAmount;
  114. return "ok";
  115. }
  116. public string bindapp(int mid)
  117. {
  118. // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where HdStatus=3 and CreateDate>='2023-10-01 00:00:00' and MchtNo!='' and MchtNo is not null", AppConfig.Base.SqlConnStr);
  119. // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where Id=" + mid, AppConfig.Base.SqlConnStr);
  120. // foreach(DataRow dr in dt.Rows)
  121. // {
  122. // CheckWeChatSignService.Instance.StartDo(new QueryMerchantStatus()
  123. // {
  124. // MerchantId = dr["Id"].ToString(),
  125. // MerchantNo = dr["MchtNo"].ToString(),
  126. // });
  127. // }
  128. Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
  129. WebCMSEntities db = new WebCMSEntities();
  130. MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
  131. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
  132. string pwd = "417027";
  133. merchant.LoginPwd = function.MD532(pwd);
  134. Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
  135. if (info == null)
  136. {
  137. info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
  138. {
  139. LoginMobile = merchantadd.MobilePhone,
  140. }).Entity;
  141. db1.SaveChanges();
  142. }
  143. info.LoginPwd = function.MD532(pwd);
  144. db1.SaveChanges();
  145. Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
  146. if (infolink == null)
  147. {
  148. infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
  149. {
  150. LoginId = info.Id,
  151. MerchantId = merchantadd.Id,
  152. Kind = 2,
  153. }).Entity;
  154. db1.SaveChanges();
  155. }
  156. db1.Dispose();
  157. db.Dispose();
  158. return "ok";
  159. }
  160. }
  161. }