Browse Source

测试推送

lcl 1 year ago
parent
commit
a4c39e22a3
3 changed files with 125 additions and 51 deletions
  1. 0 1
      Config/Base.cs
  2. 123 0
      Controllers/HomeController.cs
  3. 2 50
      Startup.cs

+ 0 - 1
Config/Base.cs

@@ -6,7 +6,6 @@ namespace AppConfig
     public class Base
     {
         public static string ApiKey = "G6H7@J8%";
-        public static string BsSqlConnStr = ConfigurationManager.AppSettings["BsSqlConnStr"].ToString();
         public static string SqlConnStr = ConfigurationManager.AppSettings["SqlConnStr"].ToString();
         public static string Host = Library.ConfigurationManager.AppSettings["Host"].ToString();
         public static string SourceHost = Library.ConfigurationManager.AppSettings["SourceHost"].ToString();

+ 123 - 0
Controllers/HomeController.cs

@@ -23,5 +23,128 @@ namespace MySystem.Controllers
         {
             return View();
         }
+
+        public string test()
+        {
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/1", "bind_merchant");
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/8", "un_bind_merchant");
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/236", "change_bind_merchant");
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/4", "sim_charge");
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/3", "service_fee");
+            testReq("http://idc.pay-api.top/idc-push-api/third/1050056/1560192687980675072/2", "trade");
+            return "ok";
+        }
+
+        public string testReq(string requrl, string reqkind)
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            if(reqkind == "bind_merchant") obj = bind_merchant();
+            if(reqkind == "un_bind_merchant") obj = un_bind_merchant();
+            if(reqkind == "change_bind_merchant") obj = change_bind_merchant();
+            if(reqkind == "sim_charge") obj = sim_charge();
+            if(reqkind == "service_fee") obj = service_fee();
+            if(reqkind == "trade") obj = trade();
+            string content = EncryptHelper.Encrypt1(obj, "57yJ3T1Btz7LytyL");
+            obj = new SortedList<string, string>();
+            obj.Add("type", reqkind);
+            obj.Add("app_id", "KXS000001");
+            obj.Add("notice_id", Guid.NewGuid().ToString());
+            obj.Add("timestamp", DateTime.Now.ToString("yyyyMMddHHmmssfff") + function.get_Random(8));
+            obj.Add("content", content);
+            string requestJson = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
+            function.WriteLog("请求地址:" + requrl);
+            function.WriteLog("请求参数:" + requestJson);
+            string result = function.PostWebRequest(requrl, requestJson, "application/json");
+            function.WriteLog("返回:" + result);
+            function.WriteLog("\n\n\n");
+            return result;
+        }
+
+        private SortedList<string, string> bind_merchant()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("phone", "135****6666");
+            obj.Add("name", "张**");
+            obj.Add("supplement_info", "4307************48");
+            obj.Add("agent_id", "88880019");
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("pos_sn", "LKB1888888");
+            obj.Add("device_model", "N101");
+            obj.Add("term_to", "L4859999");
+            obj.Add("bind_time", "2019-03-12 22:21:50");
+            return obj;
+        }
+
+        private SortedList<string, string> un_bind_merchant()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("name", "张**");
+            obj.Add("supplement_info", "4307************48");
+            obj.Add("agent_id", "88880019");
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("pos_sn", "LKB1888888");
+            obj.Add("device_model", "N101");
+            obj.Add("bind_time", "2019-03-12 22:21:50");
+            return obj;
+        }
+
+        private SortedList<string, string> change_bind_merchant()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("name", "张**");
+            obj.Add("supplement_info", "4307************48");
+            obj.Add("agent_id", "88880019");
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("before_pos_sn", "LKB1888888");
+            obj.Add("after_pos_sn", "LKB1888888");
+            obj.Add("before_device_model", "N101");
+            obj.Add("after_device_model", "N102");
+            obj.Add("bind_time", "2019-03-12 22:21:50");
+            return obj;
+        }
+
+        private SortedList<string, string> sim_charge()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("agent_id", "88880019");
+            obj.Add("pos_sn", "LKB188FBMS78888");
+            obj.Add("amount", "9900");
+            obj.Add("order_id", "2004190320190312222130116680");
+            obj.Add("trans_time", "2019-03-12 22:23:02");
+            return obj;
+        }
+
+        private SortedList<string, string> service_fee()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("agent_id", "88880019");
+            obj.Add("pos_sn", "LD188FBMS78888");
+            obj.Add("order_id", "2024190320190312222130116666");
+            obj.Add("amount", "9900");
+            obj.Add("trans_time", "2024-03-12 22:23:02");
+            return obj;
+        }
+
+        private SortedList<string, string> trade()
+        {
+            SortedList<string, string> obj = new SortedList<string, string>();
+            obj.Add("agent_id", "88880019");
+            obj.Add("order_id", "2024010420191016203820115800");
+            obj.Add("trans_id", "2024010420191016203820115800");
+            obj.Add("merch_no", "LKB50009993529999");
+            obj.Add("term_no", "M4859999");
+            obj.Add("pos_sn", "LD188FBMS78888");
+            obj.Add("amount", "000000099910");
+            obj.Add("trans_time", "20190312222421");
+            obj.Add("ret_code", "00");
+            obj.Add("ret_msg", "交易成功");
+            obj.Add("fee_amount", "4499");
+            obj.Add("pay_type", "0");
+            obj.Add("card_type", "C");
+            obj.Add("trans_type", "31");
+            return obj;
+        }
     }
 }

