浏览代码

测试激活统计

lcl 1 年之前
父节点
当前提交
cc5c646453
共有 5 个文件被更改,包括 109 次插入5 次删除
  1. 20 1
      .vscode/launch.json
  2. 81 0
      AppStart/Helper/StatService.cs
  3. 2 0
      Startup.cs
  4. 2 0
      appsettings.Development.json
  5. 4 4
      appsettings.json

+ 20 - 1
.vscode/launch.json

@@ -4,7 +4,7 @@
     // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
     "version": "0.2.0",
     "configurations": [{
-            "name": ".NET Core Launch (web)",
+            "name": ".NET Core Launch (Development)",
             "type": "coreclr",
             "request": "launch",
             "preLaunchTask": "build",
@@ -22,6 +22,25 @@
             "sourceFileMap": {
                 "/Views": "${workspaceFolder}/Views"
             }
+        },{
+            "name": ".NET Core Launch (Production)",
+            "type": "coreclr",
+            "request": "launch",
+            "preLaunchTask": "build",
+            "program": "${workspaceFolder}/bin/Debug/netcoreapp3.0/MySystem.dll",
+            "args": [],
+            "cwd": "${workspaceFolder}",
+            "stopAtEntry": false,
+            "serverReadyAction": {
+                "action": "openExternally",
+                "pattern": "^\\s*Now listening on:\\s+(https?://\\S+)"
+            },
+            "env": {
+                "ASPNETCORE_ENVIRONMENT": "Production"
+            },
+            "sourceFileMap": {
+                "/Views": "${workspaceFolder}/Views"
+            }
         },
         {
             "name": ".NET Core Attach",

+ 81 - 0
AppStart/Helper/StatService.cs

@@ -283,5 +283,86 @@ namespace MySystem
             maindb.Dispose();
             function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时执行创客激活数日志");
         }
+
+
+        public void test()
+        {
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "实时执行创客激活数日志");
+            WebCMSEntities db = new WebCMSEntities();
+            KxsMainModels.WebCMSEntities maindb = new KxsMainModels.WebCMSEntities();
+            try
+            {
+                DataTable idsDt = CustomerSqlConn.dtable("select 646 Id", AppConfig.Base.SqlConn);
+                if(idsDt.Rows.Count > 0)
+                {
+                    string ids = "";
+                    foreach (DataRow idsDr in idsDt.Rows)
+                    {
+                        ids += idsDr["Id"].ToString() + ",";
+                    }
+                    DataTable userDt = CustomerSqlConn.dtable("select UserId,DATE_FORMAT(SignDate,'%Y%m%d'),count(Id) from MerchantInfo where Id in (" + ids.TrimEnd(',') + ") group by UserId,DATE_FORMAT(SignDate,'%Y%m%d')", AppConfig.Base.SqlConn);
+                    if (userDt.Rows.Count > 0)
+                    {
+                        function.WriteLog("人数:" + userDt.Rows.Count + "\n\n", "实时执行创客激活数日志");
+                        foreach (DataRow userDr in userDt.Rows)
+                        {
+                            int UserId = int.Parse(userDr["UserId"].ToString());
+                            string TradeDate = userDr[1].ToString();
+                            int ActCount = int.Parse(function.CheckInt(userDr[2].ToString()));
+                            string TradeMonth = TradeDate.Substring(0, 6);
+                            string date = TradeDate.Substring(0, 4) + "-" + TradeDate.Substring(4, 2) + "-" + TradeDate.Substring(6, 2);
+                            string start = date + " 00:00:00";
+                            string end = DateTime.Parse(date).AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00";
+                            KxsMainModels.Users user = maindb.Users.FirstOrDefault(m => m.Id == UserId) ?? new KxsMainModels.Users();
+                            string ParentNav = user.ParentNav;
+                            UserTradeMonthSummary selfStat = db.UserTradeMonthSummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.SeoKeyword == TradeDate && m.SeoTitle == "self");
+                            if (selfStat == null)
+                            {
+                                selfStat = db.UserTradeMonthSummary.Add(new UserTradeMonthSummary()
+                                {
+                                    UserId = UserId,
+                                    TradeMonth = TradeMonth,
+                                    SeoKeyword = TradeDate,
+                                    SeoTitle = "self",
+                                }).Entity;
+                                db.SaveChanges();
+                            }
+                            selfStat.ActiveBuddyMerStatus += ActCount;
+                            ParentNav += "," + UserId + ",";
+                            if (!string.IsNullOrEmpty(ParentNav))
+                            {
+                                string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                                foreach (string NavUserIdString in ParentNavList)
+                                {
+                                    int NavUserId = int.Parse(NavUserIdString);
+                                    UserTradeMonthSummary teamStat = db.UserTradeMonthSummary.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.SeoKeyword == TradeDate && m.SeoTitle == "team");
+                                    if (teamStat == null)
+                                    {
+                                        teamStat = db.UserTradeMonthSummary.Add(new UserTradeMonthSummary()
+                                        {
+                                            UserId = NavUserId,
+                                            TradeMonth = TradeMonth,
+                                            SeoKeyword = TradeDate,
+                                            SeoTitle = "team",
+                                        }).Entity;
+                                        db.SaveChanges();
+                                    }
+                                    teamStat.ActiveBuddyMerStatus += ActCount;
+                                }
+                            }
+                        }
+                        db.SaveChanges();
+                        CustomerSqlConn.op("update MerchantInfo set ActStat=1 where Id in (" + ids.TrimEnd(',') + ")", AppConfig.Base.SqlConn);
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "实时执行创客激活数异常");
+            }
+            db.Dispose();
+            maindb.Dispose();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时执行创客激活数日志");
+        }
     }
 }

+ 2 - 0
Startup.cs

@@ -113,6 +113,8 @@ namespace MySystem
             //必须打开的
             StatService.Instance.Start(); //实时统计交易额
             StatService.Instance.StartPosActNum(); //实时统计激活数
+            
+            // StatService.Instance.test();
             //必须打开的
 
         }

+ 2 - 0
appsettings.Development.json

@@ -17,8 +17,10 @@
     "Host": "http://localhost:5301/",
     "SourceHost": "http://bs.qrcodeplate.com/",
     "Database": "KxsMainServer",
+    "KxsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer;charset=utf8;",
     "SqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
     "StatSqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateStatServer;password=lB6DfB3BufvLGh1h;database=QrCodePlateStatServer;charset=utf8;",
+    "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=4,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "OSSKey": "iL9dWgBunZRwGbHQ",

+ 4 - 4
appsettings.json

@@ -17,10 +17,10 @@
     "Host": "http://localhost:5301/",
     "SourceHost": "http://bs.qrcodeplate.com/",
     "Database": "KxsMainServer",
-    "KxsSqlConnStr": "server=47.109.31.237;port=3306;user=KxsMainServer;password=FrW8ZfxlcaVdm1r0;database=KxsMainServer;charset=utf8;",
-    "SqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
-    "StatSqlConnStr": "server=47.109.31.237;port=3306;user=QrCodePlateStatServer;password=lB6DfB3BufvLGh1h;database=QrCodePlateStatServer;charset=utf8;",
-    "RedisConnStr": "47.109.31.237:6379,password=klm@redis,DefaultDatabase=4,poolsize=500,preheat=50,asyncPipeline=true",
+    "KxsSqlConnStr": "server=47.108.231.170;port=3306;user=KxsMain;password=mzeqjriUWore0dwT;database=KxsMainServer;charset=utf8;",
+    "SqlConnStr": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateMainServer;password=ll4DFaALMu9YIooM;database=QrCodePlateMainServer;charset=utf8;",
+    "StatSqlConnStr": "server=rm-2vc27k81v217qs1t55o.mysql.cn-chengdu.rds.aliyuncs.com;port=3306;user=QrCodePlateStatServer;password=lB6DfB3BufvLGh1h;database=QrCodePlateStatServer;charset=utf8;",
+    "RedisConnStr": "redis:6379,password=kxsmp@2023,DefaultDatabase=0,poolsize=500,preheat=50,asyncPipeline=true",
     "IOSAppVersion": "1.0.0",
     "AndroidAppVersion": "1.0.0",
     "OSSKey": "iL9dWgBunZRwGbHQ",