浏览代码

实时统计每次查询50条数据

lichunlei 3 年之前
父节点
当前提交
42756eb3e7
共有 1 个文件被更改,包括 6 次插入8 次删除
  1. 6 8
      AppStart/Helper/StatService.cs

+ 6 - 8
AppStart/Helper/StatService.cs

@@ -1852,7 +1852,7 @@ namespace MySystem
             WebCMSEntities db = new WebCMSEntities();
             try
             {
-                DataTable idsDt = OtherMySqlConn.dtable("select Id from PosMachinesTwo where QueryCount=0 and ActivationState=1 and ActivationTime is not null and BuyUserId>0 limit 200");
+                DataTable idsDt = OtherMySqlConn.dtable("select Id from PosMachinesTwo where QueryCount=0 and ActivationState=1 and ActivationTime is not null and BuyUserId>0 limit 50");
                 if(idsDt.Rows.Count > 0)
                 {
                     string ids = "";
@@ -1863,7 +1863,6 @@ namespace MySystem
                     DataTable userDt = OtherMySqlConn.dtable("select BuyUserId,BrandId,DATE_FORMAT(ActivationTime, '%Y%m%d'),count(Id) from PosMachinesTwo where Id in (" + ids.TrimEnd(',') + ") group by BuyUserId,BrandId,DATE_FORMAT(ActivationTime, '%Y%m%d')");
                     if (userDt.Rows.Count > 0)
                     {
-                        OtherMySqlConn.op("update PosMachinesTwo set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
                         function.WriteLog("人数:" + userDt.Rows.Count + "\n\n", "实时执行创客激活数日志");
                         foreach (DataRow userDr in userDt.Rows)
                         {
@@ -1893,7 +1892,6 @@ namespace MySystem
                                 db.SaveChanges();
                             }
                             selfStat.DirectDebitCapNum += ActCount;
-                            db.SaveChanges();
                             ParentNav += "," + UserId + ",";
                             if (!string.IsNullOrEmpty(ParentNav))
                             {
@@ -1916,10 +1914,11 @@ namespace MySystem
                                         db.SaveChanges();
                                     }
                                     teamStat.NonDirectDebitCapNum += ActCount;
-                                    db.SaveChanges();
                                 }
                             }
                         }
+                        db.SaveChanges();
+                        OtherMySqlConn.op("update PosMachinesTwo set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
                     }
                 }
             }
@@ -2045,7 +2044,7 @@ namespace MySystem
             WebCMSEntities db = new WebCMSEntities();
             try
             {
-                DataTable idsDt = OtherMySqlConn.dtable("select Id from Users where QueryCount=0 and AuthFlag=1 and AuthDate is not null limit 200");
+                DataTable idsDt = OtherMySqlConn.dtable("select Id from Users where QueryCount=0 and AuthFlag=1 and AuthDate is not null limit 50");
                 if(idsDt.Rows.Count > 0)
                 {
                     string ids = "";
@@ -2056,7 +2055,6 @@ namespace MySystem
                     DataTable userDt = OtherMySqlConn.dtable("select ParentUserId,DATE_FORMAT(AuthDate, '%Y%m%d'),count(Id) from Users where Id in (" + ids.TrimEnd(',') + ") group by ParentUserId,DATE_FORMAT(AuthDate, '%Y%m%d')");
                     if(userDt.Rows.Count > 0)
                     {
-                        OtherMySqlConn.op("update Users set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
                         function.WriteLog("人数:" + userDt.Rows.Count + "\n\n", "实时执行新增创客数日志");
                         foreach (DataRow userDr in userDt.Rows)
                         {
@@ -2081,7 +2079,6 @@ namespace MySystem
                                 db.SaveChanges();
                             }
                             selfStat.RecUserAuthNum += AddCount;
-                            db.SaveChanges();
                             ParentNav += "," + UserId + ",";
                             if (!string.IsNullOrEmpty(ParentNav))
                             {
@@ -2102,10 +2099,11 @@ namespace MySystem
                                         db.SaveChanges();
                                     }
                                     teamStat.RecUserAuthNum += AddCount;
-                                    db.SaveChanges();
                                 }
                             }
                         }
+                        db.SaveChanges();
+                        OtherMySqlConn.op("update Users set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
                     }
                 }
             }