Browse Source

盒子的无押金50元奖励,单独执行

lichunlei 2 years ago
parent
commit
e7a710d098
1 changed files with 43 additions and 11 deletions
  1. 43 11
      AppStart/Helper/StatService.cs

+ 43 - 11
AppStart/Helper/StatService.cs

@@ -65,11 +65,7 @@ namespace MySystem
             {
                 dosomething3();
                 activePrizeWithoutDeposit();
-                // string Msg = "success";
-                // jobInfo.Status = Msg == "success" ? 1 : 0;
-                // jobInfo.Msg = Msg == "success" ? "执行完成" : Msg;
-                // RabbitMQClient.Instance.SendMsg(Newtonsoft.Json.JsonConvert.SerializeObject(jobInfo), "PublicBack");
-                // function.WritePage("/static/", "act.txt", DateTime.Now.ToString());
+                activePrizeWithoutDeposit12();
             }
             catch (Exception ex)
             {
@@ -335,9 +331,9 @@ namespace MySystem
         public void activePrizeWithoutDeposit(int posid = 0)
         {
             WebCMSEntities db = new WebCMSEntities();
-            DateTime yesterday = DateTime.Now.AddDays(-5);
+            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));
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && string.IsNullOrEmpty(m.SeoKeyword) && m.BrandId != 12);
             if (posid > 0)
             {
                 posList = posList.Where(m => m.Id == posid);
@@ -370,10 +366,6 @@ namespace MySystem
                         {
                             doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
                         }
-                        else if(pos.BrandId == 12 && pos.IsFirst == 1 && pos.CreditTrade >= 5000) //首台无押金机返50
-                        {
-                            doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
-                        }
                         else
                         {
                             //金控活动机返奖励
@@ -385,6 +377,46 @@ namespace MySystem
             db.Dispose();
         }
 
+        public void activePrizeWithoutDeposit12(int posid = 0)
+        {
+            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);
+            if (posid > 0)
+            {
+                posList = posList.Where(m => m.Id == posid);
+            }
+            else
+            {
+                posList = posList.Where(m => m.ActivationTime >= yesterday && m.ActivationTime < today);
+            }
+            foreach (PosMachinesTwo pos in posList.ToList())
+            {
+                PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
+                if (merchant != null)
+                {
+                    string ParentNav = "";
+                    Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId);
+                    if (user != null)
+                    {
+                        int GetUserId = user.Id;
+                        ParentNav = user.ParentNav;
+                        int TopUserId = 0;
+                        if (!string.IsNullOrEmpty(ParentNav))
+                        {
+                            TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
+                        }
+                        if(pos.IsFirst == 1 && pos.CreditTrade >= 5000) //首台无押金机返50
+                        {
+                            doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
+                        }
+                    }
+                }
+            }
+            db.Dispose();
+        }
+
         public void doActiveReward(WebCMSEntities db, PosMerchantInfo merchant, PosMachinesTwo pos, int GetUserId, string ParentNav, int TopUserId, decimal ActPrize, int ChangeType = 0, int ActType = 0)
         {
             bool check = db.ActiveReward.Any(m => m.KqMerNo == merchant.KqMerNo && m.RewardAmount == ActPrize);