Browse Source

fix: 移动支付bug

zhengjie 1 year ago
parent
commit
5d279f7659
2 changed files with 151 additions and 73 deletions
  1. 137 72
      Business/MobilePay.cs
  2. 14 1
      InsuBusiness.cs

+ 137 - 72
Business/MobilePay.cs

@@ -17,7 +17,7 @@ namespace PTMedicalInsurance.Business
         private CenterBusiness cBus = new CenterBusiness();
         private CenterBusiness cBus = new CenterBusiness();
         private InvokeHelper invoker = new InvokeHelper();
         private InvokeHelper invoker = new InvokeHelper();
         private Patients MPat;
         private Patients MPat;
-        private Settlements MSettl;
+        public Settlements MSettl;
         private JArray jaFee;
         private JArray jaFee;
         //
         //
         //private string fixmedins_code;//定点医疗服务机构编码
         //private string fixmedins_code;//定点医疗服务机构编码
@@ -174,29 +174,6 @@ namespace PTMedicalInsurance.Business
                     outPar = errMsg;
                     outPar = errMsg;
                     return -1;
                     return -1;
                 }
                 }
-                //6301查询具体明细信息
-                //if (Get6301Inpar(out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //    return -1;
-                //}
-                //M6301Inpar = errMsg;
-                //JObject joM6301Rtn = invoker.invokeMPService("6301", eh.encrypt(M6301Inpar));
-                //if (JsonHelper.parseMPRtnValue(joM6301Rtn, out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //    return -1;
-                //}
-                //joEncData = JObject.Parse(eh.decrypt(errMsg));
-                //JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
-                //Global.writeLog(JsonHelper.Compress(joEncData));
-                ////设置
-                //setSettlementsBy6301Rtn(joSettlInfo);
-                ////存入MI 结算表
-                //if (saveSettlement(out errMsg) != 0)
-                //{
-                //    outPar = errMsg;
-                //}
                 //返回给HIS后端 
                 //返回给HIS后端 
                 JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
                 JObject joPreSettl = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.preSetl"));
                 //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joM6201Rtn, "encData"));
                 //JObject joTmp = JObject.Parse(JsonHelper.getDestValue(joM6201Rtn, "encData"));
