Pārlūkot izejas kodu

添加广电卡统计程序

lcl 2 gadi atpakaļ
vecāks
revīzija
85293beea6

+ 130 - 1
AppStart/Helper/StatService.cs

@@ -34,6 +34,7 @@ namespace MySystem
                 if(RedisDbconn.Instance.Get<string>("StatServerStatus") == "1" && DateTime.Now.Hour >= 3)
                 if(RedisDbconn.Instance.Get<string>("StatServerStatus") == "1" && DateTime.Now.Hour >= 3)
                 {
                 {
                     StatTradeAmountEverDayV2();
                     StatTradeAmountEverDayV2();
+                    StatSimTradeAmount();
                     StatBusinessService.Instance.StatTradeAmountEverDayV2();
                     StatBusinessService.Instance.StatTradeAmountEverDayV2();
                     StatHelpProfitService.Instance.StatTradeAmountEverDayV2();
                     StatHelpProfitService.Instance.StatTradeAmountEverDayV2();
                 }
                 }
@@ -118,7 +119,7 @@ namespace MySystem
                     {
                     {
                         startId = "867041";
                         startId = "867041";
                     }
                     }
-                    string sql = "select Id from TradeRecord where Id>=" + startId + " and QueryCount=0 and ActStatus=1 and BrandId=14 order by Id limit 50";
+                    string sql = "select Id from TradeRecord where Id>=" + startId + " and QueryCount=0 and ActStatus=1 and BrandId!=14 order by Id limit 50";
                     if(Id > 0)
                     if(Id > 0)
                     {
                     {
                         sql = "select Id from TradeRecord where Id=" + Id;
                         sql = "select Id from TradeRecord where Id=" + Id;
@@ -335,6 +336,134 @@ namespace MySystem
         }
         }
 
 
 
 
+        public void StatSimTradeAmount(int Id = 0)
+        {
+            OtherMySqlConn.connstr = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), "实时执行广电卡交易额日志");
+            WebCMSEntities db = new WebCMSEntities();
+            using (var tran = db.Database.BeginTransaction())
+            {
+                try
+                {
+                    string startId = function.ReadInstance("/TradeRecord/SimId.txt");
+                    if(string.IsNullOrEmpty(startId))
+                    {
+                        startId = "10000000";
+                    }
+                    string sql = "select Id from TradeRecord where Id>=" + startId + " and QueryCount=0 and ActStatus=1 and BrandId=14 order by Id limit 50";
+                    if(Id > 0)
+                    {
+                        sql = "select Id from TradeRecord where Id=" + Id;
+                    }
+                    DataTable idsDt = OtherMySqlConn.dtable(sql);
+                    if(idsDt.Rows.Count > 0)
+                    {
+                        string ids = "";
+                        foreach (DataRow idsDr in idsDt.Rows)
+                        {
+                            ids += idsDr["Id"].ToString() + ",";
+                            if(Id == 0)
+                            {
+                                startId = idsDr["Id"].ToString();
+                            }
+                        }
+                        DataTable selfDt = OtherMySqlConn.dtable("select UserId,ParentNav,MerHelpFlag,SnNo,DATE_FORMAT(CreateDate,'%Y%m%d'),sum(TradeAmount) from TradeRecord where Id in (" + ids.TrimEnd(',') + ") group by UserId,ParentNav,MerHelpFlag,SnNo,DATE_FORMAT(CreateDate,'%Y%m%d')");
+                        if (selfDt.Rows.Count > 0)
+                        {
+                            function.WriteLog("统计人数:" + selfDt.Rows.Count + "\n\n", "实时执行广电卡交易额日志");
+                            foreach (DataRow selfDr in selfDt.Rows)
+                            {
+                                int UserId = int.Parse(selfDr["UserId"].ToString());
+                                string SnNo = selfDr["SnNo"].ToString();
+                                if(UserId == 0)
+                                {
+                                    PosMachinesTwo pos = db.PosMachinesTwo.FirstOrDefault(m => m.PosSn == SnNo);
+                                    if(pos != null)
+                                    {
+                                        UserId = pos.UserId;
+                                    }
+                                }
+                                Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                                string ParentNav = user.ParentNav;
+                                int MerHelpFlag = int.Parse(selfDr["MerHelpFlag"].ToString());
+                                string TradeDate = selfDr[4].ToString();
+                                decimal TradeAmount = decimal.Parse(selfDr[5].ToString());
+                                string TradeMonth = TradeDate.Substring(0, 6);
+
+                                SimCardDaySummary selfStat = db.SimCardDaySummary.FirstOrDefault(m => m.UserId == UserId && m.TradeMonth == TradeMonth && m.TradeDay == TradeDate && m.SeoTitle == "self");
+                                if (selfStat == null)
+                                {
+                                    selfStat = db.SimCardDaySummary.Add(new SimCardDaySummary()
+                                    {
+                                        UserId = UserId,
+                                        TradeMonth = TradeMonth,
+                                        TradeDay = TradeDate,
+                                        SeoTitle = "self",
+                                    }).Entity;
+                                    db.SaveChanges();
+                                }
+                                selfStat.TradeAmount += TradeAmount;
+                                if (MerHelpFlag == 1)
+                                {
+                                    selfStat.HelpTradeAmount += TradeAmount;
+                                }
+                                else
+                                {
+                                    selfStat.NotHelpTradeAmount += TradeAmount;
+                                }
+                                
+                                ParentNav += "," + UserId + ",";
+                                if (!string.IsNullOrEmpty(ParentNav))
+                                {
+                                    string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                                    foreach (string NavUserIdString in ParentNavList)
+                                    {
+                                        int NavUserId = int.Parse(NavUserIdString);
+                                        SimCardDaySummary teamStat = db.SimCardDaySummary.FirstOrDefault(m => m.UserId == NavUserId && m.TradeMonth == TradeMonth && m.TradeDay == TradeDate && m.SeoTitle == "team");
+                                        if (teamStat == null)
+                                        {
+                                            teamStat = db.SimCardDaySummary.Add(new SimCardDaySummary()
+                                            {
+                                                UserId = NavUserId,
+                                                TradeMonth = TradeMonth,
+                                                TradeDay = TradeDate,
+                                                SeoTitle = "team",
+                                            }).Entity;
+                                            db.SaveChanges();
+                                        }
+                                        teamStat.TradeAmount += TradeAmount;
+                                        if (MerHelpFlag == 1)
+                                        {
+                                            teamStat.HelpTradeAmount += TradeAmount;
+                                        }
+                                        else
+                                        {
+                                            teamStat.NotHelpTradeAmount += TradeAmount;
+                                        }
+                                    }
+                                }
+                            }
+                            OtherMySqlConn.op("update TradeRecord set QueryCount=1 where Id in (" + ids.TrimEnd(',') + ")");
+                            if(Id == 0)
+                            {
+                                function.WritePage("/TradeRecord/", "SimId.txt", startId);
+                            }
+                        }
+                        db.SaveChanges();
+                    }
+                    tran.Commit();
+                }
+                catch (Exception ex)
+                {
+                    tran.Rollback();
+                    function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "实时执行广电卡交易额异常");
+                }
+            }
+            db.Dispose();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时执行广电卡交易额日志");
+        }
+
+
         // 每天统计头一天的交易额
         // 每天统计头一天的交易额
         public void StartEverDay(string date)
         public void StartEverDay(string date)
         {
         {

+ 24 - 0
PxcModels/CustomQuery.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class CustomQuery
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public string AdminNames { get; set; }
+        public string Title { get; set; }
+        public string SqlContent { get; set; }
+    }
+}

