HomeController.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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. using System.Text.RegularExpressions;
  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 string test(decimal a, decimal b, decimal g)
  27. {
  28. // List<int> MerchantIds = new List<int>();
  29. // MerchantIds.Add(5);
  30. // foreach(int MerchantId in MerchantIds)
  31. // {
  32. // RedisDbconn.Instance.AddList("MerchantConfirmHdQueue", "{\"MerchantId\":\"" + MerchantId + "\"}");
  33. // }
  34. // TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"),"2023100701","100");
  35. // MqLinksHelper.Instance.doSomething("LKB01230600250000585","100");
  36. WebCMSEntities db = new WebCMSEntities();
  37. Dictionary<string, decimal> ids = new Dictionary<string, decimal>();
  38. ids.Add("2023123120272680842405573", 30.08M);
  39. // ids.Add("2023110823050361106411696", 162.39M);
  40. // ids.Add("2023103111150680882895028", 129.97M);
  41. // ids.Add("2023110115111893112798296", 186.66M);
  42. // ids.Add("2023110119350047351848839", 219.15M);
  43. // ids.Add("2023103121092345128864326", 132.51M);
  44. // ids.Add("2023110119465569176817757", 219.16M);
  45. // ids.Add("2023110119570851706448968", 219.16M);
  46. // ids.Add("2023110119282078572281345", 208.32M);
  47. // ids.Add("2023103111025117492478602", 151.62M);
  48. // ids.Add("2023103111023104266492281", 129.96M);
  49. // ids.Add("2023103111020866149098706", 140.79M);
  50. // ids.Add("2023103111014803279616494", 162.45M);
  51. // ids.Add("2023103111011872712858973", 173.28M);
  52. foreach(string orderno in ids.Keys)
  53. {
  54. decimal cur = ids[orderno];
  55. ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
  56. order.CurDivi = cur;
  57. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
  58. order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":90,");
  59. RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  60. }
  61. // List<int> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1272").Select(m => m.Id).ToList();
  62. // DataTable dt = CustomerSqlConn.dtable("select OrderId,sum(GetMoney) money from ConsumerProfit where MerchantId=1272 group by OrderId order by OrderId", AppConfig.Base.SqlConnStr);
  63. // foreach(DataRow dr in dt.Rows)
  64. // {
  65. // decimal cur = decimal.Parse(dr["money"].ToString());
  66. // int OrderId = int.Parse(dr["OrderId"].ToString());
  67. // if(!orders.Contains(OrderId))
  68. // {
  69. // // string orderno = dr["OrderNo"].ToString();
  70. // ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId) ?? new ConsumerOrders();
  71. // if(order.MaxDivi - cur >= 1)
  72. // {
  73. // order.CurDivi = cur;
  74. // order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
  75. // order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":365,");
  76. // RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  77. // var list = db.ConsumerProfit.Where(m => m.OrderId == order.Id).OrderBy(m => m.Id).ToList();
  78. // foreach(var sub in list)
  79. // {
  80. // if(cur >= sub.GetMoney)
  81. // {
  82. // cur -= sub.GetMoney;
  83. // }
  84. // else
  85. // {
  86. // if(cur > 0)
  87. // {
  88. // var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
  89. // if(edit != null)
  90. // {
  91. // edit.GetMoney = cur;
  92. // db.SaveChanges();
  93. // }
  94. // }
  95. // else
  96. // {
  97. // var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
  98. // if(edit != null)
  99. // {
  100. // db.ConsumerProfit.Remove(edit);
  101. // db.SaveChanges();
  102. // }
  103. // }
  104. // }
  105. // }
  106. // }
  107. // }
  108. // }
  109. // List<int> ids = new List<int>();
  110. // ids.Add(4058);
  111. // List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1271");
  112. // foreach(int oid in ids)
  113. // {
  114. // function.WriteLog("oid:" + oid, "返现id");
  115. // decimal curDivi = 0;
  116. // ConsumerOrders order = orders.FirstOrDefault(m => m.Id == oid);
  117. // if(order == null)
  118. // {
  119. // order = db.ConsumerOrders.FirstOrDefault(m => m.Id == oid);
  120. // curDivi = order.MaxDivi;
  121. // function.WriteLog("出局", "返现id");
  122. // }
  123. // else
  124. // {
  125. // function.WriteLog("未出局", "返现id");
  126. // curDivi = order.CurDivi;
  127. // }
  128. // if(order != null)
  129. // {
  130. // List<ConsumerProfit> profits = db.ConsumerProfit.Where(m => m.OrderId == oid).ToList();
  131. // foreach(ConsumerProfit profit in profits)
  132. // {
  133. // if(curDivi >= profit.GetMoney)
  134. // {
  135. // curDivi -= profit.GetMoney;
  136. // }
  137. // else
  138. // {
  139. // function.WriteLog(profit.Id.ToString(), "返现id");
  140. // }
  141. // }
  142. // }
  143. // function.WriteLog("\n\n", "返现id");
  144. // }
  145. db.Dispose();
  146. // decimal settleAmount = b / 100M;
  147. // decimal divideAmt = (1 - 0.0038M) * a;
  148. // divideAmt = decimal.Parse(divideAmt.ToString("f2"));
  149. // decimal hdfee = 0.0038M * a * (1 - g / 100 - 0.01M);
  150. // hdfee = decimal.Parse(hdfee.ToString("f2"));
  151. // decimal servicefee = 0.01M * a - hdfee;
  152. // servicefee = decimal.Parse(servicefee.ToString("f2"));
  153. // decimal amount = a*(1-0.0038M) - servicefee;
  154. // amount = decimal.Parse(amount.ToString("f2"));
  155. // decimal otherAmt = settleAmount - servicefee - amount;
  156. // if(otherAmt != 0)
  157. // {
  158. // amount += otherAmt;
  159. // }
  160. // amount = amount * 100; //金额(分)
  161. // servicefee = servicefee * 100;
  162. // string seviceAmount = servicefee.ToString("f0"); //服务费
  163. // string amountAmount = amount.ToString("f0");
  164. // return amountAmount + ":" + seviceAmount;
  165. return "ok";
  166. }
  167. public string bindapp(int mid)
  168. {
  169. // 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);
  170. // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where Id=" + mid, AppConfig.Base.SqlConnStr);
  171. // foreach(DataRow dr in dt.Rows)
  172. // {
  173. // CheckWeChatSignService.Instance.StartDo(new QueryMerchantStatus()
  174. // {
  175. // MerchantId = dr["Id"].ToString(),
  176. // MerchantNo = dr["MchtNo"].ToString(),
  177. // });
  178. // }
  179. Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
  180. WebCMSEntities db = new WebCMSEntities();
  181. MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
  182. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
  183. string pwd = "417027";
  184. merchant.LoginPwd = function.MD532(pwd);
  185. Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
  186. if (info == null)
  187. {
  188. info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
  189. {
  190. LoginMobile = merchantadd.MobilePhone,
  191. }).Entity;
  192. db1.SaveChanges();
  193. }
  194. info.LoginPwd = function.MD532(pwd);
  195. db1.SaveChanges();
  196. Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
  197. if (infolink == null)
  198. {
  199. infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
  200. {
  201. LoginId = info.Id,
  202. MerchantId = merchantadd.Id,
  203. Kind = 2,
  204. }).Entity;
  205. db1.SaveChanges();
  206. }
  207. db1.Dispose();
  208. db.Dispose();
  209. return "ok";
  210. }
  211. public string clearQueue(int OrderId, int MerchantId, int PayMode)
  212. {
  213. List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId + "", 1, 100000);
  214. foreach(ConsumerOrders sub in list)
  215. {
  216. if(sub.Id == OrderId)
  217. {
  218. RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:2:1272", sub);
  219. }
  220. }
  221. return "ok";
  222. }
  223. }
  224. }