浏览代码

统计上月推荐王

lcl 8 月之前
父节点
当前提交
f95e8c229b
共有 1 个文件被更改,包括 14 次插入13 次删除
  1. 14 13
      AppStart/Helper/RecommandKingHelper.cs

+ 14 - 13
AppStart/Helper/RecommandKingHelper.cs

@@ -29,24 +29,27 @@ namespace MySystem
             {
                 if(DateTime.Now.Hour > 0 && DateTime.Now.Hour < 23)
                 {
-                    Recommend();
+                    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);
             }
         }
-        public void Recommend()
+        public void Recommend(string TradeMonth)
         {
-            string today = DateTime.Now.ToString("yyyy-MM-dd");
-            string checkFlag = function.ReadInstance("/RecommandKing/" + today + ".txt");
-            if(!string.IsNullOrEmpty(checkFlag))
-            {
-                return;
-            }
-            function.WritePage("/RecommandKing/", today + ".txt", DateTime.Now.ToString());
             List<int> ReduceUserId = new List<int>();
             WebCMSEntities db = new WebCMSEntities();
             List<RecommendDirectUser> list = new List<RecommendDirectUser>();
-            string TradeMonth = DateTime.Now.AddMonths(-0).ToString("yyyyMM");
             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);
@@ -54,10 +57,9 @@ namespace MySystem
             Historys.Add(174506);
             Historys.Add(127023);
             DateTime check = DateTime.Parse("2023-10-01 00:00:00");
-            DateTime start = DateTime.Parse(DateTime.Now.AddMonths(-0).ToString("yyyy-MM") + "-01 00:00:00");
+            DateTime start = DateTime.Parse(TradeMonth + "-01 00:00:00");
             DateTime end = start.AddMonths(1);
             CustomerSqlConn.op("delete from RecommendDirectUser where TradeMonth='" + TradeMonth + "'", MysqlConn.SqlConnStr);
-            string PreTradeMonth = DateTime.Now.AddMonths(-0).ToString("yyyyMM");
             List<int> ProductIds = new List<int>();
             ProductIds.Add(10);
             ProductIds.Add(11);
@@ -69,7 +71,6 @@ namespace MySystem
             ProductIds.Add(39);
             ProductIds.Add(40);
             List<RecommandKingItem> users = new List<RecommandKingItem>();
-            // Dictionary<int, decimal> PreMonthAmt = GetTradeAmtList(PreTradeMonth);
             ReadModels.WebCMSEntities readdb = new ReadModels.WebCMSEntities();
             MpMainModels.WebCMSEntities mpdb = new MpMainModels.WebCMSEntities();
             MpMainModels2.WebCMSEntities mpdb2 = new MpMainModels2.WebCMSEntities();