Ver código fonte

添加补分润队列

lcl 4 meses atrás
pai
commit
4f9952a93c

+ 4 - 0
Startup.cs

@@ -170,6 +170,10 @@ namespace MySystem
                 ProfitAfterHelper.Instance.StartListenProfit(); //每月分润
                 ProfitBeforeNewHelper.Instance.StartListenProfit(); //每月分润
                 ProfitAfterNewHelper.Instance.StartListenProfit(); //每月分润
+                ProfitBeforeHelper.Instance.StartListenProfitAdd(); //补每月分润
+                ProfitAfterHelper.Instance.StartListenProfitAdd(); //补每月分润
+                ProfitBeforeNewHelper.Instance.StartListenProfitAdd(); //补每月分润
+                ProfitAfterNewHelper.Instance.StartListenProfitAdd(); //补每月分润
                 ProfitCheckHelper.Instance.Start(); //检查订单是否在队列里
                 SettleAmountCheckHelper.Instance.Start(); //检查未结算分账订单队列
 

+ 40 - 6
Util/HaoDa/ProfitAfterHelper.cs

@@ -53,20 +53,54 @@ namespace MySystem
             }
         }
 
+        public void StartListenProfitAdd()
+        {
+            Thread th = new Thread(StartListenProfitAddDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListenProfitAddDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("ProfitAfterQueue");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    try
+                    {
+                        DoProfit(content);
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧分润异常");
+                    }
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
         //分润算法
-        public void DoProfit()
+        public void DoProfit(string otherCondi = "")
         {
             string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
-            string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-after.txt");
-            if (!string.IsNullOrEmpty(check))
+            if(string.IsNullOrEmpty(otherCondi))
             {
-                return;
+                string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-after.txt");
+                if (!string.IsNullOrEmpty(check))
+                {
+                    return;
+                }
+                function.WritePage("/ProfitFlag/", TradeMonth + "-after.txt", DateTime.Now.ToString());
             }
-            function.WritePage("/ProfitFlag/", TradeMonth + "-after.txt", DateTime.Now.ToString());
             Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
             WebCMSEntities dbnew = new WebCMSEntities();
             KxsUserModels.WebCMSEntities udb = new KxsUserModels.WebCMSEntities();
-            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryOldAfter where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
+            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryOldAfter where TradeMonth='" + TradeMonth + "'" + otherCondi + " and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
             foreach (DataRow dr in dt.Rows)
             {
                 int UserId = int.Parse(dr["UserId"].ToString());

+ 40 - 6
Util/HaoDa/ProfitAfterNewHelper.cs

@@ -53,20 +53,54 @@ namespace MySystem
             }
         }
 
+        public void StartListenProfitAdd()
+        {
+            Thread th = new Thread(StartListenProfitAddDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListenProfitAddDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("ProfitAfterNewQueue");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    try
+                    {
+                        DoProfit(content);
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧分润异常");
+                    }
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
         //分润算法
-        public void DoProfit()
+        public void DoProfit(string otherCondi = "")
         {
             string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
-            string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-after-new.txt");
-            if (!string.IsNullOrEmpty(check))
+            if(string.IsNullOrEmpty(otherCondi))
             {
-                return;
+                string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-after-new.txt");
+                if (!string.IsNullOrEmpty(check))
+                {
+                    return;
+                }
+                function.WritePage("/ProfitFlag/", TradeMonth + "-after-new.txt", DateTime.Now.ToString());
             }
-            function.WritePage("/ProfitFlag/", TradeMonth + "-after-new.txt", DateTime.Now.ToString());
             Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
             WebCMSEntities dbnew = new WebCMSEntities();
             KxsUserModels.WebCMSEntities udb = new KxsUserModels.WebCMSEntities();
-            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryNewAfter where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
+            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryNewAfter where TradeMonth='" + TradeMonth + "'" + otherCondi + " and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
             foreach (DataRow dr in dt.Rows)
             {
                 int UserId = int.Parse(dr["UserId"].ToString());

+ 40 - 6
Util/HaoDa/ProfitBeforeHelper.cs

@@ -53,20 +53,54 @@ namespace MySystem
             }
         }
 
+        public void StartListenProfitAdd()
+        {
+            Thread th = new Thread(StartListenProfitAddDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListenProfitAddDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("ProfitBeforeQueue");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    try
+                    {
+                        DoProfit(content);
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧分润异常");
+                    }
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
         //分润算法
-        public void DoProfit()
+        public void DoProfit(string otherCondi = "")
         {
             string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
-            string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-before.txt");
-            if (!string.IsNullOrEmpty(check))
+            if(string.IsNullOrEmpty(otherCondi))
             {
-                return;
+                string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-before.txt");
+                if (!string.IsNullOrEmpty(check))
+                {
+                    return;
+                }
+                function.WritePage("/ProfitFlag/", TradeMonth + "-before.txt", DateTime.Now.ToString());
             }
-            function.WritePage("/ProfitFlag/", TradeMonth + "-before.txt", DateTime.Now.ToString());
             Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
             WebCMSEntities dbnew = new WebCMSEntities();
             KxsUserModels.WebCMSEntities udb = new KxsUserModels.WebCMSEntities();
-            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryOldBefore where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
+            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryOldBefore where TradeMonth='" + TradeMonth + "'" + otherCondi + " and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
             foreach (DataRow dr in dt.Rows)
             {
                 int UserId = int.Parse(dr["UserId"].ToString());

+ 40 - 6
Util/HaoDa/ProfitBeforeNewHelper.cs

@@ -53,20 +53,54 @@ namespace MySystem
             }
         }
 
+        public void StartListenProfitAdd()
+        {
+            Thread th = new Thread(StartListenProfitAddDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartListenProfitAddDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("ProfitBeforeNewQueue");
+                if (!string.IsNullOrEmpty(content))
+                {
+                    try
+                    {
+                        DoProfit(content);
+                    }
+                    catch (Exception ex)
+                    {
+                        LogHelper.Instance.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "来客吧分润异常");
+                    }
+                    Thread.Sleep(2000);
+                }
+                else
+                {
+                    Thread.Sleep(60000);
+                }
+            }
+        }
+
         //分润算法
-        public void DoProfit()
+        public void DoProfit(string otherCondi = "")
         {
             string TradeMonth = DateTime.Now.AddMonths(-1).ToString("yyyyMM");
-            string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-before-new.txt");
-            if (!string.IsNullOrEmpty(check))
+            if(string.IsNullOrEmpty(otherCondi))
             {
-                return;
+                string check = function.ReadInstance("/ProfitFlag/" + TradeMonth + "-before-new.txt");
+                if (!string.IsNullOrEmpty(check))
+                {
+                    return;
+                }
+                function.WritePage("/ProfitFlag/", TradeMonth + "-before-new.txt", DateTime.Now.ToString());
             }
-            function.WritePage("/ProfitFlag/", TradeMonth + "-before-new.txt", DateTime.Now.ToString());
             Models.KxsMain.WebCMSEntities kxsdb = new Models.KxsMain.WebCMSEntities();
             WebCMSEntities dbnew = new WebCMSEntities();
             KxsUserModels.WebCMSEntities udb = new KxsUserModels.WebCMSEntities();
-            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryNewBefore where TradeMonth='" + TradeMonth + "' and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
+            DataTable dt = CustomerSqlConn.dtable("select IsAct,UserId,sum(TotalAmount),Sort from UserAmountSummaryNewBefore where TradeMonth='" + TradeMonth + "'" + otherCondi + " and SeoTitle='self' group by IsAct,UserId,Sort", AppConfig.Base.SqlConnStr);
             foreach (DataRow dr in dt.Rows)
             {
                 int UserId = int.Parse(dr["UserId"].ToString());