Răsfoiți Sursa

补激活奖励队列

lcl 1 an în urmă
părinte
comite
69910f1e98
2 a modificat fișierele cu 78 adăugiri și 0 ștergeri
  1. 77 0
      AppStart/Helper/ActRewardService.cs
  2. 1 0
      Startup.cs

+ 77 - 0
AppStart/Helper/ActRewardService.cs

@@ -68,5 +68,82 @@ namespace MySystem
                 }
             }
         }
+
+
+
+
+        int[] BrandIds0 = { 12, 13 };
+        public void StartAfterAdd()
+        {
+            Thread th = new Thread(StartAfterAddDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+
+        public void StartAfterAddDo()
+        {
+            while (true)
+            {
+                string data = RedisDbconn.Instance.RPop<string>("StartAfterAddQueue");
+                if (!string.IsNullOrEmpty(data))
+                {
+                    try
+                    {
+                        int PosId = int.Parse(function.CheckInt(data));
+                        WebCMSEntities db = new WebCMSEntities();
+                        PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.Id == PosId);
+                        Users user = db.Users.FirstOrDefault(m => m.Id == pos.BuyUserId);
+                        if(pos != null && user != null)
+                        {
+                            decimal Deposit = decimal.Parse(function.CheckNum(pos.SeoKeyword));
+                            if(Deposit > 1000)
+                            {
+                                Deposit /= 100;
+                            }
+                            PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId) ?? new PosMerchantInfo();
+                            int BuyTopUserId = 0;
+                            string ParentNav = user.ParentNav;
+                            if (!string.IsNullOrEmpty(ParentNav))
+                            {
+                                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                                if (ParentNavList.Length > 1)
+                                {
+                                    BuyTopUserId = int.Parse(ParentNavList[1]);
+                                }
+                                else if (ParentNavList.Length == 1)
+                                {
+                                    BuyTopUserId = int.Parse(ParentNavList[0]);
+                                }
+                            }
+                            decimal RewardAmount = 0;
+                            if(Deposit > 0)
+                            {
+                                RewardAmount = 100;
+                            }
+                            else
+                            {
+                                if(BrandIds0.Contains(pos.BrandId))
+                                {
+                                    RewardAmount = 50;
+                                }
+                            }
+                            if(RewardAmount > 0)
+                            {
+                                StatService.Instance.doActiveReward(db, merchant, pos, user.Id, user.ParentNav, BuyTopUserId, RewardAmount);
+                            }
+                        }
+                        db.Dispose();
+                    }
+                    catch (Exception ex)
+                    {                        
+                        function.WriteLog(DateTime.Now.ToString() + "\r\n" + ex.ToString(), "设置激活奖励异常");
+                    }
+                }
+                else
+                {
+                    Thread.Sleep(500);
+                }
+            }
+        }
     }
 }

+ 1 - 0
Startup.cs

@@ -189,6 +189,7 @@ namespace MySystem
                 LeaderPrizeService.Instance.Start(); //大盟主奖励发奖
                 OperatePrizeService.Instance.Start(); //运营中心奖励发奖
                 ActRewardService.Instance.Start(); //发放激活奖励
+                ActRewardService.Instance.StartAfterAdd(); //补激活奖励
                 HelpProfitPreMerchantHelper.Instance.Start(); //助利宝每天增加指定数量商机
                 AddActService.Instance.Start(); //划拨后检查机具激活状态,并自动补录
                 PrePosRingService.Instance.Start(); //预发未申请提醒