123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- 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<HomeController> _logger;
- public HomeController(ILogger<HomeController> 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<int> ids = new List<int>();
-
-
-
-
-
- ids.Add(6843);
- List<PosCoupons> 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.Dispose();
- return "ok";
- }
- List<string> nos = new List<string>();
- 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)
- {
-
-
- 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)
- {
-
-
- Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
- Library.function.WriteLog(pos.PosSn + ":" + RootCheckNo + ":" + user.MakerCode + ":" + user.RealName, "大盟主奖励标记机具");
- }
- }
- }
- List<string> PosSns = new List<string>();
- public string ScanNos()
- {
- PosSns = new List<string>();
- 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();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- string result = "ok";
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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<string> poslist = new List<string>();
- 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)
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 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";
- }
-
-
- }
- }
|