Explorar o código

操作返现队列

lcl hai 9 meses
pai
achega
5718a1deea
Modificáronse 1 ficheiros con 95 adicións e 23 borrados
  1. 95 23
      Controllers/HomeController.cs

+ 95 - 23
Controllers/HomeController.cs

@@ -7,6 +7,7 @@ using Library;
 using LitJson;
 using System;
 using System.IO;
+using System.Text.RegularExpressions;
 
 namespace MySystem.Controllers
 {
@@ -57,31 +58,102 @@ namespace MySystem.Controllers
         public string test()
         {
             string result = "";
-            // List<ReceiverList> Receivers = new List<ReceiverList>();
-            // Receivers.Add(new ReceiverList()
-            // {
-            //     type = "MERCHANT_ID",  //分账接收方类型
-            //     account = "1611167423",  //分账接收方账号
-            //     amount = 1,  //分账金额
-            //     description = "服务费",  //分账描述
-            // });
-            // Receivers.Add(new ReceiverList()
-            // {
-            //     type = "PERSONAL_OPENID",  //分账接收方类型
-            //     account = "ooDpv5LkCKEguE-LMZO-rSV4TDpk",  //分账接收方账号
-            //     amount = 1,  //分账金额
-            //     description = "优惠",  //分账描述
-            // });
-            // result = new WeChatFunction().ProfitShare("1645266943", "4200001846202306021274142861", "2023060214014405449699901", Receivers);
-            // result = new WeChatFunction().AddReceive("1645266943", "PERSONAL_OPENID", "ooDpv5LkCKEguE-LMZO-rSV4TDpk", "", "USER");
-            // result = new WeChatFunction().QueryProfitShare("1645266943", "4200001815202306025662773463", "2023060213335030713572885");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001851202306296256433756","2023062914544345583469577", "结算");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001871202306297971809063","2023062914503970424085049", "结算");
-            // result += new WeChatFunction().Unfreeze("1647917209","4200001861202306299303626271","2023062914274571909443048", "结算");
+            WebCMSEntities maindb = new WebCMSEntities();
+            List<string> nos = new List<string>();
+            foreach(string no in nos)
+            {
+                ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
+                if (order != null)
+                {
+                    List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, 1, 999999);
+                    if (suborders.Count > 0)
+                    {
+                        ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
+                        if (suborder != null)
+                        {
+                            order.CurDivi = suborder.CurDivi;
+                            maindb.SaveChanges();
+                            RedisDbconn.Instance.RemoveFromList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, suborder);
+                            order.ReturnFlag = 0;
+                            maindb.SaveChanges();
+                        }
+                    }
+                }
+            }
+            maindb.Dispose();
 
-            // result = new WeChatFunction().ProfitShareReturn("1646405429", "1611167423", "2023060810550382756164803", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8), 0.02M);
+            return result;
+        }
 
-            // result = new WeChatFunction().GetPublicKey();
+        public string test2()
+        {
+            string result = "ok";
+            WebCMSEntities maindb = new WebCMSEntities();
+            List<string> nos = new List<string>();
+            nos.Add("2023122118000851456243816,288.4");
+            nos.Add("2023122117593143700062399,341.04");
+            nos.Add("2023122117325908930632327,254.15");
+            nos.Add("2023122116415701143090181,312.26");
+            nos.Add("2023122116413711877723909,276.83");
+            nos.Add("2023122114085649698036050,342.45");
+            nos.Add("2023122313533734425618726,299.78");
+            nos.Add("2023122313282248497454670,246.97");
+            nos.Add("2023122311000256069736155,261.82");
+            nos.Add("2023122310594073141191302,304.84");
+            nos.Add("2023122520210853072569713,191.59");
+            nos.Add("2023122518244789260165229,186.53");
+            nos.Add("2023122515274323574090329,275.95");
+            nos.Add("2023122515252336206794004,261.82");
+            nos.Add("2023122619342154468765968,178.31");
+            nos.Add("2023122618011435195726036,258.07");
+            nos.Add("2023122618001597671800401,248.51");
+            nos.Add("2023122615422945713502403,191.84");
+            nos.Add("2023122613362000858247931,227.61");
+            nos.Add("2023122820200788070426381,198.57");
+            nos.Add("2023122820125421416300639,237.29");
+            nos.Add("2023122820123371996899445,182.56");
+            nos.Add("2023122814020384897788563,167.38");
+            nos.Add("2023122811030268206294741,228.91");
+            nos.Add("2023122810460690412361230,210.46");
+            nos.Add("2023122810364031620851479,202.11");
+            nos.Add("2023122811124893906532985,224.09");
+            nos.Add("2023122917185120082183642,152.23");
+            nos.Add("2023122911233689014204746,163.27");
+            nos.Add("2023122911214057116568112,122.39");
+            nos.Add("2023122911184819662469868,180.80");
+            foreach(string sub in nos)
+            {
+                string[] data = sub.Split(',');
+                string no = data[0];
+                decimal CurDivi = decimal.Parse(data[1]);
+                ConsumerOrders order = maindb.ConsumerOrders.FirstOrDefault(m => m.OrderNo == no);
+                if (order != null)
+                {
+                    JsonData ProfitInfo = JsonMapper.ToObject(order.SeoDescription);
+                    int ProfitDays = int.Parse(function.CheckInt(ProfitInfo["ProfitDays"].ToString())); //活动有效时间
+                    if (order.IsAct == 1)
+                    {
+                        if (order.MaxDivi > order.CurDivi)
+                        {
+                            List<ConsumerOrders> suborders = RedisDbconn.Instance.GetList<ConsumerOrders>("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId);
+                            if (suborders.Count > 0)
+                            {
+                                ConsumerOrders suborder = suborders.FirstOrDefault(m => m.Id == order.Id);
+                                if (suborder == null)
+                                {
+                                    order.CurDivi = CurDivi;
+                                    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\":254,");
+                                    RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
+                                    order.ReturnFlag = 1;
+                                    maindb.SaveChanges();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            maindb.Dispose();
 
             return result;
         }