@@ -232,7 +209,6 @@ namespace PTMedicalInsurance.Business
             outPar = "";
             outPar = "";
             try
             try
             {
             {
-                //EncryptHelper eh = new EncryptHelper();
                 //6301查询具体明细信息
                 //6301查询具体明细信息
                 if (Get6301Inpar(out errMsg) != 0)
                 if (Get6301Inpar(out errMsg) != 0)
                 {
                 {
@@ -247,9 +223,9 @@ namespace PTMedicalInsurance.Business
                     return -1;
                     return -1;
                 }
                 }
                 JObject joEncData = JObject.Parse((errMsg));
                 JObject joEncData = JObject.Parse((errMsg));
-                Global.writeLog(JsonHelper.Compress(joEncData));
+                JObject joSettlInfo = JObject.Parse(JsonHelper.getDestValue(joEncData, "extData.SETLINFO"));
                 //设置
                 //设置
-                setSettlementsBy6301Rtn(joEncData);
+                setSettlementsBy6301Rtn(joSettlInfo);
                 MSettl.confirmFlag = 1;
                 MSettl.confirmFlag = 1;
                 //存入MI 结算表
                 //存入MI 结算表
                 if (updateSettlement(out errMsg) != 0)
                 if (updateSettlement(out errMsg) != 0)
@@ -273,26 +249,103 @@ namespace PTMedicalInsurance.Business
         }
         }
         public int MobilePayCancelSettlement(out string outPar)
         public int MobilePayCancelSettlement(out string outPar)
         {
         {
-            string inParam,errMsg;
+            string errMsg, YH6203Inpar;
             outPar = "";
             outPar = "";
             try
             try
             {
             {
+                if (MSettl.onlineYBFalg != "Y")
+                {
+                    //读电子凭证
+                    //if (ReadEc_KM(out errMsg) != 0)
+                    //{
+                    //    outPar = errMsg;
+                    //    return -1;
+                    //}
+                }
+
+                //获取6203入参
                 if (Get6203Inpar(out errMsg) != 0)
                 if (Get6203Inpar(out errMsg) != 0)
                 {
                 {
                     outPar = errMsg;
                     outPar = errMsg;
                     return -1;
                     return -1;
                 }
                 }
-                inParam = errMsg;
-                JObject jo6203Rtn = invoker.invokeMPService("6203", inParam);
-                //M6202
+                YH6203Inpar = errMsg;
+                JObject jo6203Rtn = invoker.invokeMPService("6203", YH6203Inpar);
                 if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
                 if (JsonHelper.parseMPRtnValue(jo6203Rtn, out errMsg) != 0)
                 {
                 {
                     outPar = errMsg;
                     outPar = errMsg;
                     return -1;
                     return -1;
                 }
                 }
-                
-                //撤销医保平台结算数据
-                return cancleSettlement(MPat.settlID, out outPar);
+                else
+                {
+                    JObject joEncData = JObject.Parse(errMsg);
+                    string newSettlID = JsonHelper.getDestValue(joEncData, "extData.setlInfo.setl_id");
+                    //处理撤销数据
+                    if (cancleSettlement(MPat.settlID, out errMsg) != 0)
+                    {
+                        outPar = errMsg;
+                        return -1;
+                    }
+                    //joParam.Add("mdtrt_id", MPat.mdtrtID);
+                    //joParam.Add("insuplc_admdvs", MPat.insuplc_admdvs);
+                    //joParam.Add("setl_id", MPat.settlID);
+                    joParam.Add("middleSettleFlag", "");
+                    //退HIS结算
+                    if (hIS.cancleSettlementInfo(joParam, out errMsg) != 0)
+                    {
+                        outPar = errMsg;
+                        return -1;
+                    }
+                    else
+                    {
+                        outPar = errMsg;
+                        return 0;
+                    }
+                }
+
+
+            }
+            catch (Exception ex)
+            {
+                Global.writeLog("MobilePayCancelSettlement:" + ex.Message);
+                outPar = ex.Message;
+                return -1;
+            }
+        }
+
+        #region 读卡
+        public int ReadEc_KM(out string outPar)
+        {
+            outPar = "";
+            string errMsg = "";
+            try
+            {
+                EncryptHelper eh = new EncryptHelper();
+                dynamic jo = new JObject();
+                jo.mdtrt_cert_type = "01";
+                jo.cardtype = "";
+                jo.businesstype = "01301";
+                jo.operatorId = Global.user.ID;
+                jo.operatorName = Global.user.ID;
+                jo.officeId = Global.user.officeID;
+                jo.officeName = Global.user.officeName;
+
+                JObject joData = new JObject();
+                joData.Add("data", jo);
+                JObject jo1191Rtn = invoker.invokeCenterService(TradeEnum.ReadECToken, joData);
+                if (JsonHelper.parseCenterRtnValue(jo1191Rtn, out errMsg) != 0)
+                {
+                    outPar = errMsg;
+                    return -1;
+                }
+                else
+                {
+                    JObject joOutput = JObject.Parse(JsonHelper.getDestValue(jo1191Rtn, "output"));
+                    outPar = joOutput.ToString();
+                    setPatientByEc(joOutput);
+                    return 0;
+                }
+
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
@@ -301,6 +354,22 @@ namespace PTMedicalInsurance.Business
             }
             }
         }
         }
 
 
