using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Data; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using MySystem.PxcModels; using System.Threading; using Library; using LitJson; using System.Security.Cryptography; namespace MySystem.Controllers { public class HomeController : Controller { private readonly ILogger _logger; public HomeController(ILogger logger) { _logger = logger; } public IActionResult Index() { return View(); } public IActionResult Error() { string isapi = Request.Headers["Api"].ToString(); if (isapi != "1") { if (Response.StatusCode == 500) { return Redirect("/public/errpage/pc/500.html"); } else if (Response.StatusCode == 502) { return Redirect("/public/errpage/pc/502.html"); } else if (Response.StatusCode == 404) { return Redirect("/public/errpage/pc/404.html"); } } return View(); } // 大盟主标记扫描 public string leaderflag() { WebCMSEntities db = new WebCMSEntities(); List ids = new List(); // List records = db.PosCouponRecord.Where(m => m.FromUserId == 597).ToList(); // foreach(PosCouponRecord record in records) // { // ids.Add(record.PosCouponId); // } ids.Add(6843); List coupons = db.PosCoupons.Where(m => ids.Contains(m.Id) && m.IsUse == 1).ToList(); foreach (PosCoupons coupon in coupons) { PosSns.Add(coupon.ExchangeCode); } foreach (PosCoupons coupon in coupons) { ChildNo(db, coupon.ExchangeCode, coupon.ExchangeCode, coupon.LeaderUserId); } // db.SaveChanges(); db.Dispose(); return "ok"; } List nos = new List(); private void ChildNo(WebCMSEntities db, string RootCheckNo, string CheckNo, int LeaderUserId) { MachineApply apply = db.MachineApply.FirstOrDefault(m => m.SwapSnExpand.Contains(CheckNo)); if(apply != null) { int len = 0; string[] SnList = apply.SwapSnExpand.TrimEnd('\n').Split('\n'); foreach(string sn in SnList) { if(PosSns.Contains(sn.Split(':')[0]) || nos.Contains(sn.Split(':')[0])) { len += 1; } } Orders order = db.Orders.FirstOrDefault(m => m.Id == apply.QueryCount); if(order != null) { if(!string.IsNullOrEmpty(order.SnNos)) { if(order.SnNos.Contains(",")) { string[] SwapSnExpands = order.SnNos.TrimEnd(',').Split(','); int index = 0; foreach(string no in SwapSnExpands) { if(!nos.Contains(no) && index < len) { index += 1; nos.Add(no); ChildNo(db, RootCheckNo, no, LeaderUserId); } } } else { string[] SwapSnExpands = order.SnNos.TrimEnd('\n').Split('\n'); int index = 0; foreach(string no in SwapSnExpands) { if(!nos.Contains(no) && index < len) { index += 1; nos.Add(no); ChildNo(db, RootCheckNo, no, LeaderUserId); } } } } else { MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == CheckNo) ?? new MachineForSnNo(); PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == forSnNo.SnId); if(pos != null) { // pos.LeaderUserId = LeaderUserId; // Library.function.WriteLog(LeaderUserId + ":" + pos.PosSn + ":" + apply.SwapSnExpand.TrimEnd('\n').Split('\n').Length, "大盟主奖励标记机具"); Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users(); Library.function.WriteLog(pos.PosSn + ":" + RootCheckNo + ":" + user.MakerCode + ":" + user.RealName, "大盟主奖励标记机具"); } } } } else { MachineForSnNo forSnNo = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == CheckNo) ?? new MachineForSnNo(); PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m=>m.Id == forSnNo.SnId); if(pos != null) { // pos.LeaderUserId = LeaderUserId; // Library.function.WriteLog(LeaderUserId + ":" + pos.PosSn, "大盟主奖励标记机具"); Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users(); Library.function.WriteLog(pos.PosSn + ":" + RootCheckNo + ":" + user.MakerCode + ":" + user.RealName, "大盟主奖励标记机具"); } } } List PosSns = new List(); public string ScanNos() { PosSns = new List(); PosSns.Add("00005002681889125851"); WebCMSEntities db = new WebCMSEntities(); foreach(string PosSn in PosSns) { ChildNo(db, PosSn, PosSn, 0); } db.Dispose(); return "ok"; } public string test() { // WebCMSEntities db = new WebCMSEntities(); // AlipayPayBack2Service.Instance.DoOrderV2(db, 269424); // db.Dispose(); // List ids = new List(); // foreach(int id in ids) // { // TradeChangeService.Instance.StatTradeAmount(id, 2, 1); // } // WebCMSEntities db = new WebCMSEntities(); // 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)); // if(pos != null) // { // SycnSpTradeService.Instance.ActPos(db, pos, 0, 30); // } // db.Dispose(); string result = ""; // result += SetDepositPostService.Instance.ModifyFee("00005002681889119293", 0.0063M, "3") + "\n\n"; // result += SetDepositPostService.Instance.SetFeeForSft("39103661", "0.6300", "3") + "\n\n"; // Dictionary headers = new Dictionary(); // string token = "eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQyN2E2OGY0NzY0MjRiMzJiNjhhM2JlMTc1ZjQ4OGE3In0.xjKmh1Pu9_DvwI-zpML8Z3oqKs99PQW-9aBg-ru2i-xQZYC3yKEtJ_H1_bcw2byGNnMNXMPRlBoDegLpSebXDA"; // headers.Add("Authorization", "Bearer " + token); // string str = "{\"feedback_type\":\"1\",\"content\":\"电饭锅电饭锅大范甘迪\"}"; // string resultJson = Encrypt(str, "CBTU1dD4Kd5pyiGWTsI10jRQ3SvKusSV", "DYgjCEIMVrj2W9xN"); // string ApiResponse = function.PostWebRequest("http://47.108.118.29:8080/v1/cybmain/feedback/feedSave", resultJson, headers, "application/json"); // string ApiResponse = function.GetWebRequest("http://47.108.118.29:8080/v1/cybmain/app/authorization"); //{"status":1,"messge":null,"data":{"userId":1,"token":"eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6ImQyN2E2OGY0NzY0MjRiMzJiNjhhM2JlMTc1ZjQ4OGE3In0.xjKmh1Pu9_DvwI-zpML8Z3oqKs99PQW-9aBg-ru2i-xQZYC3yKEtJ_H1_bcw2byGNnMNXMPRlBoDegLpSebXDA","loginTime":1699331586502,"expireTime":1699417986502,"ipaddr":null,"loginLocation":null,"browser":null,"os":null,"user":null},"other":null,"code":"1","timestamp":null} // List ids = new List(); // foreach(string id in ids) // { // RedisDbconn.Instance.AddList("OpenRewardQueue", id); // RedisDbconn.Instance.AddList("LeaderPrizeQueue", id); // RedisDbconn.Instance.AddList("OperatePrizeQueue", id); // } return result; } public string Encrypt(string plainText, string keyString, string ivString) { byte[] cipherData; Aes aes = Aes.Create(); aes.Key = System.Text.Encoding.UTF8.GetBytes(keyString); aes.IV = System.Text.Encoding.UTF8.GetBytes(ivString); aes.Mode = CipherMode.CBC; aes.Padding = PaddingMode.PKCS7; ICryptoTransform cipher = aes.CreateEncryptor(aes.Key, aes.IV); using (System.IO.MemoryStream ms = new System.IO.MemoryStream()) { using (CryptoStream cs = new CryptoStream(ms, cipher, CryptoStreamMode.Write)) { using (System.IO.StreamWriter sw = new System.IO.StreamWriter(cs)) { sw.Write(plainText); } } cipherData = ms.ToArray(); } return Convert.ToBase64String(cipherData); } public string setlee() { WebCMSEntities db = new WebCMSEntities(); List poslist = new List(); poslist.Add("00003102722201179816714"); foreach(string PosSn in poslist) { PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn); if(pos != null) { string info = "{\"RecordId\":\"\",\"PosId\":\"" + pos.Id + "\",\"Fee\": \"0.6\",\"Kind\": \"2\",\"OpMan\": \"系统\"}"; RedisDbconn.Instance.AddList("SetDepositPostQueue", info); } } db.Dispose(); return "ok"; } public string lsprize(int id = 0) { // StatService.Instance.activePrizeWithoutDeposit6(id); // WebCMSEntities db = new WebCMSEntities(); // List poslist = new List(); // poslist.Add("N6220Y02004331"); // poslist.Add("N6220Y02004411"); // poslist.Add("N6220Y02006392"); // poslist.Add("N6220Y02008090"); // poslist.Add("N6220Y02014659"); // poslist.Add("N6220Y02016352"); // poslist.Add("N6220Y02018426"); // poslist.Add("N6220Y02009475"); // poslist.Add("N6220Y02009601"); // poslist.Add("N6220Y02009630"); // poslist.Add("N6220Y02010111"); // poslist.Add("N6220Y02010795"); // poslist.Add("N6220Y02011199"); // poslist.Add("N6220Y02011405"); // poslist.Add("N6220Y02011946"); // poslist.Add("N6220Y02172467"); // poslist.Add("N6220Y02172563"); // poslist.Add("N6220Y02172658"); // poslist.Add("N6220Y02172658"); // poslist.Add("N6220Y02007603"); // foreach(string PosSn in poslist) // { // PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn); // if(pos != null) // { // // SycnSpTradeService.Instance.LiShuaActPrize(db, pos, 50); // StatService.Instance.activePrizeWithoutDeposit6(pos.Id); // } // } // db.Dispose(); return "ok"; } } }