Эх сурвалжийг харах

广电卡通过绑定通道判断激活
激活逻辑单独提出来

lcl 2 жил өмнө
parent
commit
cf5a020dc5

+ 8 - 1
AppStart/Helper/SycnSpServer/SycnSpBindService.cs

@@ -31,7 +31,7 @@ namespace MySystem
                     PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
                     DateTime start = DateTime.Now.AddDays(-5);
                     int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/BindRecordId.txt")));
-                    var Binds = spdb.BindRecord.Select(m => new { m.Id, m.CreateTime, m.Status, m.MerNo, m.MerSnNo, m.ProductType, m.Field1 }).Where(m => m.Id >= StartId && m.CreateTime >= start && m.Status == 1).OrderByDescending(m => m.Id).ToList();
+                    var Binds = spdb.BindRecord.Select(m => new { m.Id, m.CreateTime, m.Status, m.MerNo, m.MerSnNo, m.ProductType, m.Field1, m.Field5 }).Where(m => m.Id >= StartId && m.CreateTime >= start && m.Status == 1).OrderByDescending(m => m.Id).ToList();
                     foreach (var Bind in Binds)
                     {
                         var tran = db.Database.BeginTransaction();
@@ -129,6 +129,13 @@ namespace MySystem
                                     MachineData.UnBindCount -= 1;
                                     db.SaveChanges();
 
+                                    if(pos.BrandId == 14 && Bind.Field5 == "已激活")
+                                    {
+                                        pos.CreditTrade = 0.01M;
+                                        db.SaveChanges();
+                                        SycnSpTradeService.Instance.ActPos(db, pos, 0.01M, 30);
+                                    }
+
                                     if(pos.BuyUserId == 0 && pos.PreUserId > 0)
                                     {
                                         // RedisDbconn.Instance.Set("CheckUserBindPrePos:" + pos.PreUserId, "您的名下有已绑定的预发机 sn:" + pos.PosSn + " 尚未申请,绑定30分钟内申请即可免费自动补录,请前往客小爽产品中点击机具申请继续完成申请");

+ 55 - 49
AppStart/Helper/SycnSpServer/SycnSpTradeService.cs

@@ -29,7 +29,6 @@ namespace MySystem
                 {
                     WebCMSEntities spdb = new WebCMSEntities();
                     PxcModels.WebCMSEntities db = new PxcModels.WebCMSEntities();
-                    DateTime now = DateTime.Now;
                     DateTime start = DateTime.Now.AddDays(-10);
                     int StartId = int.Parse(function.CheckInt(function.ReadInstance("/SycnSp/TradeRecordId.txt")));
                     IQueryable<TradeRecord> trades = spdb.TradeRecord.Where(m => m.Id >= StartId && m.CreateDate >= start && m.Status == 1).OrderBy(m => m.CreateDate).Take(20);
@@ -343,54 +342,7 @@ namespace MySystem
                                             pos.DebitCardTrade += TradeAmount;
                                         }
                                         //判断激活条件并激活
-                                        DateTime TransferTime = pos.TransferTime == null ? DateTime.Now : pos.TransferTime.Value;
-                                        if (pos.CreditTrade >= CheckMoney && pos.BuyUserId > 0 && pos.ActivationState == 0 && TransferTime.AddMinutes(-30) < pos.BindingTime)
-                                        // if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0 && TransferTime < pos.BindingTime && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
-                                        {
-                                            pos.ActivationState = 1;
-                                            pos.ActivationTime = DateTime.Now;
-                                            function.WriteLog("机具" + pos.PosSn, "开机奖励在激活中监控");
-                                            PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
-                                            if (merchant != null)
-                                            {
-                                                merchant.ActiveStatus = 1;
-                                                merchant.MerStandardDate = DateTime.Now;
-                                                db.SaveChanges();
-
-                                                if(pos.BrandId != 14)
-                                                {
-                                                    function.WriteLog("商户" + merchant.KqMerNo, "开机奖励在激活中监控");
-
-                                                    // 推荐王逻辑(激活)
-                                                    // string SendData = "{\"Kind\":\"3\",\"Data\":{\"UserId\":\"" + pos.BuyUserId + "\",\"PosId\":\"" + pos.Id + "\",\"TradeMonth\":\"" + DateTime.Now.ToString("yyyyMM") + "\"}}";
-                                                    // RedisDbconn.Instance.AddList("RecommendActStatQueue", SendData);
-
-                                                    //发放开机奖励
-                                                    function.WriteLog("首台" + pos.IsFirst, "开机奖励在激活中监控");
-                                                    if(pos.IsFirst == 1 && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
-                                                    {
-                                                        RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
-                                                    }
-                                                }
-                                            }
-                                            if(pos.BrandId != 14)
-                                            {
-                                                //发放大盟主奖励
-                                                if (pos.LeaderUserId > 0 && pos.IsFirst == 1 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now) && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
-                                                {
-                                                    RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
-                                                }
-                                                //发放运营中心奖励
-                                                if (pos.IsFirst == 1 && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
-                                                {
-                                                    RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
-                                                }
-                                                AlipayPayBack2Service.Instance.ActReserveBack(pos.OpId, pos.OpReserve1, pos.OpReserve2, pos.OpReserve3);
-                                            }
-
-                                            //统计激活数
-                                            RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + DateTime.Now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
-                                        }
+                                        ActPos(db, pos, CheckMoney, CheckDays);
                                         if (TradeAmount > 0)
                                         {
                                             ulong MerHelpFlag = 0;
@@ -511,6 +463,60 @@ namespace MySystem
             }
         }
 
+        //机具激活逻辑
+        public void ActPos(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, decimal CheckMoney, int CheckDays)
+        {
+            DateTime now = DateTime.Now;
+            DateTime TransferTime = pos.TransferTime == null ? DateTime.Now : pos.TransferTime.Value;
+            if (pos.CreditTrade >= CheckMoney && pos.BuyUserId > 0 && pos.ActivationState == 0 && TransferTime.AddMinutes(-30) < pos.BindingTime)
+            // if (pos.CreditTrade >= CheckMoney && pos.ActivationState == 0 && TransferTime < pos.BindingTime && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
+            {
+                pos.ActivationState = 1;
+                pos.ActivationTime = DateTime.Now;
+                function.WriteLog("机具" + pos.PosSn, "开机奖励在激活中监控");
+                PxcModels.PosMerchantInfo merchant = db.PosMerchantInfo.FirstOrDefault(m => m.Id == pos.BindMerchantId);
+                if (merchant != null)
+                {
+                    merchant.ActiveStatus = 1;
+                    merchant.MerStandardDate = DateTime.Now;
+                    db.SaveChanges();
+
+                    if(pos.BrandId != 14)
+                    {
+                        function.WriteLog("商户" + merchant.KqMerNo, "开机奖励在激活中监控");
+
+                        // 推荐王逻辑(激活)
+                        // string SendData = "{\"Kind\":\"3\",\"Data\":{\"UserId\":\"" + pos.BuyUserId + "\",\"PosId\":\"" + pos.Id + "\",\"TradeMonth\":\"" + DateTime.Now.ToString("yyyyMM") + "\"}}";
+                        // RedisDbconn.Instance.AddList("RecommendActStatQueue", SendData);
+
+                        //发放开机奖励
+                        function.WriteLog("首台" + pos.IsFirst, "开机奖励在激活中监控");
+                        if(pos.IsFirst == 1 && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
+                        {
+                            RedisDbconn.Instance.AddList("OpenRewardQueue", pos.Id.ToString());
+                        }
+                    }
+                }
+                if(pos.BrandId != 14)
+                {
+                    //发放大盟主奖励
+                    if (pos.LeaderUserId > 0 && pos.IsFirst == 1 && db.Leaders.Any(m => m.Id == pos.LeaderUserId && m.ExpiredDate > now) && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
+                    {
+                        RedisDbconn.Instance.AddList("LeaderPrizeQueue", pos.Id);
+                    }
+                    //发放运营中心奖励
+                    if (pos.IsFirst == 1 && pos.BindingTime > DateTime.Now.AddDays(-CheckDays))
+                    {
+                        RedisDbconn.Instance.AddList("OperatePrizeQueue", pos.Id);
+                    }
+                    AlipayPayBack2Service.Instance.ActReserveBack(pos.OpId, pos.OpReserve1, pos.OpReserve2, pos.OpReserve3);
+                }
+
+                //统计激活数
+                RedisDbconn.Instance.AddList("StatActQueue", "{\"TradeDate\":\"" + DateTime.Now.ToString("yyyyMMdd") + "\",\"UserId\":\"" + pos.BuyUserId + "\",\"BrandId\":\"" + pos.BrandId + "\"}");
+            }
+        }
+
         //立刷格外奖励
         public void LiShuaActPrize(PxcModels.WebCMSEntities db, PxcModels.PosMachinesTwo pos, int prize)
         {