+        public void setPatientByEc(JObject jo)
+        {
+            MPat.name = JsonHelper.getDestValue(jo, "userName");
+            MPat.IDNO = JsonHelper.getDestValue(jo, "idNo");
+            MPat.certType = JsonHelper.getDestValue(jo, "idType");
+            MPat.token = JsonHelper.getDestValue(jo, "ecToken");
+            MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuOrg");
+            MPat.payAuthNo = JsonHelper.getDestValue(jo, "authNo");
+            MPat.gend = JsonHelper.getDestValue(jo, "gender");
+            MPat.brdy = JsonHelper.getDestValue(jo, "birthday");
+            MPat.naty = JsonHelper.getDestValue(jo, "nationality");
+            MPat.payOrdId = "";
+        }
+
+        #endregion
+
         #region 赋值MPat,Msettle结构体
         #region 赋值MPat,Msettle结构体
         public void setPatientByInPar()
         public void setPatientByInPar()
         {
         {
@@ -373,6 +442,7 @@ namespace PTMedicalInsurance.Business
         {
         {
             MSettl.settlID = JsonHelper.getDestValue(jo, "payOrdId");
             MSettl.settlID = JsonHelper.getDestValue(jo, "payOrdId");
             MPat.payOrdId = MSettl.settlID;
             MPat.payOrdId = MSettl.settlID;
+            MSettl.payOrdId = MSettl.settlID;
             MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
             MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
             MSettl.sumamt = getDecimalFee(jo, "feeSumamt");
             MSettl.sumamt = getDecimalFee(jo, "feeSumamt");
             MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
             MSettl.personCashPay = getDecimalFee(jo, "ownPayAmt");
@@ -401,53 +471,48 @@ namespace PTMedicalInsurance.Business
             MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
             MSettl.accountMutualAidAmount = getDecimalFee(jo, "extData.preSetl.acct_mulaid_pay");
         }
         }
 
 
-        public void setSettlementsBy6301Rtn(JObject joRtn)
+        public void setSettlementsBy6301Rtn(JObject jo)
         {
         {
-            JObject jo = JObject.Parse(JsonHelper.getDestValue(joRtn, "extData.setlinfo"));
-
-            MPat.settlID = JsonHelper.getDestValue(jo, "setlId");
-            MPat.psn_no = JsonHelper.getDestValue(jo, "psnNo");
+            MSettl.settlID = JsonHelper.getDestValue(jo, "setl_id");
+            MPat.psn_no = JsonHelper.getDestValue(jo, "psn_no");
             MPat.naty = JsonHelper.getDestValue(jo, "naty");
             MPat.naty = JsonHelper.getDestValue(jo, "naty");
-            MPat.name = JsonHelper.getDestValue(jo, "psnName");
+            //MPat.name = JsonHelper.getDestValue(jo, "name");
             MPat.age = JsonHelper.getDestValue(jo, "age");
             MPat.age = JsonHelper.getDestValue(jo, "age");
             MPat.gend = JsonHelper.getDestValue(jo, "gend");
             MPat.gend = JsonHelper.getDestValue(jo, "gend");
             MPat.certNO = JsonHelper.getDestValue(jo, "certno");
             MPat.certNO = JsonHelper.getDestValue(jo, "certno");
             MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
             MPat.brdy = JsonHelper.getDestValue(jo, "brdy");
             MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
             MPat.insuType = JsonHelper.getDestValue(jo, "insutype");
-            MPat.psn_type = JsonHelper.getDestValue(jo, "psnType");
-            MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrtCertType");
-            MPat.medType = JsonHelper.getDestValue(jo, "medType");
-            MPat.insuplc_admdvs = JsonHelper.getDestValue(joRtn, "extData.insuplcAdmdvs");
-
-            MPat.payOrdId = JsonHelper.getDestValue(joRtn, "payOrdId");
-            MSettl.ordStas = JsonHelper.getDestValue(joRtn, "ordStas");
-            MSettl.sumamt = getDecimalFee(joRtn, "feeSumamt");
-
-            MSettl.personCashPay = getDecimalFee(jo, "psnCashPay");
-            MSettl.accountPaySumamt = getDecimalFee(jo, "acctPay");
-            MSettl.fundPaySumamt = getDecimalFee(jo, "fundPaySumamt");
-
+            MPat.psn_type = JsonHelper.getDestValue(jo, "psn_type");
+            MPat.mdtrtcertType = JsonHelper.getDestValue(jo, "mdtrt_cert_type");
+            MPat.medType = JsonHelper.getDestValue(jo, "med_type");
+            //MPat.insuplc_admdvs = JsonHelper.getDestValue(jo, "insuplc_admdvs");
+            //MPat.payOrdId = JsonHelper.getDestValue(jo, "payOrdId");
+            MSettl.ordStas = JsonHelper.getDestValue(jo, "ordStas");
+            MSettl.sumamt = getDecimalFee(jo, "medfee_sumamt");
+            MSettl.personCashPay = getDecimalFee(jo, "psn_cash_pay");
+            MSettl.accountPaySumamt = getDecimalFee(jo, "acct_pay");
+            MSettl.fundPaySumamt = getDecimalFee(jo, "fund_pay_sumamt");
             //MSettl.deposit = getDecimalFee(jo, "deposit");
             //MSettl.deposit = getDecimalFee(jo, "deposit");
-            MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clrOptins");
-            MSettl.clearingType = JsonHelper.getDestValue(jo, "clrType");
-            MSettl.clearingWay = JsonHelper.getDestValue(jo, "clrWay");
-            MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlservPay");
-            MSettl.ownPayAmount = getDecimalFee(jo, "fulamtOwnpayAmt");
-            MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmtSelfpay");
-            MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpayAmt");
-            MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscpScpAmt");
-            MSettl.actualPayDeductible = getDecimalFee(jo, "actPayDedc");
-            MSettl.healthInsurancePay = getDecimalFee(jo, "hifpPay");
-            MSettl.healthInsuranceRatio = getDecimalFee(jo, "poolPropSelfpay");
-            MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifesPay");
-            MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmiPay");
-            MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifobPay");
-            MSettl.medicalAssistPay = getDecimalFee(jo, "mafPay");
-            MSettl.hospitalPartAmount = getDecimalFee(jo, "hospPartAmt");
-            MSettl.otherPay = getDecimalFee(jo, "othPay");
-            MSettl.personPaySumamt = getDecimalFee(jo, "psnPartAmt");
+            MSettl.clearingOrgan = JsonHelper.getDestValue(jo, "clr_optins");
+            MSettl.clearingType = JsonHelper.getDestValue(jo, "clr_type");
+            MSettl.clearingWay = JsonHelper.getDestValue(jo, "clr_way");
+            MSettl.civilserviceAllowancePay = getDecimalFee(jo, "cvlserv_pay");
+            MSettl.ownPayAmount = getDecimalFee(jo, "fulamt_ownpay_amt");
+            MSettl.overLimitAmountmt = getDecimalFee(jo, "overlmt_selfpay");
+            MSettl.preSelfPayAmount = getDecimalFee(jo, "preselfpay_amt");
+            MSettl.inPolicyRangeAmount = getDecimalFee(jo, "inscp_scp_amt");
+            MSettl.actualPayDeductible = getDecimalFee(jo, "act_pay_dedc");
+            MSettl.healthInsurancePay = getDecimalFee(jo, "hifp_pay");
+            MSettl.healthInsuranceRatio = getDecimalFee(jo, "pool_prop_selfpay");
+            MSettl.enterpriseSupplementPay = getDecimalFee(jo, "hifes_pay");
+            MSettl.seriousIllnessPay = getDecimalFee(jo, "hifmi_pay");
+            MSettl.largeExpensesSupplementPay = getDecimalFee(jo, "hifob_pay");
+            MSettl.medicalAssistPay = getDecimalFee(jo, "maf_pay");
+            MSettl.hospitalPartAmount = getDecimalFee(jo, "hosp_part_amt");
+            MSettl.otherPay = getDecimalFee(jo, "oth_pay");
+            MSettl.personPaySumamt = getDecimalFee(jo, "psn_part_amt");
             MSettl.balance = getDecimalFee(jo, "balc");
             MSettl.balance = getDecimalFee(jo, "balc");
-            MSettl.accountMutualAidAmount = getDecimalFee(jo, "acctMulaidPay");
+            MSettl.accountMutualAidAmount = getDecimalFee(jo, "acct_mulaid_pay");
         }
         }
 
 
         public void setSettlementsByInPar()
         public void setSettlementsByInPar()

+ 14 - 1
InsuBusiness.cs

@@ -31,6 +31,7 @@ namespace PTMedicalInsurance
         private JArray jaParams;
         private JArray jaParams;
         private JObject joParam;
         private JObject joParam;
         private JObject joInterface;
         private JObject joInterface;
+        private JObject joInsuAdmObj;
 
 
         //设置业务实例
         //设置业务实例
         CenterBusiness cBus = new CenterBusiness();
         CenterBusiness cBus = new CenterBusiness();
@@ -60,8 +61,10 @@ namespace PTMedicalInsurance
                 jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
                 jaSession = JArray.Parse(JsonHelper.getDestValue(joInParam, "session"));
                 Global.curEvt.jaSession = jaSession;
                 Global.curEvt.jaSession = jaSession;
                 jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
                 jaParams = JArray.Parse(JsonHelper.getDestValue(joInParam, "params"));
-                joParam = JObject.FromObject(jaParams[0]);                
+                joParam = JObject.FromObject(jaParams[0]);
 
 
+                if (JsonHelper.getDestValue(joInParam, "insuAdmObj") != "")
+                    joInsuAdmObj = JObject.Parse(JsonHelper.getDestValue(joInParam, "insuAdmObj"));
                 joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
                 joInterface = JObject.Parse(JsonHelper.getDestValue(joInParam, "interfaceinfo"));
 
 
                 businessType = JsonHelper.getDestValue(joInParam, "businessType");
                 businessType = JsonHelper.getDestValue(joInParam, "businessType");
@@ -453,12 +456,22 @@ namespace PTMedicalInsurance
                     case "M6C"://门诊移动支付结算撤销
                     case "M6C"://门诊移动支付结算撤销
                         {
                         {
                             #region 移动支付取消
                             #region 移动支付取消
+                            string onlineYBFalg = JsonHelper.getDestValue(joInsuAdmObj, "onlineYBFalg");
                             MobilePay mp = new MobilePay(InParam, out errMsg);
                             MobilePay mp = new MobilePay(InParam, out errMsg);
                             if (errMsg != "")
                             if (errMsg != "")
                             {
                             {
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", errMsg).ToString();
                                 return rtnResult;
                                 return rtnResult;
                             }
                             }
+                            if (String.IsNullOrEmpty(onlineYBFalg))
+                            {
+                                mp.MSettl.onlineYBFalg = "N";
+                            }
+                            else
+                            {
+                                mp.MSettl.onlineYBFalg = onlineYBFalg;
+                            }
+
                             if (mp.MobilePayCancelSettlement(out outParam) != 0)
                             if (mp.MobilePayCancelSettlement(out outParam) != 0)
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
                                 rtnResult = JsonHelper.setExceptionJson(-1, "Settlement 交易", outParam).ToString();
                             else
                             else