+ 2 - 50
Startup.cs

@@ -100,56 +100,8 @@ namespace MySystem
                     pattern: "{controller=Home}/{action=Index}/{Id?}");
             });
 
-            initMainServer();
-            initBsServer();
-
-            StartHelper.Instance.Start(); //开启线程
-        }
-
-        //初始化数据结构
-        private void initMainServer()
-        {
-            Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
-            string connstr = Configuration["Setting:SqlConnStr"];
-            System.Data.DataTable tablecollection = Library.CustomerSqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'AdMainServer'", connstr);
-            foreach (System.Data.DataRow subtable in tablecollection.Rows)
-            {
-                Dictionary<string, string> Columns = new Dictionary<string, string>();
-                System.Data.DataTable columncollection = Library.CustomerSqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'AdMainServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'", connstr);
-                foreach (System.Data.DataRow column in columncollection.Rows)
-                {
-                    string datatype = column["DATA_TYPE"].ToString();
-                    if (datatype == "decimal")
-                    {
-                        datatype = "numeric";
-                    }
-                    Columns.Add(column["COLUMN_NAME"].ToString(), datatype);
-                }
-                tables.Add(subtable["TABLE_NAME"].ToString(), Columns);
-            }
-            AppConfig.Base.mainTables = tables;
-        }
-        private void initBsServer()
-        {
-            Dictionary<string, Dictionary<string, string>> tables = new Dictionary<string, Dictionary<string, string>>();
-            string connstr = Configuration["Setting:BsSqlConnStr"];
-            System.Data.DataTable tablecollection = Library.CustomerSqlConn.dtable("select DISTINCT TABLE_NAME from information_schema.columns where table_schema = 'AdConfigServer'", connstr);
-            foreach (System.Data.DataRow subtable in tablecollection.Rows)
-            {
-                Dictionary<string, string> Columns = new Dictionary<string, string>();
-                System.Data.DataTable columncollection = Library.CustomerSqlConn.dtable("select COLUMN_NAME,DATA_TYPE from information_schema.columns where table_schema = 'AdConfigServer' and TABLE_NAME='" + subtable["TABLE_NAME"].ToString() + "'", connstr);
-                foreach (System.Data.DataRow column in columncollection.Rows)
-                {
-                    string datatype = column["DATA_TYPE"].ToString();
-                    if (datatype == "decimal")
-                    {
-                        datatype = "numeric";
-                    }
-                    Columns.Add(column["COLUMN_NAME"].ToString(), datatype);
-                }
-                tables.Add(subtable["TABLE_NAME"].ToString(), Columns);
-            }
-            AppConfig.Base.dbTables = tables;
+            // StartHelper.Instance.Start(); //开启线程
         }
+        
     }
 }