123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- 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>();
- // List<PosCouponRecord> records = db.PosCouponRecord.Where(m => m.FromUserId == 597).ToList();
- // foreach(PosCouponRecord record in records)
- // {
- // ids.Add(record.PosCouponId);
- // }
- 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.SaveChanges();
- 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)
- {
- // 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<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()
- {
- OpModels.WebCMSEntities db = new OpModels.WebCMSEntities();
- List<int> ids = new List<int>();
- List<OpModels.ChangeTypes> typelist = db.ChangeTypes.ToList();
- List<OpModels.AmountRecord> 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<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 add()
- {
- DateTime now = DateTime.Now;
- WebCMSEntities db = new WebCMSEntities();
- List<string> poslist = new List<string>();
- foreach(string PosSn in poslist)
- {
- PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn);
- if(pos != null)
- {
- PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
- if (merchant != null)
- {
- DateTime TransferTime = pos.TransferTime == null ? DateTime.Now : pos.TransferTime.Value;
- //广电卡批量补盟主奖励和运营中心奖励
- if (pos.BrandId == 14 && pos.BuyUserId > 0 && pos.ActivationState == 1 && TransferTime < pos.BindingTime && pos.BindingTime > now.AddDays(-30) && pos.CardType > 0 && pos.CardType < 100)
- {
- if(pos.LeaderUserId > 0 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now))
- {
- RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
- }
- RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
- }
- //0押金返30的奖励批量补录
- // if(pos.ActivationState == 1 && (string.IsNullOrEmpty(pos.SeoKeyword) || pos.SeoKeyword == "0") && pos.CreditTrade >= 5000 && pos.CardType < 100)
- // {
- // Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId);
- // if (user != null)
- // {
- // int GetUserId = user.Id;
- // string ParentNav = user.ParentNav;
- // int TopUserId = 0;
- // if (!string.IsNullOrEmpty(ParentNav))
- // {
- // TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
- // }
- // if(pos.BindingTime.Value.AddDays(30) >= pos.ActivationTime)
- // {
- // StatService.Instance.doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 30);
- // if(pos.LeaderUserId > 0 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now))
- // {
- // RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
- // }
- // RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
- // }
- // }
- // }
- }
- //批量补服务费奖励
- // if(decimal.Parse(function.CheckNum(pos.SeoKeyword)) > 0 && pos.CardType < 100)
- // {
- // StatService.Instance.PreActPrize(db, pos, merchant, pos.SeoKeyword);
- // }
- }
- }
- 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";
- }
-
- public string addprize()
- {
- List<int> ids = new List<int>();
- foreach(int id in ids)
- {
- RedisDbconn.Instance.AddList("LeaderPrizeQueue", id);
- }
- return "ok";
- }
- public string addprize2()
- {
- List<int> ids = new List<int>();
- foreach(int id in ids)
- {
- RedisDbconn.Instance.AddList("OperatePrizeQueue", id);
- }
- return "ok";
- }
- public string order60()
- {
- WebCMSEntities db = new WebCMSEntities();
- List<int> oids = new List<int>();
- foreach(int oid in oids)
- {
- PosCouponPrizeService.Instance.dosomething2(oid);
- }
- db.Dispose();
- return "ok";
- }
- }
- }
|