123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Threading.Tasks;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Extensions.Logging;
- using Library;
- using LitJson;
- using System.Data;
- using MySystem.Models.Main;
- using System.Text.RegularExpressions;
- 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 string test(decimal a, decimal b, decimal g)
- {
- // List<int> MerchantIds = new List<int>();
- // MerchantIds.Add(5);
- // foreach(int MerchantId in MerchantIds)
- // {
- // RedisDbconn.Instance.AddList("MerchantConfirmHdQueue", "{\"MerchantId\":\"" + MerchantId + "\"}");
- // }
- // TianYuVoiceHelper.Instance.doSomething(DateTime.Now.ToString("yyyyMMddHHmmssfff"),"2023100701","100");
- // MqLinksHelper.Instance.doSomething("LKB01230600250000585","100");
- WebCMSEntities db = new WebCMSEntities();
- Dictionary<string, decimal> ids = new Dictionary<string, decimal>();
- ids.Add("2023123120272680842405573", 30.08M);
- // ids.Add("2023110823050361106411696", 162.39M);
- // ids.Add("2023103111150680882895028", 129.97M);
- // ids.Add("2023110115111893112798296", 186.66M);
- // ids.Add("2023110119350047351848839", 219.15M);
- // ids.Add("2023103121092345128864326", 132.51M);
- // ids.Add("2023110119465569176817757", 219.16M);
- // ids.Add("2023110119570851706448968", 219.16M);
- // ids.Add("2023110119282078572281345", 208.32M);
- // ids.Add("2023103111025117492478602", 151.62M);
- // ids.Add("2023103111023104266492281", 129.96M);
- // ids.Add("2023103111020866149098706", 140.79M);
- // ids.Add("2023103111014803279616494", 162.45M);
- // ids.Add("2023103111011872712858973", 173.28M);
- foreach(string orderno in ids.Keys)
- {
- decimal cur = ids[orderno];
- ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == orderno) ?? new ConsumerOrders();
- order.CurDivi = cur;
- order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
- order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":90,");
- RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
- }
- // List<int> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1272").Select(m => m.Id).ToList();
- // DataTable dt = CustomerSqlConn.dtable("select OrderId,sum(GetMoney) money from ConsumerProfit where MerchantId=1272 group by OrderId order by OrderId", AppConfig.Base.SqlConnStr);
- // foreach(DataRow dr in dt.Rows)
- // {
- // decimal cur = decimal.Parse(dr["money"].ToString());
- // int OrderId = int.Parse(dr["OrderId"].ToString());
- // if(!orders.Contains(OrderId))
- // {
- // // string orderno = dr["OrderNo"].ToString();
- // ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId) ?? new ConsumerOrders();
- // if(order.MaxDivi - cur >= 1)
- // {
- // order.CurDivi = cur;
- // order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"UpdateDate\":\".*?\"", "\"UpdateDate\":\"" + DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss") + "\"");
- // order.SeoDescription = Regex.Replace(function.CheckNull(order.SeoDescription), "\"ProfitDays\":.*?,", "\"ProfitDays\":365,");
- // RedisDbconn.Instance.AddList("ConsumerOrdersHd:Divi:" + order.PayMode + ":" + order.MerchantId, order);
- // var list = db.ConsumerProfit.Where(m => m.OrderId == order.Id).OrderBy(m => m.Id).ToList();
- // foreach(var sub in list)
- // {
- // if(cur >= sub.GetMoney)
- // {
- // cur -= sub.GetMoney;
- // }
- // else
- // {
- // if(cur > 0)
- // {
- // var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
- // if(edit != null)
- // {
- // edit.GetMoney = cur;
- // db.SaveChanges();
- // }
- // }
- // else
- // {
- // var edit = db.ConsumerProfit.FirstOrDefault(m => m.OrderId == order.Id);
- // if(edit != null)
- // {
- // db.ConsumerProfit.Remove(edit);
- // db.SaveChanges();
- // }
- // }
- // }
- // }
- // }
- // }
- // }
- // List<int> ids = new List<int>();
- // ids.Add(4058);
- // List<ConsumerOrders> orders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:2:1271");
- // foreach(int oid in ids)
- // {
- // function.WriteLog("oid:" + oid, "返现id");
- // decimal curDivi = 0;
- // ConsumerOrders order = orders.FirstOrDefault(m => m.Id == oid);
- // if(order == null)
- // {
- // order = db.ConsumerOrders.FirstOrDefault(m => m.Id == oid);
- // curDivi = order.MaxDivi;
- // function.WriteLog("出局", "返现id");
- // }
- // else
- // {
- // function.WriteLog("未出局", "返现id");
- // curDivi = order.CurDivi;
- // }
- // if(order != null)
- // {
- // List<ConsumerProfit> profits = db.ConsumerProfit.Where(m => m.OrderId == oid).ToList();
- // foreach(ConsumerProfit profit in profits)
- // {
- // if(curDivi >= profit.GetMoney)
- // {
- // curDivi -= profit.GetMoney;
- // }
- // else
- // {
- // function.WriteLog(profit.Id.ToString(), "返现id");
- // }
- // }
- // }
- // function.WriteLog("\n\n", "返现id");
- // }
- db.Dispose();
- // decimal settleAmount = b / 100M;
- // decimal divideAmt = (1 - 0.0038M) * a;
- // divideAmt = decimal.Parse(divideAmt.ToString("f2"));
- // decimal hdfee = 0.0038M * a * (1 - g / 100 - 0.01M);
- // hdfee = decimal.Parse(hdfee.ToString("f2"));
- // decimal servicefee = 0.01M * a - hdfee;
- // servicefee = decimal.Parse(servicefee.ToString("f2"));
- // decimal amount = a*(1-0.0038M) - servicefee;
- // amount = decimal.Parse(amount.ToString("f2"));
- // decimal otherAmt = settleAmount - servicefee - amount;
- // if(otherAmt != 0)
- // {
- // amount += otherAmt;
- // }
- // amount = amount * 100; //金额(分)
- // servicefee = servicefee * 100;
- // string seviceAmount = servicefee.ToString("f0"); //服务费
- // string amountAmount = amount.ToString("f0");
- // return amountAmount + ":" + seviceAmount;
- return "ok";
- }
- public string bindapp(int mid)
- {
- // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where HdStatus=3 and CreateDate>='2023-10-01 00:00:00' and MchtNo!='' and MchtNo is not null", AppConfig.Base.SqlConnStr);
- // DataTable dt = CustomerSqlConn.dtable("select Id,MchtNo from MerchantAddInfo where Id=" + mid, AppConfig.Base.SqlConnStr);
- // foreach(DataRow dr in dt.Rows)
- // {
- // CheckWeChatSignService.Instance.StartDo(new QueryMerchantStatus()
- // {
- // MerchantId = dr["Id"].ToString(),
- // MerchantNo = dr["MchtNo"].ToString(),
- // });
- // }
- Models.Main1.WebCMSEntities db1 = new Models.Main1.WebCMSEntities();
- WebCMSEntities db = new WebCMSEntities();
- MerchantAddInfo merchantadd = db.MerchantAddInfo.FirstOrDefault(m => m.Id == 1147);
- MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == 1147);
- string pwd = "417027";
- merchant.LoginPwd = function.MD532(pwd);
- Models.Main1.MerchantLoginInfo info = db1.MerchantLoginInfo.FirstOrDefault(m => m.LoginMobile == merchantadd.MobilePhone);
- if (info == null)
- {
- info = db1.MerchantLoginInfo.Add(new Models.Main1.MerchantLoginInfo()
- {
- LoginMobile = merchantadd.MobilePhone,
- }).Entity;
- db1.SaveChanges();
- }
- info.LoginPwd = function.MD532(pwd);
- db1.SaveChanges();
- Models.Main1.MerchantAccountLinkInfo infolink = db1.MerchantAccountLinkInfo.FirstOrDefault(m => m.LoginId == info.Id && m.MerchantId == merchantadd.Id && m.Kind == 2);
- if (infolink == null)
- {
- infolink = db1.MerchantAccountLinkInfo.Add(new Models.Main1.MerchantAccountLinkInfo()
- {
- LoginId = info.Id,
- MerchantId = merchantadd.Id,
- Kind = 2,
- }).Entity;
- db1.SaveChanges();
- }
- db1.Dispose();
- db.Dispose();
- return "ok";
- }
-
-
- public string clearQueue(int OrderId, int MerchantId, int PayMode)
- {
- List<ConsumerOrders> list = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrdersHd:Divi:" + PayMode + ":" + MerchantId + "", 1, 100000);
- foreach(ConsumerOrders sub in list)
- {
- if(sub.Id == OrderId)
- {
- RedisDbconn.Instance.DelFromList("ConsumerOrdersHd:Divi:2:1272", sub);
- }
- }
- return "ok";
- }
-
-
-
- }
- }
|