HomeController.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. // 大盟主标记扫描
  47. public string leaderflag()
  48. {
  49. WebCMSEntities db = new WebCMSEntities();
  50. List<int> ids = new List<int>();
  51. // List<PosCouponRecord> records = db.PosCouponRecord.Where(m => m.FromUserId == 597).ToList();
  52. // foreach(PosCouponRecord record in records)
  53. // {
  54. // ids.Add(record.PosCouponId);
  55. // }
  56. ids.Add(6843);
  57. List<PosCoupons> coupons = db.PosCoupons.Where(m => ids.Contains(m.Id) && m.IsUse == 1).ToList();
  58. foreach (PosCoupons coupon in coupons)
  59. {
  60. PosSns.Add(coupon.ExchangeCode);
  61. }
  62. foreach (PosCoupons coupon in coupons)
  63. {
  64. ChildNo(db, coupon.ExchangeCode, coupon.ExchangeCode, coupon.LeaderUserId);
  65. }
  66. // db.SaveChanges();
  67. db.Dispose();
  68. return "ok";
  69. }
  70. List<string> nos = new List<string>();
  71. private void ChildNo(WebCMSEntities db, string RootCheckNo, string CheckNo, int LeaderUserId)
  72. {
  73. MachineApply apply = db.MachineApply.FirstOrDefault(m => m.SwapSnExpand.Contains(CheckNo));
  74. if(apply != null)
  75. {
  76. int len = 0;
  77. string[] SnList = apply.SwapSnExpand.TrimEnd('\n').Split('\n');
  78. foreach(string sn in SnList)
  79. {
  80. if(PosSns.Contains(sn.Split(':')[0]) || nos.Contains(sn.Split(':')[0]))
  81. {
  82. len += 1;
  83. }
  84. }
  85. Orders order = db.Orders.FirstOrDefault(m => m.Id == apply.QueryCount);
  86. if(order != null)
  87. {
  88. if(!string.IsNullOrEmpty(order.SnNos))
  89. {
  90. if(order.SnNos.Contains(","))
  91. {
  92. string[] SwapSnExpands = order.SnNos.TrimEnd(',').Split(',');
  93. int index = 0;
  94. foreach(string no in SwapSnExpands)
  95. {
  96. if(!nos.Contains(no) && index < len)
  97. {
  98. index += 1;
  99. nos.Add(no);
  100. ChildNo(db, RootCheckNo, no, LeaderUserId);
  101. }
  102. }
  103. }
  104. else
  105. {
  106. string[] SwapSnExpands = order.SnNos.TrimEnd('\n').Split('\n');
  107. int index = 0;
  108. foreach(string no in SwapSnExpands)
  109. {
  110. if(!nos.Contains(no) && index < len)
  111. {
  112. index += 1;
  113. nos.Add(no);
  114. ChildNo(db, RootCheckNo, no, LeaderUserId);
  115. }
  116. }
  117. }
  118. }
  119. else
  120. {
  121. MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == CheckNo) ?? new MachineForSnNo();
  122. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forSnNo.SnId);
  123. if(pos != null)
  124. {
  125. // pos.LeaderUserId = LeaderUserId;
  126. // Library.function.WriteLog(LeaderUserId + ":" + pos.PosSn + ":" + apply.SwapSnExpand.TrimEnd('\n').Split('\n').Length, "大盟主奖励标记机具");
  127. Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
  128. Library.function.WriteLog(pos.PosSn + ":" + RootCheckNo + ":" + user.MakerCode + ":" + user.RealName, "大盟主奖励标记机具");
  129. }
  130. }
  131. }
  132. }
  133. else
  134. {
  135. MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == CheckNo) ?? new MachineForSnNo();
  136. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m=>m.Id == forSnNo.SnId);
  137. if(pos != null)
  138. {
  139. // pos.LeaderUserId = LeaderUserId;
  140. // Library.function.WriteLog(LeaderUserId + ":" + pos.PosSn, "大盟主奖励标记机具");
  141. Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
  142. Library.function.WriteLog(pos.PosSn + ":" + RootCheckNo + ":" + user.MakerCode + ":" + user.RealName, "大盟主奖励标记机具");
  143. }
  144. }
  145. }
  146. List<string> PosSns = new List<string>();
  147. public string ScanNos()
  148. {
  149. PosSns = new List<string>();
  150. PosSns.Add("00005002681889125851");
  151. WebCMSEntities db = new WebCMSEntities();
  152. foreach(string PosSn in PosSns)
  153. {
  154. ChildNo(db, PosSn, PosSn, 0);
  155. }
  156. db.Dispose();
  157. return "ok";
  158. }
  159. public string test()
  160. {
  161. // WebCMSEntities db = new WebCMSEntities();
  162. // AlipayPayBack2Service.Instance.DoOrderV2(db, 269424);
  163. // db.Dispose();
  164. // List<int> ids = new List<int>();
  165. // foreach(int id in ids)
  166. // {
  167. // TradeChangeService.Instance.StatTradeAmount(id, 2, 1);
  168. // }
  169. // WebCMSEntities db = new WebCMSEntities();
  170. // PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == "8610086012" && m.ActivationState == 0 && !string.IsNullOrEmpty(m.SeoKeyword) && m.SeoKeyword != "0" && (m.CreditTrade >= 1000 || m.BrandId == 14));
  171. // if(pos != null)
  172. // {
  173. // SycnSpTradeService.Instance.ActPos(db, pos, 0, 30);
  174. // }
  175. // db.Dispose();
  176. string result = "";
  177. // result += SetDepositPostService.Instance.ModifyFee("00005002681889119293", 0.0063M, "3") + "\n\n";
  178. result += SetDepositPostService.Instance.SetFeeForSft("39103661", "0.6300", "3") + "\n\n";
  179. // result += SetDepositPostService.Instance.LDFeeRate("110000004032435", "0.0063", 10, 3) + "\n\n";
  180. // result += SetDepositPostService.Instance.LDFeeRate("110000004008674", "0.0063", 11, 3) + "\n\n";
  181. return result;
  182. }
  183. public string setlee()
  184. {
  185. WebCMSEntities db = new WebCMSEntities();
  186. List<string> poslist = new List<string>();
  187. poslist.Add("00003102722201179816714");
  188. foreach(string PosSn in poslist)
  189. {
  190. PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
  191. if(pos != null)
  192. {
  193. string info = "{\"RecordId\":\"\",\"PosId\":\"" + pos.Id + "\",\"Fee\": \"0.6\",\"Kind\": \"2\",\"OpMan\": \"系统\"}";
  194. RedisDbconn.Instance.AddList("SetDepositPostQueue", info);
  195. }
  196. }
  197. db.Dispose();
  198. return "ok";
  199. }
  200. public string lsprize(int id = 0)
  201. {
  202. // StatService.Instance.activePrizeWithoutDeposit6(id);
  203. // WebCMSEntities db = new WebCMSEntities();
  204. // List<string> poslist = new List<string>();
  205. // poslist.Add("N6220Y02004331");
  206. // poslist.Add("N6220Y02004411");
  207. // poslist.Add("N6220Y02006392");
  208. // poslist.Add("N6220Y02008090");
  209. // poslist.Add("N6220Y02014659");
  210. // poslist.Add("N6220Y02016352");
  211. // poslist.Add("N6220Y02018426");
  212. // poslist.Add("N6220Y02009475");
  213. // poslist.Add("N6220Y02009601");
  214. // poslist.Add("N6220Y02009630");
  215. // poslist.Add("N6220Y02010111");
  216. // poslist.Add("N6220Y02010795");
  217. // poslist.Add("N6220Y02011199");
  218. // poslist.Add("N6220Y02011405");
  219. // poslist.Add("N6220Y02011946");
  220. // poslist.Add("N6220Y02172467");
  221. // poslist.Add("N6220Y02172563");
  222. // poslist.Add("N6220Y02172658");
  223. // poslist.Add("N6220Y02172658");
  224. // poslist.Add("N6220Y02007603");
  225. // foreach(string PosSn in poslist)
  226. // {
  227. // PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
  228. // if(pos != null)
  229. // {
  230. // // SycnSpTradeService.Instance.LiShuaActPrize(db, pos, 50);
  231. // StatService.Instance.activePrizeWithoutDeposit6(pos.Id);
  232. // }
  233. // }
  234. // db.Dispose();
  235. return "ok";
  236. }
  237. }
  238. }