HomeController.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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)
  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("2023110210011368216017215", 262.47M);
  38. // foreach(string orderno in ids.Keys)
  39. // {
  40. // decimal cur = ids[orderno];
  41. // ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
  42. // order.CurDivi = cur;
  43. // RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
  44. // }
  45. // List<int> ids = new List<int>();
  46. // ids.Add(4058);
  47. // List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1271");
  48. // foreach(int oid in ids)
  49. // {
  50. // function.WriteLog("oid:" + oid, "返现id");
  51. // decimal curDivi = 0;
  52. // ConsumerOrders order = orders.FirstOrDefault(m => m.Id == oid);
  53. // if(order == null)
  54. // {
  55. // order = db.ConsumerOrders.FirstOrDefault(m => m.Id == oid);
  56. // curDivi = order.MaxDivi;
  57. // function.WriteLog("出局", "返现id");
  58. // }
  59. // else
  60. // {
  61. // function.WriteLog("未出局", "返现id");
  62. // curDivi = order.CurDivi;
  63. // }
  64. // if(order != null)
  65. // {
  66. // List<ConsumerProfit> profits = db.ConsumerProfit.Where(m => m.OrderId == oid).ToList();
  67. // foreach(ConsumerProfit profit in profits)
  68. // {
  69. // if(curDivi >= profit.GetMoney)
  70. // {
  71. // curDivi -= profit.GetMoney;
  72. // }
  73. // else
  74. // {
  75. // function.WriteLog(profit.Id.ToString(), "返现id");
  76. // }
  77. // }
  78. // }
  79. // function.WriteLog("\n\n", "返现id");
  80. // }
  81. // db.Dispose();
  82. decimal hdfee = 0.0038M * a * (1 - 0.9M - 0.01M);
  83. hdfee = decimal.Parse(hdfee.ToString("f2"));
  84. decimal servicefee = 0.01M * a - hdfee;
  85. servicefee = decimal.Parse(servicefee.ToString("f2"));
  86. decimal amount = a*(1-0.0038M) - servicefee;
  87. amount = amount * 100; //金额(分)
  88. servicefee = servicefee * 100;
  89. string seviceAmount = servicefee.ToString("f0"); //服务费
  90. string amountAmount = amount.ToString("f0");
  91. return amountAmount + ":" + seviceAmount;
  92. }
  93. public string bindapp(int mid)
  94. {
  95. // 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);
  96. // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where Id=" + mid, AppConfig.Base.SqlConnStr);
  97. // foreach(DataRow dr in dt.Rows)
  98. // {
  99. // CheckWeChatSignService.Instance.StartDo(new QueryMerchantStatus()
  100. // {
  101. // MerchantId = dr["Id"].ToString(),
  102. // MerchantNo = dr["MchtNo"].ToString(),
  103. // });
  104. // }
  105. Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
  106. WebCMSEntities db = new WebCMSEntities();
  107. MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
  108. MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
  109. string pwd = "417027";
  110. merchant.LoginPwd = function.MD532(pwd);
  111. Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
  112. if (info == null)
  113. {
  114. info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
  115. {
  116. LoginMobile = merchantadd.MobilePhone,
  117. }).Entity;
  118. db1.SaveChanges();
  119. }
  120. info.LoginPwd = function.MD532(pwd);
  121. db1.SaveChanges();
  122. Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
  123. if (infolink == null)
  124. {
  125. infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
  126. {
  127. LoginId = info.Id,
  128. MerchantId = merchantadd.Id,
  129. Kind = 2,
  130. }).Entity;
  131. db1.SaveChanges();
  132. }
  133. db1.Dispose();
  134. db.Dispose();
  135. return "ok";
  136. }
  137. }
  138. }