lcl 6 months ago
parent
commit
81bcadb271
2 changed files with 64 additions and 30 deletions
  1. 62 28
      AppStart/Helper/RecommandKingHelper.cs
  2. 2 2
      Startup.cs

+ 62 - 28
AppStart/Helper/RecommandKingHelper.cs

@@ -25,41 +25,72 @@ namespace MySystem
         }
         public void StartFor()
         {
-            while (true)
-            {
-                if(DateTime.Now.Hour > 19 && DateTime.Now.Hour < 23)
-                {
-                    string today = DateTime.Now.ToString("yyyy-MM-dd");
-                    string checkFlag = function.ReadInstance("/RecommandKing/" + today + ".txt");
-                    if(string.IsNullOrEmpty(checkFlag))
-                    {
-                        function.WritePage("/RecommandKing/", today + ".txt", DateTime.Now.ToString());
+            // while (true)
+            // {
+            //     if(DateTime.Now.Hour > 19 && DateTime.Now.Hour < 23)
+            //     {
+            //         string today = DateTime.Now.ToString("yyyy-MM-dd");
+            //         string checkFlag = function.ReadInstance("/RecommandKing/" + today + ".txt");
+            //         if(string.IsNullOrEmpty(checkFlag))
+            //         {
+            //             function.WritePage("/RecommandKing/", today + ".txt", DateTime.Now.ToString());
 
-                        if(DateTime.Now.Day == 2)
-                        {
-                            Recommend(DateTime.Now.AddMonths(-1).ToString("yyyyMM"));
-                        }
-                        Recommend(DateTime.Now.ToString("yyyyMM"));
-                    }
-                }
-                Thread.Sleep(600000);
-            }
+            //             if(DateTime.Now.Day == 2)
+            //             {
+            //                 Recommend(DateTime.Now.AddMonths(-1).ToString("yyyyMM"));
+            //             }
+            //             Recommend(DateTime.Now.ToString("yyyyMM"));
+            //         }
+            //     }
+            //     Thread.Sleep(600000);
+            // }
+            Recommend("202311", 50);
+            Recommend("202312", 50);
+            Recommend("202401", 50);
+            Recommend("202402", 50);
+            Recommend("202403", 50);
+            Recommend("202404", 50);
+            Recommend("202405", 50);
+            Recommend("202406", 50);
+            Recommend("202407", 50);
+            Recommend("202408", 50);
+            Recommend("202311", 45);
+            Recommend("202312", 45);
+            Recommend("202401", 45);
+            Recommend("202402", 45);
+            Recommend("202403", 45);
+            Recommend("202404", 45);
+            Recommend("202405", 45);
+            Recommend("202406", 45);
+            Recommend("202407", 45);
+            Recommend("202408", 45);
+            Recommend("202311", 40);
+            Recommend("202312", 40);
+            Recommend("202401", 40);
+            Recommend("202402", 40);
+            Recommend("202403", 40);
+            Recommend("202404", 40);
+            Recommend("202405", 40);
+            Recommend("202406", 40);
+            Recommend("202407", 40);
+            Recommend("202408", 40);
         }
-        public void Recommend(string TradeMonth)
+        public void Recommend(string TradeMonth, int CheckActCount)
         {
             List<int> ReduceUserId = new List<int>();
             WebCMSEntities db = new WebCMSEntities();
             List<RecommendDirectUser> list = new List<RecommendDirectUser>();
-            List<int> Historys = db.RecommendDirectUser.Where(m => m.QueryCount >= 50 && m.TradeMonth != TradeMonth).ToList().Select(m => m.UserId).ToList();
-            Historys.Add(565);
-            Historys.Add(139473);
-            Historys.Add(173790);
-            Historys.Add(174506);
-            Historys.Add(127023);
+            List<int> Historys = new List<int>();
+            // List<int> Historys = db.RecommendDirectUser.Where(m => m.QueryCount >= 50 && m.TradeMonth != TradeMonth).ToList().Select(m => m.UserId).ToList();
+            // Historys.Add(565);
+            // Historys.Add(139473);
+            // Historys.Add(173790);
+            // Historys.Add(174506);
+            // Historys.Add(127023);
             DateTime check = DateTime.Parse("2023-10-01 00:00:00");
             DateTime start = DateTime.Parse(TradeMonth.Substring(0, 4) + "-" + TradeMonth.Substring(4, 2) + "-01 00:00:00");
             DateTime end = start.AddMonths(1);
-            CustomerSqlConn.op("delete from RecommendDirectUser where TradeMonth='" + TradeMonth + "'", MysqlConn.SqlConnStr);
+            CustomerSqlConn.op("delete from RecommendDirectUser", MysqlConn.SqlConnStr);
             List<int> ProductIds = new List<int>();
             ProductIds.Add(10);
             ProductIds.Add(11);
@@ -181,7 +212,7 @@ namespace MySystem
                 foreach(RecommandKingItem sub in subs)
                 {
                     function.WriteLog(sub.UserId + ":" + sub.ActCount, "推荐王最终的达标创客数量分析");
-                    if(sub.ActCount < 50 && sub.UserLevel < 5 && !Historys.Contains(sub.UserId))
+                    if(sub.ActCount < CheckActCount && sub.UserLevel < 5 && !Historys.Contains(sub.UserId))
                     {
                         ActCount += sub.ActCount;
                         if(sub.Op) ActCount += 1;
@@ -204,7 +235,7 @@ namespace MySystem
                         {
                             UserId = user.UserId,
                             TradeMonth = TradeMonth,
-                            QueryCount = user.ActCount > 50 ? 50 : user.ActCount,
+                            QueryCount = user.ActCount > CheckActCount ? CheckActCount : user.ActCount,
                         }).Entity;
                         if(num % 200 == 0)
                         {
@@ -218,6 +249,9 @@ namespace MySystem
             readdb.Dispose();
             mpdb.Dispose();
             mpdb2.Dispose();
+
+            CustomerSqlConn.op("CREATE TABLE RecommendDirectUser" + TradeMonth + "_" + CheckActCount + " LIKE RecommendDirectUser", MysqlConn.SqlConnStr);
+            CustomerSqlConn.op("INSERT INTO RecommendDirectUser" + TradeMonth + "_" + CheckActCount + " SELECT * FROM RecommendDirectUser", MysqlConn.SqlConnStr);
         }
 
         public decimal GetTradeAmt(int UserId, string TradeMonth)

+ 2 - 2
Startup.cs

@@ -166,9 +166,9 @@ namespace MySystem
             // }
             // if(Library.ConfigurationManager.EnvironmentFlag == 2)
             // {
-                LeaderCompPrizeHelper.Instance.Start(); //领导人达标奖
+                // LeaderCompPrizeHelper.Instance.Start(); //领导人达标奖
                 RecommandKingHelper.Instance.Start(); //推荐王
-                AddSourcePosSnHelper.Instance.Start(); //补来源机具
+                // AddSourcePosSnHelper.Instance.Start(); //补来源机具
             // } 
 
             // LeaderCompPrizeHelper.Instance.StartTest();