lcl 1 жил өмнө
parent
commit
0f7a7db184

+ 2 - 2
AppStart/Helper/AlipayPayBackService.cs

@@ -61,8 +61,8 @@ namespace MySystem
                                 order.PayMoney = order.PayMoney;
                                 order.MaxDivi = order.MaxDivi;
                                 db.SaveChanges();
-                                RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
-                                RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.MerchantId, order);
+                                RedisDbconn.Instance.AddList("ConsumerOrders:Divi:1:List", order.Id.ToString());
+                                RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:1:" + order.MerchantId, order);
                                 // ConsumerOrdersStatService.Instance.Stat(order);
                             }
                         }

+ 29 - 44
AppStart/Helper/Profit/ProfitHelper.cs

@@ -126,10 +126,10 @@ namespace MySystem
         {
             while (true)
             {
-                string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:List");
+                string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:1:List");
                 if (!string.IsNullOrEmpty(orderidstring))
                 {
-                    ReturnStat(orderidstring);
+                    ReturnStat(orderidstring, 1);
                 }
                 else
                 {
@@ -138,7 +138,29 @@ namespace MySystem
             }
         }
 
-        public void ReturnStat(string orderidstring)
+        public void StartListenWxTrade()
+        {
+            Thread th = new Thread(StartListenWxTradeDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartListenWxTradeDo()
+        {
+            while (true)
+            {
+                string orderidstring = RedisDbconn.Instance.RPop<string>("ConsumerOrders:Divi:2:List");
+                if (!string.IsNullOrEmpty(orderidstring))
+                {
+                    ReturnStat(orderidstring, 2);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
+        public void ReturnStat(string orderidstring, int PayMode)
         { 
             int OrderId = int.Parse(function.CheckInt(orderidstring));
             WebCMSEntities db = new WebCMSEntities();
@@ -149,7 +171,6 @@ namespace MySystem
                     ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId);
                     if (order != null)
                     {
-                        int PayMode = order.PayMode;
                         decimal PayMoney = order.PayMoney;
                         int MerchantId = order.MerchantId;
                         MerchantInfo merchant = db.MerchantInfo.FirstOrDefault(m => m.Id == MerchantId);
@@ -181,7 +202,7 @@ namespace MySystem
                                     DiviMoney = DiviMoney / DiviPersons;
                                     List<int> deletes = new List<int>();
                                     long CurDiviPersons = DiviPersons;
-                                    long QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + MerchantId);
+                                    long QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
                                     long CurQueueCount = QueueCount;
                                     // int CheckNum = 0; //判断活动人数是否大于当前队列订单数来确认while循环的数量,如果是就少循环一次,判处自己的订单名额
                                     if (CurDiviPersons >= CurQueueCount)
@@ -198,7 +219,7 @@ namespace MySystem
                                     int OutCount = 0; // 出局人数
                                     while (CurDiviPersons > 0)
                                     {
-                                        ConsumerOrders suborder = RedisDbconn.Instance.RPop<ConsumerOrders>("ConsumerOrders:Divi:" + MerchantId);
+                                        ConsumerOrders suborder = RedisDbconn.Instance.RPop<ConsumerOrders>("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
                                         if (suborder != null)
                                         {
                                             MerchantParamSet subset = Newtonsoft.Json.JsonConvert.DeserializeObject<MerchantParamSet>(order.SeoDescription);
@@ -243,7 +264,7 @@ namespace MySystem
                                                         Dictionary<string, string> dic = WeChatFunction.Instance.Refund(merchantAdd.SubMchid, GetMoney, suborder.PayMoney, suborder.OrderNo, DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
                                                         if (suborder.CurDivi < suborder.MaxDivi)
                                                         {
-                                                            RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + MerchantId, suborder);
+                                                            RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId, suborder);
                                                         }
                                                         else
                                                         {
@@ -259,7 +280,7 @@ namespace MySystem
                                             }
                                         }
                                         CurDiviPersons -= 1;
-                                        QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + MerchantId);
+                                        QueueCount = RedisDbconn.Instance.Count("ConsumerOrders:Divi:" + PayMode + ":" + MerchantId);
                                         if (QueueCount == 0)
                                         {
                                             CurDiviPersons = 0;
@@ -681,42 +702,6 @@ namespace MySystem
 
         #endregion      
 
-        #region 待分账队列
-
-        public void StartListenSplitAccount()
-        { 
-            bool op = true;
-            while (op)
-            {
-                try
-                {
-                    string orderidstring = RedisDbconn.Instance.Get<string>("ConsumerOrders:Divi:List");
-                    if (!string.IsNullOrEmpty(orderidstring))
-                    {
-                        int OrderId = int.Parse(function.CheckInt(orderidstring));
-                        WebCMSEntities db = new WebCMSEntities();
-                        ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.Id == OrderId && m.Status == 1);
-                        if (order != null)
-                        {
-                            // TODO: 
-                        }
-                        db.Dispose();
-                    }
-                    else
-                    {
-                        op = false;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    op = false;
-                    function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":" + ex.ToString(), "待分账队列异常");
-                }
-            }
-        }
-
-        #endregion
-
 
 
 

+ 2 - 2
AppStart/Helper/ProfitShareService.cs

@@ -55,8 +55,8 @@ namespace MySystem
                     ConsumerOrders order = db.ConsumerOrders.FirstOrDefault(m => m.OrderNo == OrderNo && m.Status == 1);
                     if (order != null)
                     {
-                        RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
-                        RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.MerchantId, order);
+                        RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + order.PayMode + ":List", order.Id.ToString());
+                        RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.PayMode + ":" + order.MerchantId, order);
                     }
                     db.Dispose();
                 }

+ 0 - 67
AppStart/Helper/SycnMysql/ConsumerOrdersHelper.cs

@@ -1,67 +0,0 @@
-using Library;
-using MySystem.PxcModels;
-using System;
-using System.Linq;
-
-namespace MySystem
-{
-    public class ConsumerOrdersHelper
-    {
-        public readonly static ConsumerOrdersHelper Instance = new ConsumerOrdersHelper();
-        private ConsumerOrdersHelper()
-        { }
-
-        public string Start()
-        {
-            bool op = true;
-            WebCMSEntities db = new WebCMSEntities();
-            string result = "";
-            // int total = 0;
-            while (op)
-            {
-                ConsumerOrders PopData = new ConsumerOrders();
-                try
-                {
-                    //获取apserver待同步的数据,执行入库
-                    PopData = RedisDbconn.Instance.RPop<ConsumerOrders>("Pop:ConsumerOrders");
-                    if (PopData != null)
-                    {
-                        ConsumerOrders checkExist = db.ConsumerOrders.FirstOrDefault(m => m.Id == PopData.Id);
-                        if (checkExist != null)
-                        {
-                            checkExist = PopData;
-                            db.SaveChanges();
-                        }
-                        else
-                        {
-                            ConsumerOrders item = db.ConsumerOrders.Add(PopData).Entity;
-                            db.SaveChanges();
-                            RedisDbconn.Instance.AddList("ConsumerOrders:Divi:" + PopData.MerchantId, item);
-                            RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", item.Id.ToString());
-                        }
-                        // if (total >= 20)
-                        // {
-                        //     total = 0;
-                        // }
-                        if (string.IsNullOrEmpty(result)) result = "success";
-                    }
-                    else
-                    {
-                        op = false;
-                    }
-                }
-                catch (Exception ex)
-                {
-                    ErrorMsg msg = new ErrorMsg();
-                    msg.Obj = PopData;
-                    msg.Time = DateTime.Now;
-                    msg.ErrorContent = ex.ToString();
-                    function.WriteLog(Newtonsoft.Json.JsonConvert.SerializeObject(msg), "Pop:ConsumerOrders:Error");
-                    result = "有异常,请查看Pop:ConsumerOrders:Error队列";
-                }
-            }
-            db.Dispose();
-            return result;
-        }
-    }
-}

+ 3 - 3
AppStart/Helper/WeChatPayBackService.cs

@@ -102,7 +102,7 @@ namespace MySystem
                                         description = "服务费",  //分账描述
                                     });
                                     WeChatFunction.Instance.ProfitShare(merchantAdd.SubMchid, TradeNo, OrderNo, Receivers);
