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() { OpModels.WebCMSEntities db = new OpModels.WebCMSEntities(); List ids = new List(); List typelist = db.ChangeTypes.ToList(); List list = db.AmountRecord.OrderBy(m => m.Id).ToList(); int index = 0; foreach(OpModels.AmountRecord sub in list) { index += 1; if(!ids.Contains(sub.Id)) { int OperateType = sub.OperateType; OpModels.ChangeTypes type = typelist.FirstOrDefault(m => m.Name == sub.SeoDescription) ?? new OpModels.ChangeTypes(); decimal UseAmount = sub.UseAmount; decimal UseTotalAmt = 0; decimal UseValidForGetAmount = 0; decimal UseValidAmount = 0; if(type.Name == "商城购机" || type.Name == "购买小盟主" || type.Name == "购买运营中心") { UseTotalAmt = UseAmount; UseValidForGetAmount = UseAmount; OpModels.AmountRecord same = db.AmountRecord.FirstOrDefault(m => m.UserId == sub.UserId && m.CreateDate >= sub.CreateDate && m.CreateDate <= sub.CreateDate.Value.AddSeconds(5) && m.UseAmount == UseAmount && m.SeoDescription == sub.SeoDescription && m.OperateType == 1) ?? new OpModels.AmountRecord(); ids.Add(same.Id); OperateType = 0; } else { if(sub.Version == 1) { UseTotalAmt = UseAmount; } else if(sub.Version == 2) { UseValidForGetAmount = UseAmount; } else if(sub.Version == 3) { UseValidAmount = UseAmount; } else { if(OperateType == 1) { UseTotalAmt = UseAmount; } else { UseTotalAmt = -UseAmount; } } } OpModels.AmountRecordNew add = db.AmountRecordNew.Add(new OpModels.AmountRecordNew() { CreateDate = sub.CreateDate, UpdateDate = sub.UpdateDate, ChangeTypeId = type.Id, Remark = sub.SeoDescription, AfterValidForGetAmount = sub.AfterValidForGetAmount, AfterTotalAmt = sub.AfterTotalAmt, AfterValidAmount = sub.AfterValidAmount, OperateType = OperateType, AfterAmount = sub.AfterAmount, BeforeAmount = sub.BeforeAmount, UseAmount = UseAmount, UserId = sub.UserId, UseValidForGetAmount = UseValidForGetAmount, UseTotalAmt = UseTotalAmt, UseValidAmount = UseValidAmount, }).Entity; if(index % 100 == 0) { db.SaveChanges(); } } } db.SaveChanges(); db.Dispose(); return "ok"; } 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"; } //金控自备机,补商户信息 public string jkmerinfo(string sn) { SpModels.WebCMSEntities spdb = new SpModels.WebCMSEntities(); PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities(); var Bind = spdb.BindRecord.FirstOrDefault(m => m.MerSnNo == sn && m.Field1 == "解绑"); if (Bind != null) { PxcModels.MachineForSnNo posFor = db.MachineForSnNo.FirstOrDefault(m => m.SnNo == Bind.MerSnNo) ?? new PxcModels.MachineForSnNo(); PxcModels.PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == posFor.SnId); if (pos != null) { pos.BindingState = 1; pos.BindingTime = Bind.CreateTime; pos.Status = 0; PxcModels.MachineForMerNo merFor = db.MachineForMerNo.FirstOrDefault(m => m.MerNo == Bind.MerNo); if (merFor == null) { merFor = db.MachineForMerNo.Add(new PxcModels.MachineForMerNo() { MerNo = Bind.MerNo, SnId = pos.Id, }).Entity; } else { merFor.SnId = pos.Id; } db.SaveChanges(); PxcModels.Users user = db.Users.FirstOrDefault(m => m.Id == pos.UserId) ?? new PxcModels.Users(); int TopUserId = 0; if (!string.IsNullOrEmpty(user.ParentNav)) { TopUserId = int.Parse(user.ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]); } int BrandId = pos.BrandId; PxcModels.TradeRecord trade = db.TradeRecord.FirstOrDefault(m => m.SnNo == sn) ?? new PxcModels.TradeRecord(); PxcModels.PosMerchantInfo add = db.PosMerchantInfo.FirstOrDefault(m => m.KqMerNo == Bind.MerNo); if (add == null) { if(trade.MerchantId > 0) { add = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo() { CreateDate = Bind.CreateTime, KqMerNo = Bind.MerNo, MerchantNo = Bind.MerNo.Length > 16 ? Bind.MerNo.Substring(0, 16) : Bind.MerNo, Id = trade.MerchantId, }).Entity; db.SaveChanges(); } else { add = db.PosMerchantInfo.Add(new PxcModels.PosMerchantInfo() { CreateDate = Bind.CreateTime, KqMerNo = Bind.MerNo, MerchantNo = Bind.MerNo.Length > 16 ? Bind.MerNo.Substring(0, 16) : Bind.MerNo, }).Entity; db.SaveChanges(); } } add.UpdateDate = Bind.UpdateTime; add.TopUserId = TopUserId; add.BrandId = BrandId; add.SnStoreId = pos.StoreId; add.SnType = pos.PosSnType; add.UserId = pos.UserId; add.MerStatus = 1; add.KqSnNo = Bind.MerSnNo; add.MerIdcardNo = function.CheckNull(Bind.SeoKeyword).ToUpper(); add.MerRealName = Bind.MerName; add.MerchantMobile = Bind.MerNewSnNo; add.MerchantName = Bind.MerName; pos.BindMerchantId = add.Id; pos.LastMerchantId = add.Id; db.SaveChanges(); RedisDbconn.Instance.AddList("DepositReturnStatQueue", add.Id.ToString()); PxcModels.Users buser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new PxcModels.Users(); if(buser.BusinessFlag == 1) { bool checkMer = db.BusinessPartnerMerchant.Any(m => m.MerchantId == add.Id); if(!checkMer) { PxcModels.BusinessPartnerPos bpos = db.BusinessPartnerPos.FirstOrDefault(m => m.PosId == pos.Id) ?? new PxcModels.BusinessPartnerPos(); db.BusinessPartnerMerchant.Add(new PxcModels.BusinessPartnerMerchant() { CreateDate = DateTime.Now, MerNo = Bind.MerNo, MerchantId = add.Id, PartnerId = bpos.PartnerId, UserId = pos.BuyUserId, }); db.SaveChanges(); } } } } spdb.Dispose(); db.Dispose(); return "ok"; } public string sycnTrade(int Id) { PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities(); PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == Id); if(merchant != null) { DepositReturnStatService.Instance.DoSomething(db, merchant); } return "ok"; } } }