Explorar o código

分离激活奖励队列

lcl hai 1 ano
pai
achega
ce97395a4c
Modificáronse 2 ficheiros con 85 adicións e 11 borrados
  1. 82 10
      AppStart/Helper/StatService.cs
  2. 3 1
      Startup.cs

+ 82 - 10
AppStart/Helper/StatService.cs

@@ -58,17 +58,70 @@ namespace MySystem
 
         public void ActiveReward()
         {
-            try
+            while(true)
             {
-                dosomething3();
-                activePrizeWithoutDeposit();
-                activePrizeWithoutDeposit12();
+                try
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":start", "实时处理激活奖励");
+                    dosomething3();
+                    function.WriteLog(DateTime.Now.ToString() + ":end\n\n", "实时处理激活奖励");
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "实时处理激活奖励异常");
+                }
+                Thread.Sleep(30000);
             }
-            catch (Exception ex)
+        }
+
+        public void StartActiveReward1()
+        {
+            Thread th = new Thread(ActiveReward1);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void ActiveReward1()
+        {
+            while(true)
+            {
+                try
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":start", "实时处理0押激活奖励");
+                    activePrizeWithoutDeposit();
+                    function.WriteLog(DateTime.Now.ToString() + ":end\n\n", "实时处理0押激活奖励");
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "实时处理0押激活奖励异常");
+                }
+                Thread.Sleep(30000);
+            }
+        }
+
+        public void StartActiveReward2()
+        {
+            Thread th = new Thread(ActiveReward2);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void ActiveReward2()
+        {
+            while(true)
             {
-                function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "实时处理激活记录异常");
+                try
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":start", "实时处理盒易付0押激活奖励");
+                    activePrizeWithoutDeposit12();
+                    function.WriteLog(DateTime.Now.ToString() + ":end\n\n", "实时处理盒易付0押激活奖励");
+                }
+                catch (Exception ex)
+                {
+                    function.WriteLog(DateTime.Now.ToString() + ":" + ex.ToString(), "实时处理盒易付0押激活奖励异常");
+                }
+                Thread.Sleep(30000);
             }
-            Thread.Sleep(30000);
         }
 
 
@@ -222,7 +275,7 @@ namespace MySystem
             WebCMSEntities db = new WebCMSEntities();
             DateTime yesterday = DateTime.Now.AddDays(-1);
             DateTime today = DateTime.Now;
-            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && !string.IsNullOrEmpty(m.SeoKeyword));
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && !string.IsNullOrEmpty(m.SeoKeyword) && m.Detail != "1");
             if (posid > 0)
             {
                 posList = posList.Where(m => m.Id == posid);
@@ -290,6 +343,12 @@ namespace MySystem
                                 doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
                             }
                         }
+                        PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(edit != null)
+                        {
+                            edit.Detail = "1";
+                            db.SaveChanges();
+                        }
                     }
                     // }
                 }
@@ -321,7 +380,7 @@ namespace MySystem
             WebCMSEntities db = new WebCMSEntities();
             DateTime yesterday = DateTime.Now.AddDays(-1);
             DateTime today = DateTime.Now.AddMinutes(-5);
-            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && string.IsNullOrEmpty(m.SeoKeyword) && m.BrandId != 12);
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && string.IsNullOrEmpty(m.SeoKeyword) && m.BrandId != 12 && m.Detail != "1");
             if (posid > 0)
             {
                 posList = posList.Where(m => m.Id == posid);
@@ -359,6 +418,12 @@ namespace MySystem
                             //金控活动机返奖励
                             doJk30(db, pos, merchant, GetUserId, ParentNav, TopUserId);
                         }
+                        PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(edit != null)
+                        {
+                            edit.Detail = "1";
+                            db.SaveChanges();
+                        }
                     }
                 }
             }
@@ -370,7 +435,7 @@ namespace MySystem
             WebCMSEntities db = new WebCMSEntities();
             DateTime yesterday = DateTime.Now.AddDays(-30);
             DateTime today = DateTime.Now.AddMinutes(-5);
-            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && string.IsNullOrEmpty(m.SeoKeyword) && (m.BrandId == 12 || m.BrandId == 13));
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && string.IsNullOrEmpty(m.SeoKeyword) && (m.BrandId == 12 || m.BrandId == 13) && m.Detail != "1");
             if (posid > 0)
             {
                 posList = posList.Where(m => m.Id == posid);
@@ -438,6 +503,12 @@ namespace MySystem
                                 }
                             }
                         }
+                        PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(item != null)
+                        {
+                            item.Detail = "1";
+                            db.SaveChanges();
+                        }
                     }
                 }
             }
@@ -450,6 +521,7 @@ namespace MySystem
             bool check1 = db.ActiveReward.Any(m => m.KqSnNo == pos.PosSn && m.RewardAmount == ActPrize);
             if (!check && !check1)
             {
+                function.WriteLog(DateTime.Now.ToString() + ":" + pos.PosSn, "实时处理激活奖励");
                 Users machineUser = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId) ?? new Users();
                 db.ActiveReward.Add(new ActiveReward()
                 {

+ 3 - 1
Startup.cs

@@ -187,7 +187,9 @@ namespace MySystem
             SycnSpUnBindService.Instance.Start(); //同步SP解绑数据
             SycnSpMerchantRecordService.Instance.Start(); //同步SP商户记录数据
 
-            StatService.Instance.StartActiveReward(); //实时处理激活记录
+            StatService.Instance.StartActiveReward(); //实时处理激活奖励
+            StatService.Instance.StartActiveReward1(); //实时处理0押激活奖励
+            StatService.Instance.StartActiveReward2(); //实时处理盒易付0押激活奖励
             StatService.Instance.StartOpenReward(); //实时获取开机奖励
             StatService.Instance.ListenFluxRecord(); //实时获取流量费分佣
             LeaderPrizeService.Instance.Start(); //大盟主奖励发奖