+ 2 - 0
PxcModels/LeaderAccountRecord.cs

@@ -29,5 +29,7 @@ namespace MySystem.PxcModels
         public string CreateMan { get; set; }
         public string CreateMan { get; set; }
         public string UpdateMan { get; set; }
         public string UpdateMan { get; set; }
         public int Version { get; set; }
         public int Version { get; set; }
+        public decimal LeaderReserve { get; set; }
+        public int LeaderId { get; set; }
     }
     }
 }
 }

+ 4 - 0
PxcModels/PosMachinesTwo.cs

@@ -60,5 +60,9 @@ namespace MySystem.PxcModels
         public string SourcePosSn { get; set; }
         public string SourcePosSn { get; set; }
         public int RecycStatus { get; set; }
         public int RecycStatus { get; set; }
         public string OutBatchNo { get; set; }
         public string OutBatchNo { get; set; }
+        public int WithholdFlag { get; set; }
+        public int IsSupplement { get; set; }
+        public int IsOpAct { get; set; }
+        public int LastMerchantId { get; set; }
     }
     }
 }
 }

+ 2 - 0
PxcModels/PosMerchantInfoBak.cs

@@ -43,5 +43,7 @@ namespace MySystem.PxcModels
         public string MerchantMobile { get; set; }
         public string MerchantMobile { get; set; }
         public string MerchantName { get; set; }
         public string MerchantName { get; set; }
         public string MerchantNo { get; set; }
         public string MerchantNo { get; set; }
+        public int StandardMonths { get; set; }
+        public int StandardStatus { get; set; }
     }
     }
 }
 }

+ 1 - 0
PxcModels/PreSendStockDetail.cs

@@ -29,5 +29,6 @@ namespace MySystem.PxcModels
         public int BrandId { get; set; }
         public int BrandId { get; set; }
         public int StoreId { get; set; }
         public int StoreId { get; set; }
         public ulong AuthFlag { get; set; }
         public ulong AuthFlag { get; set; }
+        public int WithholdFlag { get; set; }
     }
     }
 }
 }

+ 27 - 0
PxcModels/SimCardDaySummary.cs

@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class SimCardDaySummary
+    {
+        public int Id { get; set; }
+        public int Sort { get; set; }
+        public int QueryCount { get; set; }
+        public int Status { get; set; }
+        public int Version { get; set; }
+        public DateTime? CreateDate { get; set; }
+        public DateTime? UpdateDate { get; set; }
+        public string CreateMan { get; set; }
+        public string UpdateMan { get; set; }
+        public string SeoTitle { get; set; }
+        public string SeoKeyword { get; set; }
+        public string SeoDescription { get; set; }
+        public decimal NotHelpTradeAmount { get; set; }
+        public decimal HelpTradeAmount { get; set; }
+        public decimal TradeAmount { get; set; }
+        public string TradeMonth { get; set; }
+        public string TradeDay { get; set; }
+        public int UserId { get; set; }
+    }
+}

+ 12 - 0
PxcModels/TableSplit.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class TableSplit
+    {
+        public string TableName { get; set; }
+        public int EndId { get; set; }
+        public int StartId { get; set; }
+    }
+}

+ 14 - 0
PxcModels/TmpLeaders.cs

@@ -0,0 +1,14 @@
+using System;
+using System.Collections.Generic;
+
+namespace MySystem.PxcModels
+{
+    public partial class TmpLeaders
+    {
+        public string MakerCode { get; set; }
+        public string RealName { get; set; }
+        public string LevelString { get; set; }
+        public DateTime? BuyDate { get; set; }
+        public int UserId { get; set; }
+    }
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 254 - 146
PxcModels/WebCMSEntities.cs


Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels