Browse Source

修复盒易付首台50元激活奖励发放问题

lcl 1 year ago
parent
commit
df38dec1e8
1 changed files with 76 additions and 43 deletions
  1. 76 43
      AppStart/Helper/StatService.cs

+ 76 - 43
AppStart/Helper/StatService.cs

@@ -114,6 +114,7 @@ namespace MySystem
                 {
                     function.WriteLog(DateTime.Now.ToString() + ":start", "实时处理盒易付0押激活奖励");
                     activePrizeWithoutDeposit12();
+                    activePrizeWithoutDeposit122();
                     function.WriteLog(DateTime.Now.ToString() + ":end\n\n", "实时处理盒易付0押激活奖励");
                 }
                 catch (Exception ex)
@@ -435,7 +436,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) && m.Detail != "1");
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && m.IsFirst == 1 && m.CreditTrade >= 5000 && string.IsNullOrEmpty(m.SeoKeyword) && (m.BrandId == 12 || m.BrandId == 13) && m.Detail != "1");
             if (posid > 0)
             {
                 posList = posList.Where(m => m.Id == posid);
@@ -460,60 +461,92 @@ namespace MySystem
                         {
                             TopUserId = int.Parse(ParentNav.Trim(',').Replace(",,", ",").Split(',')[0]);
                         }
-                        bool check = false;
                         //首台无押金机返50
-                        if(pos.IsFirst == 1 && pos.CreditTrade >= 5000)
+                        doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
+                        PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(item != null)
                         {
-                            doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
-                            check = true;
+                            item.Detail = "1";
+                            db.SaveChanges();
+                        }
+                    }
+                }
+            }
+            db.Dispose();
+        }
+
+
+        public void activePrizeWithoutDeposit122(int posid = 0)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            DateTime yesterday = DateTime.Now.AddDays(-30);
+            DateTime today = DateTime.Now.AddMinutes(-5);
+            DateTime checkTime = DateTime.Parse("2023-08-01 00:00:00");
+            IQueryable<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => m.ActivationState == 1 && m.IsFirst == 0 && m.CreditTrade >= 1000 && m.ActivationTime < checkTime && string.IsNullOrEmpty(m.SeoKeyword) && (m.BrandId == 12 || m.BrandId == 13) && m.Detail != "1");
+            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 == 0 && pos.CreditTrade >= 1000 && pos.ActivationState == 1 && pos.ActivationTime < DateTime.Parse("2023-08-01 00:00:00"))
+                        string IdCard = merchant.MerIdcardNo;
+                        string IdCardStart = IdCard.Substring(0, 6);
+                        string IdCardEnd = IdCard.Substring(IdCard.Length - 4);
+                        string MerName = merchant.MerchantName;
+                        List<int> BrandIds = new List<int>();
+                        BrandIds.Add(4);
+                        BrandIds.Add(5);
+                        BrandIds.Add(8);
+                        BrandIds.Add(9);
+                        PosMerchantInfo other = db.PosMerchantInfo.FirstOrDefault(m => m.MerIdcardNo.StartsWith(IdCardStart) && m.MerIdcardNo.EndsWith(IdCardEnd) && m.MerchantName.Contains(MerName) && BrandIds.Contains(m.BrandId));
+                        if(other != null)
                         {
-                            string IdCard = merchant.MerIdcardNo;
-                            string IdCardStart = IdCard.Substring(0, 6);
-                            string IdCardEnd = IdCard.Substring(IdCard.Length - 4);
-                            string MerName = merchant.MerchantName;
-                            List<int> BrandIds = new List<int>();
-                            BrandIds.Add(4);
-                            BrandIds.Add(5);
-                            BrandIds.Add(8);
-                            BrandIds.Add(9);
-                            PosMerchantInfo other = db.PosMerchantInfo.FirstOrDefault(m => m.MerIdcardNo.StartsWith(IdCardStart) && m.MerIdcardNo.EndsWith(IdCardEnd) && m.MerchantName.Contains(MerName) && BrandIds.Contains(m.BrandId));
-                            if(other != null)
+                            PosMachinesTwo checkpos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == other.KqSnNo && m.IsFirst == 1);
+                            if(checkpos != null)
                             {
-                                PosMachinesTwo checkpos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == other.KqSnNo && m.IsFirst == 1);
-                                if(checkpos != null)
+                                doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
+                                PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                                if(edit != null)
                                 {
-                                    doActiveReward(db, merchant, pos, GetUserId, ParentNav, TopUserId, 50);
-                                    PosMachinesTwo edit = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
-                                    if(edit != null)
+                                    edit.SeoKeyword = checkpos.SeoKeyword;
+                                    edit.UpFeeFlag = checkpos.UpFeeFlag;
+                                    edit.DownFeeFlag = checkpos.DownFeeFlag;
+                                    edit.UpFeeDate = checkpos.UpFeeDate;
+                                    edit.DownFeeDate = checkpos.DownFeeDate;
+                                    edit.BindingTime = checkpos.BindingTime;
+                                    edit.IsFirst = checkpos.IsFirst;
+                                    db.SaveChanges();
+                                    if(edit.UpFeeFlag == 1 && edit.DownFeeFlag == 0)
                                     {
-                                        edit.SeoKeyword = checkpos.SeoKeyword;
-                                        edit.UpFeeFlag = checkpos.UpFeeFlag;
-                                        edit.DownFeeFlag = checkpos.DownFeeFlag;
-                                        edit.UpFeeDate = checkpos.UpFeeDate;
-                                        edit.DownFeeDate = checkpos.DownFeeDate;
-                                        edit.BindingTime = checkpos.BindingTime;
-                                        edit.IsFirst = checkpos.IsFirst;
-                                        db.SaveChanges();
-                                        if(edit.UpFeeFlag == 1 && edit.DownFeeFlag == 0)
-                                        {
-                                            string info = "{\"RecordId\":\"\",\"PosId\":\"" + edit.Id + "\",\"Fee\": \"0.63\",\"Kind\": \"1\",\"OpMan\": \"系统\"}";
-                                            RedisDbconn.Instance.AddList("SetDepositPostQueue", info);
-                                        }
+                                        string info = "{\"RecordId\":\"\",\"PosId\":\"" + edit.Id + "\",\"Fee\": \"0.63\",\"Kind\": \"1\",\"OpMan\": \"系统\"}";
+                                        RedisDbconn.Instance.AddList("SetDepositPostQueue", info);
                                     }
                                 }
                             }
-                            check = true;
                         }
-                        if(check)
+                        PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
+                        if(item != null)
                         {
-                            PosMachinesTwo item = db.PosMachinesTwo.FirstOrDefault(m => m.Id == pos.Id);
-                            if(item != null)
-                            {
-                                item.Detail = "1";
-                                db.SaveChanges();
-                            }
+                            item.Detail = "1";
+                            db.SaveChanges();
                         }
                     }
                 }