Browse Source

增加分表队列
增加数据入库队列

lcl 2 years ago
parent
commit
3d1ab29a75

+ 205 - 0
AppStart/Helper/SplitTableData/AddRecordService.cs

@@ -0,0 +1,205 @@
+using System;
+using System.Collections.Generic;
+using Library;
+using LitJson;
+using System.Linq;
+using System.Data;
+using System.Threading;
+using MySystem.PxcModels;
+
+namespace MySystem
+{
+    public class AddRecordService
+    {
+        public readonly static AddRecordService Instance = new AddRecordService();
+        private AddRecordService()
+        { }
+
+        //分表字段集合
+        private Dictionary<string, string> FieldDic = new Dictionary<string, string>()
+        {
+            {"TradeRecord", "Id,Sort,QueryCount,Status,Version,CreateDate,UpdateDate,CreateMan,UpdateMan,SeoTitle,SeoKeyword,SeoDescription,MerUserId,TopUserId,Remark,BrandId,DirectFlag,CapFlag,QrPayFlag,BankCardType,TradeAmount,TradeSerialNo,ClearDate,TradeDate,SnNo,MerBuddyType,HelpMonthCount,MerHelpFlag,MerNo,MerchantId,UserId,RecordNo,ParentNav,PayType,VipFlag,ActStatus"},
+            {"UserAccountRecord", "Id,Sort,QueryCount,Status,Version,CreateDate,UpdateDate,CreateMan,UpdateMan,SeoTitle,SeoKeyword,SeoDescription,TransRecordNo,Remark,AfterBalanceAmount,BeforeBalanceAmount,AfterFreezeAmount,BeforeFreezeAmount,AfterTotalAmount,BeforeTotalAmount,ChangeAmount,ProductType,ChangeType,UserId,Kind"},
+            {"SpBindRecord", "Id,Sort,QueryCount,Status,CreateDate,UpdateDate,SeoTitle,SeoKeyword,SeoDescription,ChannelSerial,UpdateTime,CreateTime,Remark,MerNewSnNo,ProductType,MerStatus,MerOperateType,MerOperateDate,MerSnNo,MerName,AgentName,MerNo,Field5,Field4,Field3,Field2,Field1"},
+            {"SpMerchants", "Id,Sort,QueryCount,Status,CreateDate,UpdateDate,SeoTitle,SeoKeyword,SeoDescription,AgentNo,SnNo,UpdateTime,CreateTime,Remark,City,Province,ProductType,MerStatus,MerAuditDate,MerRegDate,MerIdcardNo,MerMobile,MerRealName,AgentName,MerName,MerNo,Field5,Field4,Field3,Field2,Field1"},
+            {"SpActivateRecord", "Id,Sort,QueryCount,Status,CreateDate,UpdateDate,SeoTitle,SeoKeyword,SeoDescription,ProductType,AgentNo,Remark,BizEnterName,BizEnterNo,MerIdcardNo,MerRealName,ActivateDate,ActivateStatus,AssessMonthCount,AssessMonth,MerRegDate,SnNo,MerMobile,MerName,MerNo,ChannelSerial,Field5,Field4,Field3,Field2,Field1"},
+            {"SpTradeRecord", "Id,Sort,QueryCount,Status,CreateDate,UpdateDate,SeoTitle,SeoKeyword,SeoDescription,ChannelSerial,AgentNo,ProductType,Remark,SettleMethod,SettleFee,BankCardNo,ReceiptType,IsStoreCashier,DigAmt,DigAmtFlag,MerMobile,DeviceType,TradeSnNo,BankCardType,SerEntryMode,TradeType,TradeTime,TradeDate,ErrorMsg,ErrorCode,TradeStatus,DiscountRateFlag,BankAuthCode,TradeReferNo,TradeAmount,MerName,MerNo,TradeSerialNo,Field5,Field4,Field3,Field2,Field1"},
+        };
+
+        //交易记录队列
+        public void StartTradeRecord()
+        {
+            Thread th = new Thread(StartTradeRecordDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartTradeRecordDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddTradeRecordQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "TradeRecord");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        //收支明细队列
+        public void StartUserAccountRecord()
+        {
+            Thread th = new Thread(StartUserAccountRecordDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartUserAccountRecordDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddUserAccountRecordQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "UserAccountRecord");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        //SP绑定记录队列
+        public void StartSpBindRecord()
+        {
+            Thread th = new Thread(StartSpBindRecordDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartSpBindRecordDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddSpBindRecordQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "SpBindRecord");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        //SP商户信息队列
+        public void StartSpMerchants()
+        {
+            Thread th = new Thread(StartSpMerchantsDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartSpMerchantsDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddSpMerchantsQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "SpMerchants");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        //SP激活押金队列
+        public void StartSpActivateRecord()
+        {
+            Thread th = new Thread(StartSpActivateRecordDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartSpActivateRecordDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddSpActivateRecordQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "SpActivateRecord");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+        //SP交易记录队列
+        public void StartSpTradeRecord()
+        {
+            Thread th = new Thread(StartSpTradeRecordDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartSpTradeRecordDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("AddSpTradeRecordQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    string[] datalist = content.Split(new string[] { "#cut#" }, StringSplitOptions.None);
+                    AddData(datalist[0], datalist[1], "SpTradeRecord");
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+
+
+        //添加表数据
+        public void AddData(string content, string date, string table)
+        {
+            try
+            {
+                JsonData selfDr = JsonMapper.ToObject(content);
+                string fields = FieldDic[table];
+                string val = "";
+                foreach(string field in fields.Split(','))
+                {
+                    Type t = selfDr[field].GetType();
+                    if(t == typeof(int) || t == typeof(decimal))
+                    {
+                        val += selfDr[field].ToString() + ",";
+                    }
+                    else
+                    {
+                        val += "'" + selfDr[field].ToString() + "',";
+                    }
+                }
+                string sql = "INSERT INTO " + table + date + " (" + fields + ") VALUES (" + val.TrimEnd(',') + ")";
+                CustomerSqlConn.op(sql, AppConfig.Base.StatSqlConn);
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "添加记录RDS异常");
+            }
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "添加记录RDS");
+        }
+
+    }
+}

+ 182 - 7
AppStart/Helper/StatNewService.cs → AppStart/Helper/SplitTableData/StatNewService.cs

@@ -28,25 +28,51 @@ namespace MySystem
             while (true)
             {
                 string TradeDate = DateTime.Now.AddDays(1).ToString("yyyyMMdd");
-                CreateTableOp(TradeDate, 1);
                 string TradeMonth = DateTime.Now.AddMonths(1).ToString("yyyyMM");
-                CreateTableOp(TradeMonth, 2);
+
+                CreateTableOp(TradeDate, 1, "TradeDaySummary");
+                CreateTableOp(TradeDate, 1, "PosMerchantTradeSummay");
+                CreateTableOp(TradeDate, 1, "UserTradeMonthSummary");
+
+                if(DateTime.Now.Day > 25)
+                {
+                    CreateTableOp(TradeMonth, 2, "TradeDaySummary");
+                    CreateTableOp(TradeMonth, 2, "PosMerchantTradeSummay");
+                    CreateTableOp(TradeMonth, 2, "UserTradeMonthSummary");
+                    CreateTableOp(TradeMonth, 2, "TradeRecord");
+                    CreateTableOp(TradeMonth, 2, "UserAccountRecord");
+                    CreateTableOp(TradeMonth, 2, "SpBindRecord");
+                    CreateTableOp(TradeMonth, 2, "SpMerchants");
+                    CreateTableOp(TradeMonth, 2, "SpActivateRecord");
+                    CreateTableOp(TradeMonth, 2, "SpTradeRecord");
+                }
+
                 int timespan = 1000 * 60 * 60;
                 Thread.Sleep(timespan);
             }
         }
-        private void CreateTableOp(string TradeDate, int Kind = 1)
+        private void CreateTableOp(string TradeDate, int Kind, string TableName)
         {
-            if(string.IsNullOrEmpty(RedisDbconn.Instance.Get<string>("TradeDaySummary" + TradeDate)))
+            if(string.IsNullOrEmpty(RedisDbconn.Instance.Get<string>(TableName + TradeDate)))
             {
-                CustomerSqlConn.op(AppConfig.Base.CreateTradeDaySummary.Replace("#DateTime#", TradeDate), AppConfig.Base.StatSqlConn);
-                RedisDbconn.Instance.Set("TradeDaySummary" + TradeDate, "1");
+                string sql = "";
+                if(TableName == "TradeDaySummary") sql = AppConfig.Base.CreateTradeDaySummary.Replace("#DateTime#", TradeDate);
+                if(TableName == "TradeRecord") sql = AppConfig.Base.CreateTradeRecord.Replace("#DateTime#", TradeDate);
+                if(TableName == "PosMerchantTradeSummay") sql = AppConfig.Base.CreatePosMerchantTradeSummay.Replace("#DateTime#", TradeDate);
+                if(TableName == "UserAccountRecord") sql = AppConfig.Base.CreateUserAccountRecord.Replace("#DateTime#", TradeDate);
+                if(TableName == "UserTradeMonthSummary") sql = AppConfig.Base.CreateUserTradeMonthSummary.Replace("#DateTime#", TradeDate);
+                if(TableName == "SpBindRecord") sql = AppConfig.Base.CreateSpBindRecord.Replace("#DateTime#", TradeDate);
+                if(TableName == "SpMerchants") sql = AppConfig.Base.CreateSpMerchants.Replace("#DateTime#", TradeDate);
+                if(TableName == "SpActivateRecord") sql = AppConfig.Base.CreateSpActivateRecord.Replace("#DateTime#", TradeDate);
+                if(TableName == "SpTradeRecord") sql = AppConfig.Base.CreateSpTradeRecord.Replace("#DateTime#", TradeDate);
+                CustomerSqlConn.op(sql, AppConfig.Base.StatSqlConn);
+                RedisDbconn.Instance.Set(TableName + TradeDate, "1");
                 int sec = 3600 * 25;
                 if(Kind == 2)
                 {
                     sec = 3600 * 24 * 35;
                 }
-                RedisDbconn.Instance.SetExpire("TradeDaySummary" + TradeDate, sec);
+                RedisDbconn.Instance.SetExpire(TableName + TradeDate, sec);
             }
         }
 
@@ -255,5 +281,154 @@ namespace MySystem
             function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时统计交易额日志RDS");
         }
 
+
+
+
+        // 统计商户交易额到RDS
+        public void StartMer()
+        {
+            Thread th = new Thread(StartMerDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartMerDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("StatMerTradeAmountQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    StatMerTradeAmount(content, 1);
+                    StatMerTradeAmount(content, 2);
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+        public void StatMerTradeAmount(string content, int Kind)
+        {
+            JsonData selfDr = JsonMapper.ToObject(content);
+            string TradeDate = selfDr["TradeDate"].ToString();
+            decimal TradeAmount = decimal.Parse(selfDr["TradeAmount"].ToString());
+            int MerchantId = int.Parse(selfDr["MerchantId"].ToString());
+            int BrandId = int.Parse(selfDr["BrandId"].ToString());
+            if(Kind == 2)
+            {
+                TradeDate = TradeDate.Substring(0, 6);
+            }
+            string Id = "0";
+            DataTable check = CustomerSqlConn.dtable("select Id from PosMerchantTradeSummay" + TradeDate + " where MerchantId=" + MerchantId + " and BrandId=" + BrandId + "", AppConfig.Base.StatSqlConn);
+            if(check.Rows.Count < 1)
+            {
+                check = CustomerSqlConn.dtable("insert into PosMerchantTradeSummay" + TradeDate + " (MerchantId,BrandId) values (" + MerchantId + "," + BrandId + ");select @@IDENTITY", AppConfig.Base.StatSqlConn);
+                if(check.Rows.Count > 0)
+                {
+                    Id = check.Rows[0][0].ToString();
+                }
+            }
+            else
+            {
+                Id = check.Rows[0][0].ToString();
+            }
+            CustomerSqlConn.op("update PosMerchantTradeSummay" + TradeDate + " set TradeAmount=TradeAmount+" + TradeAmount + " where Id=" + Id, AppConfig.Base.StatSqlConn);
+        }
+
+
+
+
+        // 统计激活数到RDS
+        public void StartAct()
+        {
+            Thread th = new Thread(StartActDo);
+            th.IsBackground = true;
+            th.Start();
+        }
+        public void StartActDo()
+        {
+            while (true)
+            {
+                string content = RedisDbconn.Instance.RPop<string>("StatActQueue");
+                if(!string.IsNullOrEmpty(content))
+                {
+                    StatAct(content, 1);
+                    StatAct(content, 2);
+                }
+                else
+                {
+                    Thread.Sleep(10000);
+                }
+            }
+        }
+        public void StatAct(string content, int Kind)
+        {
+            WebCMSEntities db = new WebCMSEntities();
+            try
+            {
+                JsonData selfDr = JsonMapper.ToObject(content);
+                int UserId = int.Parse(selfDr["UserId"].ToString());
+                Users user = db.Users.FirstOrDefault(m => m.Id == UserId) ?? new Users();
+                string ParentNav = user.ParentNav;
+                int BrandId = int.Parse(selfDr["BrandId"].ToString());
+                string TradeDate = selfDr["TradeDate"].ToString();
+                decimal TradeAmount = decimal.Parse(selfDr["TradeAmount"].ToString());
+                int TradeCount = int.Parse(selfDr["TradeCount"].ToString());
+                if(Kind == 2)
+                {
+                    TradeDate = TradeDate.Substring(0, 6);
+                }
+
+                string Id = "0";
+                DataTable check = CustomerSqlConn.dtable("select Id from UserTradeMonthSummary" + TradeDate + " where UserId=" + UserId + " and BrandId=" + BrandId + " and SeoTitle='self'", AppConfig.Base.StatSqlConn);
+                if(check.Rows.Count < 1)
+                {
+                    check = CustomerSqlConn.dtable("insert into UserTradeMonthSummary" + TradeDate + " (UserId,BrandId,SeoTitle) values (" + UserId + "," + BrandId + ",'self');select @@IDENTITY", AppConfig.Base.StatSqlConn);
+                    if(check.Rows.Count > 0)
+                    {
+                        Id = check.Rows[0][0].ToString();
+                    }
+                }
+                else
+                {
+                    Id = check.Rows[0][0].ToString();
+                }
+                CustomerSqlConn.op("update UserTradeMonthSummary" + TradeDate + " set ActiveBuddyMerStatus=ActiveBuddyMerStatus+1 where Id=" + Id, AppConfig.Base.StatSqlConn);
+                ParentNav += "," + UserId + ",";
+                if (!string.IsNullOrEmpty(ParentNav))
+                {
+                    string[] ParentNavList = ParentNav.Trim(',').Replace(",,", ",").Split(',');
+                    foreach (string NavUserIdString in ParentNavList)
+                    {
+                        int NavUserId = int.Parse(NavUserIdString);
+
+                        string PId = "0";
+                        DataTable pcheck = CustomerSqlConn.dtable("select Id from UserTradeMonthSummary" + TradeDate + " where UserId=" + NavUserId + " and BrandId=" + BrandId + " and SeoTitle='team'", AppConfig.Base.StatSqlConn);
+                        if(pcheck.Rows.Count < 1)
+                        {
+                            pcheck = CustomerSqlConn.dtable("insert into UserTradeMonthSummary" + TradeDate + " (UserId,BrandId,SeoTitle) values (" + NavUserId + "," + BrandId + ",'team');select @@IDENTITY", AppConfig.Base.StatSqlConn);
+                            if(pcheck.Rows.Count > 0)
+                            {
+                                PId = pcheck.Rows[0][0].ToString();
+                            }
+                        }
+                        else
+                        {
+                            PId = pcheck.Rows[0][0].ToString();
+                        }
+
+                        CustomerSqlConn.op("update UserTradeMonthSummary" + TradeDate + " set ActiveBuddyMerStatus=ActiveBuddyMerStatus+1 where Id=" + PId, AppConfig.Base.StatSqlConn);
+                    }
+                }
+                db.SaveChanges();
+            }
+            catch (Exception ex)
+            {
+                function.WriteLog(DateTime.Now.ToString() + "\n" + ex.ToString(), "实时统计交易额日志RDS异常");
+            }
+            db.Dispose();
+            function.WriteLog(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff") + "\n\n", "实时统计交易额日志RDS");
+        }
+
     }
 }

+ 280 - 0
Config/Base.cs

@@ -8,6 +8,7 @@ namespace AppConfig
         public static string SqlConn = Library.ConfigurationManager.AppSettings["SqlConnStr"].ToString();
         public static string StatSqlConn = Library.ConfigurationManager.AppSettings["StatSqlConnStr"].ToString();
 
+        //交易统计表
         public static string CreateTradeDaySummary = "SET NAMES utf8mb4;" +
                                                     "SET FOREIGN_KEY_CHECKS = 0;" +
                                                     "CREATE TABLE `TradeDaySummary#DateTime#` (" +
@@ -90,5 +91,284 @@ namespace AppConfig
                                                     "KEY `TradeDaySummaryIndex` (`UserId`,`BrandId`,`QueryCount`,`VipFlag`,`PayType`,`SeoTitle`)" +
                                                     ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;" +
                                                     "SET FOREIGN_KEY_CHECKS = 1;";
+
+        //交易记录表
+        public static string CreateTradeRecord = "CREATE TABLE `TradeRecord#DateTime#` (" +
+                                                "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                "`Version` int(11) NOT NULL DEFAULT '0'," +
+                                                "`CreateDate` datetime DEFAULT NULL," +
+                                                "`UpdateDate` datetime DEFAULT NULL," +
+                                                "`CreateMan` varchar(50) DEFAULT NULL," +
+                                                "`UpdateMan` varchar(50) DEFAULT NULL," +
+                                                "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                "`SeoDescription` varchar(500) DEFAULT NULL," +
+                                                "`MerUserId` int(11) NOT NULL DEFAULT '0'," +
+                                                "`TopUserId` int(11) NOT NULL DEFAULT '0'," +
+                                                "`Remark` varchar(64) DEFAULT NULL," +
+                                                "`BrandId` int(11) NOT NULL DEFAULT '0'," +
+                                                "`DirectFlag` bit(1) NOT NULL DEFAULT b'0'," +
+                                                "`CapFlag` int(11) NOT NULL DEFAULT '0'," +
+                                                "`QrPayFlag` int(11) NOT NULL DEFAULT '0'," +
+                                                "`BankCardType` int(11) NOT NULL DEFAULT '0'," +
+                                                "`TradeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                "`TradeSerialNo` varchar(48) DEFAULT NULL," +
+                                                "`ClearDate` datetime DEFAULT NULL," +
+                                                "`TradeDate` datetime DEFAULT NULL," +
+                                                "`SnNo` varchar(32) DEFAULT NULL," +
+                                                "`MerBuddyType` int(11) NOT NULL DEFAULT '0'," +
+                                                "`HelpMonthCount` int(11) NOT NULL DEFAULT '0'," +
+                                                "`MerHelpFlag` bit(1) NOT NULL DEFAULT b'0'," +
+                                                "`MerNo` varchar(32) DEFAULT NULL," +
+                                                "`MerchantId` int(11) NOT NULL DEFAULT '0'," +
+                                                "`UserId` int(11) NOT NULL DEFAULT '0'," +
+                                                "`RecordNo` varchar(50) DEFAULT NULL," +
+                                                "`ParentNav` mediumtext," +
+                                                "`PayType` int(11) NOT NULL DEFAULT '0'," +
+                                                "`VipFlag` int(11) NOT NULL DEFAULT '0'," +
+                                                "`ActStatus` int(11) NOT NULL DEFAULT '0'," +
+                                                "PRIMARY KEY (`Id`)," +
+                                                "KEY `TradeRecordIndex` (`BrandId`,`UserId`,`MerchantId`,`MerNo`,`SnNo`,`CreateDate`)" +
+                                                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //商户交易额统计
+        public static string CreatePosMerchantTradeSummay = "CREATE TABLE `PosMerchantTradeSummay#DateTime#` (" +
+                                                            "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                            "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`CreateDate` datetime DEFAULT NULL," +
+                                                            "`UpdateDate` datetime DEFAULT NULL," +
+                                                            "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                            "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                            "`SeoDescription` varchar(500) DEFAULT NULL," +
+                                                            "`BrandId` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`TradeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                            "`TradeDate` varchar(8) DEFAULT NULL," +
+                                                            "`TradeMonth` varchar(6) DEFAULT NULL," +
+                                                            "`MerchantId` int(11) NOT NULL DEFAULT '0'," +
+                                                            "PRIMARY KEY (`Id`)," +
+                                                            "KEY `PosMerchantTradeSummayIndex` (`MerchantId`,`BrandId`)" +
+                                                            ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //收支明细
+        public static string CreateUserAccountRecord = "CREATE TABLE `UserAccountRecord#DateTime#` (" +
+                                                        "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                        "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`Version` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`CreateDate` datetime DEFAULT NULL," +
+                                                        "`UpdateDate` datetime DEFAULT NULL," +
+                                                        "`CreateMan` varchar(50) DEFAULT NULL," +
+                                                        "`UpdateMan` varchar(50) DEFAULT NULL," +
+                                                        "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                        "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                        "`SeoDescription` varchar(500) DEFAULT NULL," +
+                                                        "`TransRecordNo` varchar(32) DEFAULT NULL," +
+                                                        "`Remark` varchar(64) DEFAULT NULL," +
+                                                        "`AfterBalanceAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`BeforeBalanceAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`AfterFreezeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`BeforeFreezeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`AfterTotalAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`BeforeTotalAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`ChangeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                        "`ProductType` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`ChangeType` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`UserId` int(11) NOT NULL DEFAULT '0'," +
+                                                        "`Kind` int(11) NOT NULL DEFAULT '0'," +
+                                                        "PRIMARY KEY (`Id`)," +
+                                                        "KEY `UserAccountRecordIndex` (`UserId`,`ChangeType`,`CreateDate`)" +
+                                                        ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //激活量统计
+        public static string CreateUserTradeMonthSummary = "CREATE TABLE `UserTradeMonthSummary#DateTime#` (" +
+                                                            "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                            "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`Version` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`CreateDate` datetime DEFAULT NULL," +
+                                                            "`UpdateDate` datetime DEFAULT NULL," +
+                                                            "`CreateMan` varchar(50) DEFAULT NULL," +
+                                                            "`UpdateMan` varchar(50) DEFAULT NULL," +
+                                                            "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                            "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                            "`SeoDescription` varchar(500) DEFAULT NULL," +
+                                                            "`Remark` varchar(64) DEFAULT NULL," +
+                                                            "`ActiveBuddyMerStatus` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`MallPosOrderStatus` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`DebitCapTradeNum` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`DebitCapTradeAmt` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                            "`DebitNotCapTradeAmt` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                            "`CreditTradeAmt` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                            "`TradeAmt` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                            "`StatType` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`BrandId` int(11) NOT NULL DEFAULT '0'," +
+                                                            "`TradeMonth` varchar(6) DEFAULT NULL," +
+                                                            "`UserId` int(11) NOT NULL DEFAULT '0'," +
+                                                            "PRIMARY KEY (`Id`)," +
+                                                            "KEY `UserTradeMonthSummaryIndex` (`UserId`,`BrandId`,`SeoTitle`)" +
+                                                            ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //SP绑定记录表
+        public static string CreateSpBindRecord = "CREATE TABLE `BindRecord#DateTime#` (" +
+                                                "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                "`CreateDate` datetime DEFAULT NULL," +
+                                                "`UpdateDate` datetime DEFAULT NULL," +
+                                                "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                "`SeoDescription` mediumtext," +
+                                                "`ChannelSerial` varchar(50) DEFAULT NULL," +
+                                                "`UpdateTime` datetime DEFAULT NULL," +
+                                                "`CreateTime` datetime DEFAULT NULL," +
+                                                "`Remark` varchar(64) DEFAULT NULL," +
+                                                "`MerNewSnNo` varchar(32) DEFAULT NULL," +
+                                                "`ProductType` varchar(32) DEFAULT NULL," +
+                                                "`MerStatus` varchar(16) DEFAULT NULL," +
+                                                "`MerOperateType` varchar(16) DEFAULT NULL," +
+                                                "`MerOperateDate` datetime DEFAULT NULL," +
+                                                "`MerSnNo` varchar(32) DEFAULT NULL," +
+                                                "`MerName` varchar(32) DEFAULT NULL," +
+                                                "`AgentName` varchar(64) DEFAULT NULL," +
+                                                "`MerNo` varchar(32) DEFAULT NULL," +
+                                                "`Field5` varchar(50) DEFAULT NULL," +
+                                                "`Field4` varchar(50) DEFAULT NULL," +
+                                                "`Field3` varchar(50) DEFAULT NULL," +
+                                                "`Field2` varchar(50) DEFAULT NULL," +
+                                                "`Field1` varchar(50) DEFAULT NULL," +
+                                                "PRIMARY KEY (`Id`)," +
+                                                "KEY `BindRecordIndex` (`MerSnNo`,`MerNo`,`CreateTime`)" +
+                                                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //SP商户信息
+        public static string CreateSpMerchants = "CREATE TABLE `Merchants#DateTime#` (" +
+                                                "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                "`CreateDate` datetime DEFAULT NULL," +
+                                                "`UpdateDate` datetime DEFAULT NULL," +
+                                                "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                "`SeoDescription` varchar(500) DEFAULT NULL," +
+                                                "`AgentNo` varchar(32) DEFAULT NULL," +
+                                                "`SnNo` varchar(32) DEFAULT NULL," +
+                                                "`UpdateTime` datetime DEFAULT NULL," +
+                                                "`CreateTime` datetime DEFAULT NULL," +
+                                                "`Remark` varchar(64) DEFAULT NULL," +
+                                                "`City` varchar(32) DEFAULT NULL," +
+                                                "`Province` varchar(32) DEFAULT NULL," +
+                                                "`ProductType` varchar(32) DEFAULT NULL," +
+                                                "`MerStatus` varchar(16) DEFAULT NULL," +
+                                                "`MerAuditDate` datetime DEFAULT NULL," +
+                                                "`MerRegDate` datetime DEFAULT NULL," +
+                                                "`MerIdcardNo` varchar(18) DEFAULT NULL," +
+                                                "`MerMobile` varchar(11) DEFAULT NULL," +
+                                                "`MerRealName` varchar(16) DEFAULT NULL," +
+                                                "`AgentName` varchar(64) DEFAULT NULL," +
+                                                "`MerName` varchar(32) DEFAULT NULL," +
+                                                "`MerNo` varchar(32) DEFAULT NULL," +
+                                                "`Field5` varchar(50) DEFAULT NULL," +
+                                                "`Field4` varchar(50) DEFAULT NULL," +
+                                                "`Field3` varchar(50) DEFAULT NULL," +
+                                                "`Field2` varchar(50) DEFAULT NULL," +
+                                                "`Field1` varchar(50) DEFAULT NULL," +
+                                                "PRIMARY KEY (`Id`)," +
+                                                "KEY `MerchantsIndex` (`MerNo`,`SnNo`,`CreateDate`)" +
+                                                ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //SP押金记录
+        public static string CreateSpActivateRecord = "CREATE TABLE `ActivateRecord#DateTime#` (" +
+                                                     "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                     "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                     "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                     "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                     "`CreateDate` datetime DEFAULT NULL," +
+                                                     "`UpdateDate` datetime DEFAULT NULL," +
+                                                     "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                     "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                     "`SeoDescription` mediumtext," +
+                                                     "`ProductType` varchar(32) DEFAULT NULL," +
+                                                     "`AgentNo` varchar(32) DEFAULT NULL," +
+                                                     "`Remark` varchar(64) DEFAULT NULL," +
+                                                     "`BizEnterName` varchar(32) DEFAULT NULL," +
+                                                     "`BizEnterNo` varchar(16) DEFAULT NULL," +
+                                                     "`MerIdcardNo` varchar(18) DEFAULT NULL," +
+                                                     "`MerRealName` varchar(16) DEFAULT NULL," +
+                                                     "`ActivateDate` datetime DEFAULT NULL," +
+                                                     "`ActivateStatus` varchar(20) DEFAULT NULL," +
+                                                     "`AssessMonthCount` varchar(8) DEFAULT NULL," +
+                                                     "`AssessMonth` varchar(8) DEFAULT NULL," +
+                                                     "`MerRegDate` datetime DEFAULT NULL," +
+                                                     "`SnNo` varchar(32) DEFAULT NULL," +
+                                                     "`MerMobile` varchar(32) DEFAULT NULL," +
+                                                     "`MerName` varchar(32) DEFAULT NULL," +
+                                                     "`MerNo` varchar(32) DEFAULT NULL," +
+                                                     "`ChannelSerial` varchar(50) DEFAULT NULL," +
+                                                     "`Field5` varchar(50) DEFAULT NULL," +
+                                                     "`Field4` varchar(50) DEFAULT NULL," +
+                                                     "`Field3` varchar(50) DEFAULT NULL," +
+                                                     "`Field2` varchar(50) DEFAULT NULL," +
+                                                     "`Field1` varchar(50) DEFAULT NULL," +
+                                                     "PRIMARY KEY (`Id`)," +
+                                                    "KEY `TradeRecordIndex` (`SnNo`,`ProductType`,`MerNo`,`ActivateDate`)" +
+                                                     ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
+
+        //SP交易记录表
+        public static string CreateSpTradeRecord = "CREATE TABLE `TradeRecord` (" +
+                                                    "`Id` int(11) NOT NULL AUTO_INCREMENT," +
+                                                    "`Sort` int(11) NOT NULL DEFAULT '0'," +
+                                                    "`QueryCount` int(11) NOT NULL DEFAULT '0'," +
+                                                    "`Status` int(11) NOT NULL DEFAULT '0'," +
+                                                    "`CreateDate` datetime DEFAULT NULL," +
+                                                    "`UpdateDate` datetime DEFAULT NULL," +
+                                                    "`SeoTitle` varchar(100) DEFAULT NULL," +
+                                                    "`SeoKeyword` varchar(200) DEFAULT NULL," +
+                                                    "`SeoDescription` mediumtext," +
+                                                    "`ChannelSerial` varchar(50) DEFAULT NULL," +
+                                                    "`AgentNo` varchar(32) DEFAULT NULL," +
+                                                    "`ProductType` varchar(32) DEFAULT NULL," +
+                                                    "`Remark` varchar(64) DEFAULT NULL," +
+                                                    "`SettleMethod` varchar(16) DEFAULT NULL," +
+                                                    "`SettleFee` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                    "`BankCardNo` varchar(32) DEFAULT NULL," +
+                                                    "`ReceiptType` varchar(16) DEFAULT NULL," +
+                                                    "`IsStoreCashier` varchar(16) DEFAULT NULL," +
+                                                    "`DigAmt` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                    "`DigAmtFlag` varchar(4) DEFAULT NULL," +
+                                                    "`MerMobile` varchar(11) DEFAULT NULL," +
+                                                    "`DeviceType` varchar(16) DEFAULT NULL," +
+                                                    "`TradeSnNo` varchar(50) DEFAULT NULL," +
+                                                    "`BankCardType` varchar(16) DEFAULT NULL," +
+                                                    "`SerEntryMode` varchar(32) DEFAULT NULL," +
+                                                    "`TradeType` varchar(32) DEFAULT NULL," +
+                                                    "`TradeTime` varchar(8) DEFAULT NULL," +
+                                                    "`TradeDate` varchar(8) DEFAULT NULL," +
+                                                    "`ErrorMsg` varchar(32) DEFAULT NULL," +
+                                                    "`ErrorCode` varchar(16) DEFAULT NULL," +
+                                                    "`TradeStatus` varchar(16) DEFAULT NULL," +
+                                                    "`DiscountRateFlag` varchar(16) DEFAULT NULL," +
+                                                    "`BankAuthCode` varchar(32) DEFAULT NULL," +
+                                                    "`TradeReferNo` varchar(32) DEFAULT NULL," +
+                                                    "`TradeAmount` decimal(18,2) NOT NULL DEFAULT '0.00'," +
+                                                    "`MerName` varchar(50) DEFAULT NULL," +
+                                                    "`MerNo` varchar(50) DEFAULT NULL," +
+                                                    "`TradeSerialNo` varchar(100) DEFAULT NULL," +
+                                                    "`Field5` varchar(50) DEFAULT NULL," +
+                                                    "`Field4` varchar(50) DEFAULT NULL," +
+                                                    "`Field3` varchar(50) DEFAULT NULL," +
+                                                    "`Field2` varchar(50) DEFAULT NULL," +
+                                                    "`Field1` varchar(50) DEFAULT NULL," +
+                                                    "PRIMARY KEY (`Id`)," +
+                                                    "KEY `TradeRecordIndex` (`TradeSnNo`,`ProductType`,`MerNo`,`CreateDate`)" +
+                                                    ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;";
     }
 }