Browse Source

perf: 移动支付回调优化

zhengjie 1 year ago
parent
commit
f486b56ea4
2 changed files with 39 additions and 20 deletions
  1. 32 11
      Business/MobilePay.cs
  2. 7 9
      InsuBusiness.cs

+ 32 - 11
Business/MobilePay.cs

@@ -191,23 +191,44 @@ namespace PTMedicalInsurance.Business
                 return -1;
             }
         }
+        /// <summary>
+        /// 回调确认
+        /// </summary>
+        /// <param name="inParam"></param>
+        /// <param name="outPar"></param>
+        /// <returns></returns>
+        public int MobilePayCallback(JObject joEncData, out string outPar)
+        {
+            outPar = string.Empty;
+            string setlInfo = JsonHelper.getDestValue(joEncData, "extData.SETLINFO");
+            if (string.IsNullOrEmpty(setlInfo))
+            {
+                //此时为异步返回结算内容
+                string ordStatus = JsonHelper.getDestValue(joEncData, "ordStas");
+                outPar = JsonHelper.setExceptionJson(0, "移动医保结算", "当前订单状态为:【" + ordStatus + "】,结算成功,但未返回结算明细!").ToString();
+                return 0;
+            }
+            //设置
+            return ConfirmResult(JObject.Parse(setlInfo), out outPar);
+        }
+
+        public int MobilePayCallback(out string outPar)
+        {
+            if (joParam != null) {
+                return MobilePayCallback(joParam, out outPar);
+            }
+            outPar = JsonHelper.setIrisReturnValue(-1,"移动支付回调,参数错误",null).ToString();
+            return -1;
+        }
+
         public int MobilePayConfirmSettlement(out string outPar)
         {
             outPar = "";
             try
             {
                 PayStatusQuery(out outPar);
-                JObject joEncData = JObject.Parse((outPar));
-                string setlInfo = JsonHelper.getDestValue(joEncData, "extData.SETLINFO");
-                if (string.IsNullOrEmpty(setlInfo))
-                {
-                    //此时为异步返回结算内容
-                    string ordStatus = JsonHelper.getDestValue(joEncData, "ordStas");
-                    outPar = JsonHelper.setExceptionJson(0, "移动医保结算", "当前订单状态为:【"+ordStatus+"】,结算成功,但未返回结算明细!").ToString();
-                    return 0;
-                }
-                //设置
-                return ConfirmResult(JObject.Parse(setlInfo), out outPar);
+                JObject joEncData = JObject.Parse(outPar);
+                return MobilePayCallback(joEncData, out outPar);
 
             }
             catch (Exception ex)

+ 7 - 9
InsuBusiness.cs

@@ -744,15 +744,6 @@ namespace PTMedicalInsurance
             //设置返回值,错误信息
             string errMsg, rtnResult = "", outParam;
 
-            JObject joParamMobile = JObject.Parse(InParam);
-            if (joParamMobile.ContainsKey("callType") && joParamMobile.ContainsKey("hiDocSn"))
-            {
-                //移动支付回调[6302]交易
-                MobilePay mp = new MobilePay();
-                mp.ConfirmResult(joParamMobile, out rtnResult);
-                return rtnResult;
-            }
-
             try
             {
                 //解析入参
@@ -1196,6 +1187,13 @@ namespace PTMedicalInsurance
                                 rtnResult = outParam;
                             return rtnResult;
                         }
+                    case "M6CallBack":  //移动支付回调
+                        {
+                            MobilePay mp = new MobilePay(InParam, out errMsg);
+                            mp.MobilePayCallback(out outParam);
+                            rtnResult = outParam;
+                            return rtnResult;
+                        }
                     case "M6Q": //移动支付查询
                         {
                             MobilePay mp = new MobilePay(InParam, out errMsg);