Procházet zdrojové kódy

统计来量吧漏掉的数据

lcl před 1 rokem
rodič
revize
1422d6fe77
2 změnil soubory, kde provedl 86 přidání a 62 odebrání
  1. binární
      .DS_Store
  2. 86 62
      AppStart/Timer/TestHelper.cs

binární
.DS_Store


+ 86 - 62
AppStart/Timer/TestHelper.cs

@@ -2104,60 +2104,14 @@ public class TestHelper
 
     public void tmpdo()
     {
+        string check = function.ReadInstance("/tmpdo.txt");
+        if(!string.IsNullOrEmpty(check))
+        {
+            return;
+        }
+        function.WritePage("/", "tmpdo.txt", DateTime.Now.ToString());
         WebCMSEntities db = new WebCMSEntities();
         List<string> list = new List<string>();
-        list.Add("2024-10-21 16:18:46,799.00,720,1014DL2130087");
-        list.Add("2024-10-21 15:08:02,499.00,360,1014DL2115765");
-        list.Add("2024-10-21 14:56:10,119.00,360,1182460943");
-        list.Add("2024-10-21 14:52:50,399.00,360,126800303956");
-        list.Add("2024-10-21 14:19:13,799.00,720,1014DL2083849");
-        list.Add("2024-10-21 14:00:57,119.00,360,1182459044");
-        list.Add("2024-10-21 13:54:32,199.00,90,1014DL2012889");
-        list.Add("2024-10-21 13:45:01,499.00,360,1014DL2130525");
-        list.Add("2024-10-21 13:28:40,399.00,360,126800303733");
-        list.Add("2024-10-21 12:38:33,119.00,360,1182463442");
-        list.Add("2024-10-21 12:15:27,699.00,720,126800310191");
-        list.Add("2024-10-21 12:14:47,119.00,360,1182456669");
-        list.Add("2024-10-21 11:56:46,499.00,360,1014DL2070549");
-        list.Add("2024-10-21 11:51:01,399.00,360,126800320505");
-        list.Add("2024-10-21 10:32:22,499.00,360,1014DL2175348");
-        list.Add("2024-10-21 10:30:22,499.00,360,1014DL2111780");
-        list.Add("2024-10-20 21:28:06,699.00,720,126800307734");
-        list.Add("2024-10-20 21:04:30,119.00,360,1182456271");
-        list.Add("2024-10-20 21:01:30,799.00,720,1014DL2023084");
-        list.Add("2024-10-20 20:24:23,399.00,360,126800307304");
-        list.Add("2024-10-20 18:56:55,119.00,360,1182462956");
-        list.Add("2024-10-20 18:49:19,59.00,30,126800301265");
-        list.Add("2024-10-20 18:12:47,199.00,90,1014DL2169762");
-        list.Add("2024-10-20 17:58:36,119.00,360,1182460844");
-        list.Add("2024-10-20 17:36:50,499.00,360,1014DL2171602");
-        list.Add("2024-10-20 16:45:53,119.00,360,1182457188");
-        list.Add("2024-10-20 16:16:47,119.00,360,1182463194");
-        list.Add("2024-10-20 16:04:31,399.00,360,126800307882");
-        list.Add("2024-10-20 15:51:31,399.00,360,126800310951");
-        list.Add("2024-10-20 15:38:40,119.00,360,1182461743");
-        list.Add("2024-10-20 15:37:00,159.00,90,126800298867");
-        list.Add("2024-10-20 15:26:25,499.00,360,1014DL2132182");
-        list.Add("2024-10-20 14:43:43,499.00,360,1014DL2180462");
-        list.Add("2024-10-20 14:38:58,119.00,360,1182457113");
-        list.Add("2024-10-20 14:36:22,399.00,360,126800306058");
-        list.Add("2024-10-20 14:29:17,399.00,360,126800315646");
-        list.Add("2024-10-20 14:17:41,499.00,360,1014DL2082940");
-        list.Add("2024-10-20 13:20:39,499.00,360,1014DL2009968");
-        list.Add("2024-10-20 12:53:53,69.00,30,1014DL2177807");
-        list.Add("2024-10-20 12:20:27,399.00,360,126800325132");
-        list.Add("2024-10-20 12:09:11,399.00,360,126800327674");
-        list.Add("2024-10-20 12:09:11,399.00,360,126800327674");
-        list.Add("2024-10-20 11:56:06,499.00,360,1014DL2172469");
-        list.Add("2024-10-20 11:38:50,799.00,720,1014DL2041201");
-        list.Add("2024-10-20 11:28:45,119.00,360,1182457626");
-        list.Add("2024-10-20 11:14:59,499.00,360,1014DL2123082");
-        list.Add("2024-10-20 10:53:18,499.00,360,1014DL2062363");
-        list.Add("2024-10-20 10:50:08,499.00,360,1014DL2063767");
-        list.Add("2024-10-20 10:22:32,119.00,360,1182454540");
-        list.Add("2024-10-20 08:52:24,119.00,360,1182457287");
-        list.Add("2024-10-20 08:32:48,119.00,360,1182459515");
-        list.Add("2024-10-19 21:20:51,799.00,720,1014DL2063825");
         list.Add("2024-10-19 21:04:55,119.00,360,1182462634");
         list.Add("2024-10-19 20:08:34,119.00,360,1182454425");
         list.Add("2024-10-19 19:57:41,119.00,360,1182460737");
@@ -2530,6 +2484,20 @@ public class TestHelper
         list.Add("2024-09-30 15:46:58,119.00,360,1221623093");
         list.Add("2024-09-30 15:21:37,199.00,720,1221613011");
         list.Add("2024-09-30 14:40:50,119.00,360,1221607047");
+        List<int> bids = new List<int>();
+        bids.Add(23);
+        bids.Add(24);
+        bids.Add(25);
+        bids.Add(26);
+        List<Users> users = db.Users.Where(m => m.AuthFlag == 1).ToList();
+        function.WriteLog("1--" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计来量吧漏掉的交易");
+        List<PosMachinesTwo> posList = db.PosMachinesTwo.Where(m => bids.Contains(m.BrandId)).ToList();
+        function.WriteLog("2--" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计来量吧漏掉的交易");
+        List<WifiTradeRecord> tradeList = db.WifiTradeRecord.ToList();
+        function.WriteLog("3--" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计来量吧漏掉的交易");
+        List<TradeDaySummary> statList = db.TradeDaySummary.Where(m => m.Id >= 22361221 && bids.Contains(m.BrandId)).ToList();
+        function.WriteLog("4--" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "统计来量吧漏掉的交易");
+        statNew = new List<TradeDaySummary>();
         foreach(string sub in list)
         {
             string[] data = sub.Split(',');
@@ -2540,31 +2508,87 @@ public class TestHelper
             decimal TradeAmt = TradeAmount / Months;
             TradeAmt = PublicFunction.NumberFormat(TradeAmt);
             string TradeMonth = TradeTime.AddMonths(-1).ToString("yyyyMM");
-            PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
-            bool statFlag = db.WifiTradeRecord.Any(m => m.SnNo == PosSn && m.CreateDate < TradeTime);
+            PosMachinesTwo pos = posList.FirstOrDefault(m => m.PosSn == PosSn) ?? new PosMachinesTwo();
+            bool statFlag = tradeList.Any(m => m.SnNo == PosSn && m.CreateDate < TradeTime);
             if(statFlag)
             {
-                TradeDaySummary stat = db.TradeDaySummary.Where(m => m.UserId == pos.BuyUserId && m.BrandId == pos.BrandId).OrderByDescending(m => m.Id).FirstOrDefault() ?? new TradeDaySummary();
+                TradeDaySummary stat = statList.Where(m => m.UserId == pos.BuyUserId && m.BrandId == pos.BrandId).OrderByDescending(m => m.Id).FirstOrDefault() ?? new TradeDaySummary();
                 TradeMonth = string.IsNullOrEmpty(stat.TradeMonth) ? TradeTime.AddMonths(-1).ToString("yyyyMM") : stat.TradeMonth;
             }
             DateTime StartMonth = DateTime.Parse(TradeMonth.Substring(0, 4) + "-" + TradeMonth.Substring(4, 2) + "-01 00:00:00");
             for (int i = 1; i <= Months; i++)
             {
                 StartMonth = StartMonth.AddMonths(1);
-                SycnSpTradeWifiService.Instance.StatTrade(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
-                if (pos.BindingTime < TradeTime.AddMonths(-9))
+                StatTrade(users, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+            }
+            function.WriteLog(sub, "统计来量吧漏掉的交易");
+        }
+        int index = 0;
+        foreach(TradeDaySummary subData in statNew)
+        {
+            index += 1;
+            if(index > 1620)
+            {
+                db.TradeDaySummary.Add(subData);
+                if(index % 20 == 0) db.SaveChanges();
+                function.WriteLog(index.ToString(), "统计来量吧漏掉的交易");
+            }
+        }
+        db.SaveChanges();
+        db.Dispose();
+        function.WriteLog("end", "统计来量吧漏掉的交易");
+    }
+
+    List<TradeDaySummary> statNew = new List<TradeDaySummary>();
+    public void StatTrade(List<Users> users, int UserId, int BrandId, string TradeMonth, decimal TradeAmount)
+    {
+        Users user = users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+        string ParentNav = user.ParentNav;
+        string TradeDate = TradeMonth + "01";
+        ParentNav += "," + UserId + ",";
+
+        TradeDaySummary selfStat = statNew.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "self");
+        if (selfStat == null)
+        {
+            statNew.Add(new TradeDaySummary()
+            {
+                UserId = UserId,
+                TradeMonth = TradeMonth,
+                TradeDate = TradeDate,
+                BrandId = BrandId,
+                SeoTitle = "self",
+                HelpDirectTradeAmt = TradeAmount
+            });
+        }
+        else
+        {
+            selfStat.HelpDirectTradeAmt += TradeAmount;
+        }
+        if (!string.IsNullOrEmpty(ParentNav))
+        {
+            string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+            foreach (string NavUserIdString in ParentNavList)
+            {
+                int NavUserId = int.Parse(NavUserIdString);
+                TradeDaySummary teamStat = statNew.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDate == TradeDate && m.BrandId == BrandId && m.SeoTitle == "team");
+                if (teamStat == null)
                 {
-                    SycnSpTradeWifiService.Instance.StatTradeBefore(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                    statNew.Add(new TradeDaySummary()
+                    {
+                        UserId = NavUserId,
+                        TradeMonth = TradeMonth,
+                        TradeDate = TradeDate,
+                        BrandId = BrandId,
+                        SeoTitle = "team",
+                        HelpNonDirectTradeAmt = TradeAmount
+                    });
                 }
                 else
                 {
-                    SycnSpTradeWifiService.Instance.StatTradeAfter(db, pos.BuyUserId, pos.BrandId, StartMonth.ToString("yyyyMM"), TradeAmt);
+                    teamStat.HelpNonDirectTradeAmt += TradeAmount;
                 }
             }
-            function.WriteLog(sub, "统计来量吧漏掉的交易");
         }
-        db.Dispose();
-        function.WriteLog("end", "统计来量吧漏掉的交易");
     }
 
 }