Explorar el Código

perf: 移动支付测试通过

zhengjie hace 1 año
padre
commit
77445c4171

+ 5 - 19
Business/HisMainBusiness.cs

@@ -122,16 +122,8 @@ namespace PTMedicalInsurance.Business
             inf.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2");
 
             IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini");
-            inf.fixedPointType = ini.ReadValue("FixedPointInfo", "TYPE"); //1.省本级 2.市本级 3.区本级
-
-            //获取AK,SK(可配置)
-            IniFile urlIni = new IniFile(Global.curEvt.path + @"\EncrypInfo.ini");
-            string ak = urlIni.ReadValue("KEY", "AK");
-            string sk = urlIni.ReadValue("KEY", "SK");
-            if (!string.IsNullOrEmpty(ak) && !string.IsNullOrEmpty(sk)) {
-                inf.AK = ak;
-                inf.SK = sk;
-            }
+            Global.inf.fixedPointType = ini.ReadValue("FixedPointInfo", "TYPE"); //1.省本级 2.市本级 3.区本级
+
 
             inf.cainfo = "";
         }
@@ -166,15 +158,9 @@ namespace PTMedicalInsurance.Business
             inf.cardURL = "http://10.77.211.236/1.0.0/agent-card-init";
             inf.ecURL = JsonHelper.getDestValue(joInpar, "CenterURL2");
 
-            //获取AK,SK(可配置)
-            IniFile urlIni = new IniFile(Global.curEvt.path + @"\EncrypInfo.ini");
-            string ak = urlIni.ReadValue("KEY", "AK");
-            string sk = urlIni.ReadValue("KEY", "SK");
-            if (!string.IsNullOrEmpty(ak) && !string.IsNullOrEmpty(sk))
-            {
-                inf.AK = ak;
-                inf.SK = sk;
-            }
+            IniFile ini = new IniFile(Global.curEvt.path + @"\INSUConfigure.ini");
+            Global.inf.fixedPointType = ini.ReadValue("FixedPointInfo", "TYPE"); //1.省本级 2.市本级 3.区本级
+
 
             inf.cainfo = "";
 

+ 1 - 1
Business/MobilePay.cs

@@ -136,7 +136,7 @@ namespace PTMedicalInsurance.Business
                 JObject joM6201Rtn = invoker.invokeMPService("6201", errMsg);
                 if (JsonHelper.parseMPRtnValue(joM6201Rtn, out errMsg) != 0)
                 {
-                    outPar = errMsg;
+                    outPar = joM6201Rtn.ToString();
                     return -1;
                 }
                 JObject joEncData = JObject.Parse(errMsg);

+ 2 - 2
Common/SignUtils.cs

@@ -45,9 +45,9 @@ namespace PTMedicalInsurance.Common
 			jobject.Add("encType", "SM4");
 			jobject.Add("signType", "SM2");
 			jobject.Add("timestamp", ts); ;
-			//jobject.Add("version", "2.0.1");
+			jobject.Add("version", "2.0.1");
 
-			string signData = SMUtil.sign(jobject, appSecret, prvkey);
+            string signData = SMUtil.sign(jobject, appSecret, prvkey);
 			string encData = SMUtil.encrypt(data, appId, appSecret);
 
 			jobject.Add("encData", encData);

+ 52 - 15
Helper/InvokeHelper.cs

@@ -36,15 +36,22 @@ namespace PTMedicalInsurance.Helper
         private string authorization;
 
         public InvokeHelper()
+        {
+            LoadCenterURL(false);
+        }
+
+
+        private void LoadCenterURL(bool reloadFromCfgFile)
         {
             IniFile ini = new IniFile(Global.curEvt.path + @"\CenterServiceURL.ini");
-            if (string.IsNullOrEmpty(Global.inf.centerURL))
+            // 默认采用的是后台配置的地址
+            if (reloadFromCfgFile)
             {
                 Global.inf.centerURL = ini.ReadValue("CENTER", "url");
                 Global.inf.uploadURL = ini.ReadValue("CENTER", "upload");
                 Global.inf.downURL = ini.ReadValue("CENTER", "download");
-                Global.inf.ecURL = ini.ReadValue("CENTER", "ecToken");
             }
+            Global.inf.ecURL = ini.ReadValue("CENTER", "ecToken");
             Global.inf.mobilePayURL = ini.ReadValue("CENTER", "mobilePay");
             Global.inf.ecPrescURL = ini.ReadValue("CENTER", "prescription");
             // 移动支付
@@ -60,6 +67,38 @@ namespace PTMedicalInsurance.Helper
         }
 
 
+        /// <summary>
+        /// API密钥
+        /// </summary>
+        private void LoadAPIKey(string prefix)
+        {
+            //获取AK,SK(可配置)
+            IniFile urlIni = new IniFile(Global.curEvt.path + @"\EncrypInfo.ini");
+            string ak = urlIni.ReadValue(prefix, "AK");
+            string sk = urlIni.ReadValue(prefix, "SK");
+            if (!string.IsNullOrEmpty(ak) && !string.IsNullOrEmpty(sk))
+            {
+                Global.inf.AK = ak;
+                Global.inf.SK = sk;
+            }
+        }
+
+        /// <summary>
+        /// 核心接口密钥
+        /// </summary>
+        private void LoadCoreAPIKey()
+        {
+            LoadAPIKey("KEY");
+        }
+        /// <summary>
+        /// 移动支付密钥
+        /// </summary>
+        private void LoadMobileAPIKey()
+        {
+            LoadAPIKey("MOBILE");
+        }
+
+
         #region 内部服务调用
 
         /// <summary>
@@ -199,12 +238,6 @@ namespace PTMedicalInsurance.Helper
         {
             Global.curEvt.URL = Global.inf.centerURL + funNo;
             string data = JsonHelper.setCenterInpar(funNo, joInput);
-            //if (funNo.StartsWith("35"))
-            //{
-            //    // 进销存测试
-            //    Global.curEvt.URL = "http://10.42.149.235:9091/hss/api/hiinterface";
-            //}
-
             return invokeCenterService(data);
         }
 
@@ -219,6 +252,7 @@ namespace PTMedicalInsurance.Helper
                 int iInt = center.Init(ref errMsg);
                 if (iInt == 0)
                 {
+                    LoadCoreAPIKey();
                     iInt = center.Business(data, ref outputData, ref errMsg);
                     if (iInt == 0 && !string.IsNullOrEmpty(outputData))
                     {
@@ -260,6 +294,13 @@ namespace PTMedicalInsurance.Helper
             string funNo = trade.GetCode() ;
             Global.curEvt.funNo = funNo;
 
+            if (Global.curEvt.testMode)
+            {
+                // 医保测试环境
+                LoadCenterURL(true);
+            }
+
+
             string prefix = Global.inf.centerURL;
             switch (trade)
             {
@@ -273,13 +314,7 @@ namespace PTMedicalInsurance.Helper
                     prefix = Global.inf.centerURL;
                     break;
             }
-
-            if (Global.curEvt.testMode)
-            {
-                // 医保测试环境
-                prefix = "http://10.77.224.18:9001/CSB/hsa-fsi-no";
-            }
-
+           
             // 根据情况确实是否需要加funNo
             Global.curEvt.URL = prefix + Global.curEvt.funNo;
         }
@@ -414,6 +449,8 @@ namespace PTMedicalInsurance.Helper
                 try
                 {
                     InvokeRestCenter mobileCenter = new InvokeRestCenter();
+                    LoadMobileAPIKey();
+
                     int iInt = mobileCenter.Business(data, ref outputData, ref errMsg);
                     joRtn = JObject.Parse(outputData);
 

+ 6 - 6
Helper/InvokeRestCenter.cs

@@ -30,11 +30,11 @@ namespace PTMedicalInsurance.Helper
                 request.ContentType = "application/json";
 
                 String stamp = TimeStamp.get13().ToString();
-                string apiName = Global.curEvt.URL.Substring(Global.curEvt.URL.Length - 12);
-                if (apiName.Contains("4101A"))
-                {
-                    apiName = "h" + apiName;
-                }
+                string apiName = Global.curEvt.URL.Substring(Global.curEvt.URL.LastIndexOf("/") + 1);
+                //if (apiName.Contains("4101A"))
+                //{
+                //    apiName = "h" + apiName;
+                //}
                 Global.writeLog(apiName);
                 //南昌增加头部信息
                 string sTemp = "_api_access_key=" + Global.inf.AK
@@ -74,7 +74,7 @@ namespace PTMedicalInsurance.Helper
                     Stream myResponseStream = res.GetResponseStream();
                     StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.UTF8);
                     string retString = myStreamReader.ReadToEnd();
-                    outputData = JsonHelper.setExceptionJson(-99, "centerServeiceInvok中获得响应流异常", retString).ToString();
+                    outputData = JsonHelper.setExceptionJson(-99, "异常返回", retString).ToString();
                     return -1;
                 }
                 outputData = getResponseData(response);

+ 4 - 0
Helper/JsonHelper.cs

@@ -432,6 +432,10 @@ namespace PTMedicalInsurance.Helper
                 string success = getDestValue(joRtn, "success");
                 string message = getDestValue(joRtn, "message");
                 string encData = getDestValue(joRtn, "encData");
+                if (string.IsNullOrEmpty(message)) {
+                    message = getDestValue(joRtn, "errorMessage");
+                }
+
                 //Global.writeLog("success:" + success);
                 if (success != "True")
                 {