-                                    
+
                                     //开始监听分账状态
                                     Dictionary<string, object> req = new Dictionary<string, object>();
                                     req.Add("SubMchid", merchantAdd.SubMchid); //子商户号
@@ -112,8 +112,8 @@ namespace MySystem
                                 }
                                 else
                                 {
-                                    RedisDbconn.Instance.AddList("ConsumerOrders:Divi:List", order.Id.ToString());
-                                    RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:" + order.MerchantId, order);
+                                    RedisDbconn.Instance.AddList("ConsumerOrders:Divi:2:List", order.Id.ToString());
+                                    RedisDbconn.Instance.AddRightList("ConsumerOrders:Divi:2:" + order.MerchantId, order);
                                 }
                             }
                         }

+ 7 - 6
Startup.cs

@@ -171,12 +171,13 @@ namespace MySystem
             });
 
             //必须打开的
-            MerchantConfirmService.Instance.Start();
-            CheckWeChatSignService.Instance.Start();
-            WeChatPayBackService.Instance.Start();
-            ProfitHelper.Instance.StartActive();
-            ProfitHelper.Instance.StartListenTrade();
-            ProfitShareService.Instance.Start();
+            MerchantConfirmService.Instance.Start(); //特约商户进件队列
+            CheckWeChatSignService.Instance.Start(); //特约商户签约队列
+            WeChatPayBackService.Instance.Start(); //微信支付回调队列
+            ProfitHelper.Instance.StartActive(); //发放达标奖励队列
+            ProfitHelper.Instance.StartListenTrade(); //支付宝返现队列
+            ProfitHelper.Instance.StartListenWxTrade(); //微信返现队列
+            ProfitShareService.Instance.Start(); //分账状态监控队列,分账完成则提交返现
             //必须打开的
         }
     }